qemu qcow2 disk enlarge

來源:互聯網
上載者:User

標籤:使用   io   art   for   re   c   

>

1。 

[[email protected] kvm]# qemu-img info new.qcow2 image: new.qcow2file format: qcow2virtual size: 60G (64424509440 bytes)disk size: 7.0Gcluster_size: 65536qemu-img resize  filename +20GImage resized.[[email protected] kvm]# qemu-img  info new.qcow2 image: new.qcow2file format: qcow2virtual size: 80G (85899345920 bytes)disk size: 7.0Gcluster_size: 65536

磁碟擴充的第一步搞定。這裡建議只搞一個/分區, 添加完磁碟後,可以識別掛載出來。我們是一個/ 和一個/export 分區, 擴充完磁碟後,進入到系統,fdisk -l  接著就是刪除磁碟建立磁碟的過程。這個大家應該比我更熟練。就不多說了。


2. 磁碟擴充

擴充qcow2 磁碟格式

使用命令

virt-filesystems --long -h --all -a olddisktruncate -r olddisk newdisktruncate -s +5G newdisk# Note "/dev/sda2" is a partition inside the "olddisk" file.virt-resize --expand /dev/sda2 olddisk newdisk

cp net.qcow2 nett.qcow2[[email protected] kvm]# virt-df -h net.qcow2 Filesystem                                Size       Used  Available  Use%net.qcow2:/dev/sda1                       194M        28M       155M   15%net.qcow2:/dev/sda2                        19G       6.3G        12G   33%net.qcow2:/dev/sda5                        36G       176M        34G    1%[[email protected] kvm]# virt-filesystems --long -h --all -a net.qcow2Name       Type        VFS      Label  MBR  Size  Parent/dev/sda1  filesystem  ext4     -      -    200M  -/dev/sda2  filesystem  ext4     -      -    20G   -/dev/sda3  filesystem  swap     -      -    4.0G  -/dev/sda4  filesystem  unknown  -      -    1.0K  -/dev/sda5  filesystem  ext4     -      -    36G   -/dev/sda1  partition   -        -      83   200M  /dev/sda/dev/sda2  partition   -        -      83   20G   /dev/sda/dev/sda3  partition   -        -      82   4.0G  /dev/sda/dev/sda4  partition   -        -      05   1.0K  /dev/sda/dev/sda5  partition   -        -      83   36G   /dev/sda/dev/sda   device      -        -      -    80G   -選擇要擴充的磁碟  我選擇的是/dev/sda2  需要執行如下命令   truncate -r net.qcow2 nett.qcow2truncate -s +5G nett.qcow2 [[email protected] kvm]# virt-resize  --expand /dev/sda2  net.qcow2  nett.qcow2  枓鈻掆枓鈼74% 鉄︹枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓Resize operation completed with no errors.  Before deleting the old disk, carefully check that the resized disk boots and works correctly這就轉換成功[[email protected] kvm]# virt-filesystems  --long -h --all -a nett.qcow2 Name       Type        VFS      Label  MBR  Size  Parent/dev/sda1  filesystem  ext4     -      -    200M  -/dev/sda2  filesystem  ext4     -      -    40G   -/dev/sda3  filesystem  swap     -      -    4.0G  -/dev/sda4  filesystem  unknown  -      -    1.0K  -/dev/sda5  filesystem  ext4     -      -    36G   -/dev/sda1  partition   -        -      83   200M  /dev/sda/dev/sda2  partition   -        -      83   40G   /dev/sda  # 增長了不少。/dev/sda3  partition   -        -      82   4.0G  /dev/sda/dev/sda4  partition   -        -      05   1.0K  /dev/sda/dev/sda5  partition   -        -      83   36G   /dev/sda/dev/sda   device      -        -      -    80G   -[[email protected] kvm]# qemu-img  info nett.qcow2 image: nett.qcow2file format: qcow2virtual size: 80G (85899345920 bytes)disk size: 60Gcluster_size: 65536virt-resize 只能擴充主要磁碟分割。/dev/sda5 已經變為擴充分區,無法直接對其擴充,可以對/dev/sda4進行擴充,再重新格式化磁碟,重新分區。


如過哪位仁兄有更好或其他方式,請不吝賜教。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.