In the latest nbdkit (and at the time of writing you will need nbdkit from git) you can type this magical incantation:
nbdkit data data=" @0x1c0 2 0 0xee 0xfe 0xff 0xff 0x01 0 0 0 0xff 0xff 0xff 0xff @0x1fe 0x55 0xaa @0x200 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54 0 0 1 0 0x5c 0 0 0 0x9b 0xe5 0x6a 0xc5 0 0 0 0 1 0 0 0 0 0 0 0 0xff 0xff 0xff 0xff 0xff 0xff 0x37 0 0x22 0 0 0 0 0 0 0 0xde 0xff 0xff 0xff 0xff 0xff 0x37 0 0x72 0xb6 0x9e 0x0c 0x6b 0x76 0xb0 0x4f 0xb3 0x94 0xb2 0xf1 0x61 0xec 0xdd 0x3c 2 0 0 0 0 0 0 0 0x80 0 0 0 0x80 0 0 0 0x79 0x8a 0xd0 0x7e 0 0 0 0 @0x400 0xaf 0x3d 0xc6 0x0f 0x83 0x84 0x72 0x47 0x8e 0x79 0x3d 0x69 0xd8 0x47 0x7d 0xe4 0xd5 0x19 0x46 0x95 0xe3 0x82 0xa8 0x4c 0x95 0x82 0x7a 0xbe 0x1c 0xfc 0x62 0x90 0x80 0 0 0 0 0 0 0 0x80 0xff 0xff 0xff 0xff 0xff 0x37 0 0 0 0 0 0 0 0 0 0x70 0 0x31 0 0 0 0 0 @0x6fffffffffffbe00 0xaf 0x3d 0xc6 0x0f 0x83 0x84 0x72 0x47 0x8e 0x79 0x3d 0x69 0xd8 0x47 0x7d 0xe4 0xd5 0x19 0x46 0x95 0xe3 0x82 0xa8 0x4c 0x95 0x82 0x7a 0xbe 0x1c 0xfc 0x62 0x90 0x80 0 0 0 0 0 0 0 0x80 0xff 0xff 0xff 0xff 0xff 0x37 0 0 0 0 0 0 0 0 0 0x70 0 0x31 0 0 0 0 0 @0x6ffffffffffffe00 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54 0 0 1 0 0x5c 0 0 0 0x6c 0x76 0xa1 0xa0 0 0 0 0 0xff 0xff 0xff 0xff 0xff 0xff 0x37 0 1 0 0 0 0 0 0 0 0x22 0 0 0 0 0 0 0 0xde 0xff 0xff 0xff 0xff 0xff 0x37 0 0x72 0xb6 0x9e 0x0c 0x6b 0x76 0xb0 0x4f 0xb3 0x94 0xb2 0xf1 0x61 0xec 0xdd 0x3c 0xdf 0xff 0xff 0xff 0xff 0xff 0x37 0 0x80 0 0 0 0x80 0 0 0 0x79 0x8a 0xd0 0x7e 0 0 0 0 " size=7E
When nbdkit starts up you can connect to it in a few ways. If you have a qemu virtual machine running an installed operating system, attach a second NBD drive. On the command line that would look like this:
$ qemu-system-x86_64 ... -file drive=nbd:localhost:10809,if=virtio
Or you could use guestfish:
$ guestfish --format=raw -a nbd://localhost ><fs> run
What this creates is a 7 exabyte disk with a single, empty GPT partition.
7 exabytes is a lot. It’s 8,070,450,532,247,928,832 bytes, or about 7 billion gigabytes. In fact even with ever increasing storage capacities in hard disk drives it’ll be a very long time before we get exabyte drives.
Peculiar things happen when you try to use this disk in Linux. For sure the kernel has no problem finding the partition, creating a /dev/sda1
device, and returning the right size. Ext4 has a maximum filesystem size of merely 1 exabyte so it won’t even try to make a filesystem, and on my laptop trying to write an XFS filesystem on the partition just caused qemu to grind away at 200% CPU making no apparent progress even after many minutes.
Why not throw your own favourite disk analysis tools at this image and see what they make of it.
Finally how did I create the magic command line above?
I used the nbdkit memory plugin to make an empty 7 EB disk. Note this requires a recent version of the plugin which was rewritten with support for sparse arrays.
$ nbdkit memory size=7E
Then I could connect to it with guestfish to create the GPT partition:
$ guestfish --format=raw -a nbd://localhost ><fs> run ><fs> part-disk /dev/sda gpt
GPT uses a partition table at the beginning and end of the disk. So – still in guestfish – I could sample what the partitioning tool had written to both ends of the disk:
><fs> pread-device /dev/sda 1M 0 | cat > start ><fs> pread-device /dev/sda 1M 8070450532246880256 | cat > end
I then used hexdump + manual inspection of the hexdump output to write the long data string:
$ hexdump -C start 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001c0 02 00 ee fe ff ff 01 00 00 00 ff ff ff ff 00 00 |................| 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| ...
translates to …
@0x1c0 2 0 0xee 0xfe 0xff 0xff 0x01 0 0 0 0xff 0xff 0xff 0xff @0x1fe 0x55 0xaa
Pingback: nbdkit as a flexible alternative to loopback mounts | Richard WM Jones