I'm experimenting with repartitioning in a KVM virtual. I have created a new qcow2 disk and mounted in a virtual. I'm experimenting with resizing the filesystem and repartitioning. I had previously unmounted and shrunk the filesystem using e2fsk -f and then resize2fs -M down to around 30k blocks. From what I've read online, to shrink the partition I now need to delete it, and then recreate it with a smaller block count (no less than the size of my file system) at the same starting sector. When I use fdisk to delete partition 1, and then recreate it, my lowest starting sector is 2048. As you can see in the output below, partition 1 originally starts at sector 8. What am I doing incorrectly?
pphan@www-dev1:~$ mount -l -t ext3 /dev/vdb1 on /wsrv type ext3 (rw) pphan@www-dev1:~$ sudo umount /wsrv pphan@www-dev1:~$ sudo fdisk -u -c -l /dev/vdb Disk /dev/vdb: 1073 MB, 1073741824 bytes 9 heads, 8 sectors/track, 29127 cylinders, total 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xad16440c Device Boot Start End Blocks Id System /dev/vdb1 8 2097143 1048568 83 Linux
Ubuntu 10.04.2 host and guest. I have tagged libvirt-KVM because I am not sure if this problem is specific to disk images.