Finally give the end sector or just let fdisk pick the highest sector you can use. You MUST use the same start sector as was used before. Type n and give the desired partition number, and then the start sector. Type d and give the partition number to delete. Then the partition will contain a valid file system. What you will do is to delete that partition from the partition table and create a new partition that starts at the exact same sector but ends at a later one. Type p to print out the partiton table and look for the start sector of your partition, for instance partition 2 starts at sector 106496. A quick way to do it is to use dd dd if=/dev/zero of=disk.img bs=1c seek=4G count=0Ģ) make the partition bigger using fdisk (I wish I could do this in parted or some nicer tool. What you have to do is toġ) make the whole file bigger, say 4GiB. it has a partition table and one or more partitions, and say you want to make the last partition larger. I think Caesium's answer is fine, I'd just like to write down some other commands to achieve the same thing.Īssume you have a file disk.img with a disk image, i.e. Use fdisk or cfdisk, or whatever you feel comfortable with - you should see a whole bunch of unallocated space on your guest disk now.ģ) Finally, if you resized your existing partition, make the filesystem inside the new bigger partition bigger (this is actually in the guide linked above anyway). OR 2b) creating a new partition would be simpler (and safer) if you just want more storage space. It's quite a lot to copy here, so I'll just link instead for now. This is quite involved and probably the most dangerous part. You need to boot off a LiveCD in your guest for this, since you won't be able to mess with a mounted partition. Now your guest can see a bigger disk, but still has old partitions and filesystems.Ģ) Make the partition inside the disk image bigger. In your host: qemu-img resize foo.qcow2 +32G I recommend before doing any of this you take a complete copy of the disk image as it is, then when it all breaks you can copy it back to start over.ġ) Make the disk image bigger. # mv /var/lib/libvirt/images/outdisk /var/lib/libvirt/images/Win7.img Make a backup just in case (or use mv if you do not want the backup): # cp /var/lib/libvirt/images/Win7.img /var/lib/libvirt/images/ Before deleting the oldĭisk, carefully check that the resized disk boots and works correctly. Resize operation completed with no errors. Įxpanding /dev/sda2 using the 'ntfsresize' method. Setting up initial partition table on outdisk. Theįilesystem ntfs on /dev/sda2 will be expanded using the dev/sda2: This partition will be resized from 32G to 64G. dev/sda1: This partition will be left alone. You'll need to expand /dev/sda2 (not the boot partition): # virt-resize -expand /dev/sda2 /var/lib/libvirt/images/Win7.img /var/lib/libvirt/images/outdiskĮxamining /var/lib/libvirt/images/Win7.img. You may need to adapt /var/lib/libvirt/images/Win7.img in the following: # virt-filesystems -long -parts -blkdevs -h -a /var/lib/libvirt/images/Win7.imgĬreate your 64G disk: # truncate -s 64G /var/lib/libvirt/images/outdisk Get the location of your VM disk: # virsh dumpxml Win7 | xpath -e /domain/devices/disk/source Install the tool: # apt-get install libguestfs-tools First thing make sure your VM is shut down: Let's assume your image is called Win7 (why not?). This handle pretty much everything under the hood now. On Debian based distro you should use virt-resize instead.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |