The test script:

#!/bin/bash -
set -e

# test case 1: only primary partitions

guestfish -N disk <<EOF
part-init /dev/sda mbr
part-add /dev/sda p 64 255
part-add /dev/sda p 256 -128
EOF
virt-filesystems --all --long -h -a test1.img
truncate -s 1G test2.img
virt-resize --expand /dev/sda1 test1.img test2.img

if [ ! $? -eq 0 ]; then exit 1; fi

rm -rf test1.img test2.img

# test case 2: only logical partitions

guestfish -N disk <<EOF
part-init /dev/sda mbr
part-add /dev/sda extended 64 2048
part-add /dev/sda logical 512 1024
part-add /dev/sda logical 1026 2048
EOF
virt-filesystems --all --long -h -a test1.img
truncate -s 1G test2.img
virt-resize --expand /dev/sda5 --resize /dev/sda6=+2000% test1.img test2.img

if [ ! $? -eq 0 ]; then exit 1; fi

rm -rf test1.img test2.img

# test case 3: primary partitions and logical partitions

guestfish -N disk <<EOF
part-init /dev/sda mbr
part-add /dev/sda p 64 255
part-add /dev/sda p 256 1024
part-add /dev/sda extended 1026 4096
part-add /dev/sda logical 1028 2048
part-add /dev/sda logical 2050 4096
EOF
virt-filesystems --all --long -h -a test1.img
truncate -s 1G test2.img
virt-resize --expand /dev/sda5 --resize /dev/sda6=+1000% --resize 
/dev/sda1=+20% test1.img test2.img

_______________________________________________
Libguestfs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to