75d51474efe284565f2c4291f4f9e077f4dd6ed4
[libguestfs.git] / tools / test-virt-resize.sh
1 #!/bin/bash -
2
3 export LANG=C
4 set -e
5
6 # Test expanding.
7 #
8 # This exercises a number of interesting codepaths including resizing
9 # LV content, handling GPT, and using qcow2 as a target.
10
11 ../fish/guestfish -N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
12
13 qemu-img create -f qcow2 test2.img 500M
14 ./virt-resize -d --expand /dev/sda2 --lv-expand /dev/VG/LV test1.img test2.img
15
16 # Test shrinking in a semi-realistic scenario.  Although the disk
17 # image created above contains no data, we will nevertheless use
18 # similar operations to ones that might be used by a real admin.
19
20 ../fish/guestfish -a test1.img <<EOF
21 run
22 resize2fs-size /dev/VG/LV 190M
23 lvresize /dev/VG/LV 190
24 pvresize-size /dev/sda2 200M
25 fsck ext4 /dev/VG/LV
26 EOF
27
28 rm -f test2.img; truncate -s 300M test2.img
29 ./virt-resize -d --shrink /dev/sda2 test1.img test2.img
30
31 rm -f test1.img test2.img