[Libguestfs] [PATCH nbdkit v3 2/5] tests: Implement a better nbdkit-partition-filter test.

Eric Blake eblake at redhat.com
Tue Jan 22 23:04:35 UTC 2019


On 1/22/19 4:20 PM, Richard W.M. Jones wrote:
> Test the partition filter against real life partition tables created
> by sfdisk.
> ---

> +
> +test dos 1 <<'EOF'
> +2048 1023 L -
> +EOF
> +
> +test dos 2 <<'EOF'
> +2048 1023 L -
> +4096 4095 L -
> +EOF

I don't know how to make sfdisk populate ONLY partition 2 using
non-label form (short of populating both 1 and 2, then deleting
partition 1), but as there are disks in the wild like that, it might
make for an interesting test.  But I _do_ know how to do it using
labeled form, by doing it manually and then letting --dump tell me how
to repeat it:

$ truncate --size 1G disk
$ sfdisk -X dos disk <<\EOF
, 100M
, 100M
EOF
$ sfdisk --delete disk 1
$ sfdisk --dump disk
label: dos
label-id: 0x1b18e388
device: disk
unit: sectors

disk2 : start=      206848, size=      204800, type=83


In fact, labeled form is how you convince sfdisk to create partitions in
non-ascending order, to the point that 'sfdisk --reorder' then shuffles
the tables (but not the partitions themselves) to be back in ascending
order (of course, reordering can invalidate /etc/fstab and other
references in the guest OS that were keying off of partition number
instead of label)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190122/70c1ff9d/attachment.sig>


More information about the Libguestfs mailing list