shrink qcow2 ext4 filesystem
I think these were the steps I took. This shit took forever
Guestfish the image1
guestfish -rw -a myimg.qcow
start the guestfish vm an env1
><fs> run
Inspect current partitions. These are listed in bytes
1 | ><fs> part-list /dev/sda |
Del the partition you’re shrinking1
><fs> part-del /dev/sda 1
Add it back at your preferred size. Note that part-add is in sectors1
><fs> part-add /dev/sda p 2048 26213887
The partition will still be the same size in your list until you resize1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16><fs> part-list /dev/sda
[0] = {
part_num: 1
part_start: 1048576
part_end: 13421510655
part_size: 13420462080
}
><fs> resize2fs /dev/sda1
><fs> part-list /dev/sda
[0] = {
part_num: 1
part_start: 1048576
part_end: 13421510655
part_size: 13420462080
}
><fs> quit
Now convert to raw, create a new container which is larger than your new desired size
1 | root()@8798.blake_test_playground [glance_test]# qemu-img info blake_test.full |