A way to extend a RAW image's storage by using qemu-img


In some exceptional case, we only have a RAW image with a shortages-storage and need to extend it.

To resolve this problem, I searched internet and found someone said that the linux's internal command "dd" could do it.

I haven't verified the "dd" way but I tried a more smart and more flexible way like below:




first, create a sparse image ( qcow2 ) base on the RAW image:

      eg:  qemu-img  create   -b  [base.RAW]  -f  qcow2  [sparse.qcow2]


second, use qemu-img's resize command to resize the sparse image's size:

      eg:  qemu-img  resize  [sparse.qcow2]  +10G


third,  boot and login this sparse image , actually, because of the qcow2 format's feature which called Copy-on-Write,

      this image will conserve the additional date of the RAW image.


fourth,  use linux's internal command "fdisk" to create a new partition, and use command "partprobe" to refresh the partition table.


fifth,  use command "df  -T" to check the using file system type and then use command "mkfs.[FileSystemType]" to create filesystem for the new partition,

      if you finished them above all, now you can mount the new partition to a specified directory.


with this, now you've extend a RAW image's storage, but the operation of new partition's mount is not permanent,

maybe you need type "blkid" or "ls  -l  /dev/disk/by-uuid" to find the new partition's UUID and write it in the fstab,

maybe you're just extend the storage for temporary using, so , it's enough.


ps: actually, in my opinion, this way also can be worked for the QCOW2 type image.

thanks.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值