0

I just have 4.6GB VDI image. I have to copy it into a FAT32 Filesystem. I cannot use VMDK format and only VDI images.

How can I split the VDI into smaller VDI chunks so I can copy it into a USB.

Hennes
  • 65,804
  • 7
  • 115
  • 169

1 Answers1

3

Do you just need it split into chunks small enough to fit on a FAT32 filesystem so that you can transport or copy it? If that is the case, you can:

  • Use split to split a file into pieces.
  • Or use dd to do the same.
  • Or archive it (e.g. multi-part RARs or multi-part ZIP files).

If you need the VM to actually run from the pen drive:

  • Change the filesystem. FAT32 is limited to 4GiB or smaller files, simply because that is a limit of that filesystem.
  • Or change to a file format which can be split. (Why are VMDKs not an option?).
  • Or go all out ugly with a loop-back filesystem, RAIDing multiple 4GiB files files on the FAT32 formatted pendrive into a single partition large enough to handle, and use a different filesystem on that.


Edit 25-5-2014: Adding more information on the third option.

Creating the ≤4GiB files using dd:

dd if=/dev/null of=/mnt/myPenDrive/RAID_part_1.diskimage bs=1M count=3072
dd if=/dev/null of=/mnt/myPenDrive/RAID_part_2.diskimage bs=1M count=3072

Explanation:

  • Read 1M chunks from /dev/null, which provides an endless source of zero's.
  • Do this 3072 times.
  • Write the resulting 3TiB of zeros to a file called RAID_part_1.diskimage

Note the file can be almost any size, but since we are writing to a FAt32 filesystem they need to be smaller than 4GiB. So do not increase count to more than 4095.


Next we tell the OS that we want to see these files as a block device.

losetup /dev/loop0 /mnt/myPenDrive/RAID_part_1.diskimage
losetup /dev/loop1 /mnt/myPenDrive/RAID_part_2.diskimage

We can now access these files as a regular disk. E.g. run fdisk on then, format them in any way we want and mount the formatted volumes.

Once more: We can format this loopback device in an other format that FAT32. So the FAT32 limits no longer apply. Since or fake 'disk' is less than 4GiB the disk will still get full if we try to create a 6GiB file though. So lets expand the disk.

We can do this by concatenating multiple devices. Think of it as a paper notebook where you can glue two notebook together. The last page of the first notebook to the first page of the second notebook. Now you have turned two smaller notebooks (disk) into on large notebook.

A much more detailed and thorough description of that can be found here on our sister site.

For Linux you probably want to use mdadm.

First make sure you have mdadm available (e.g. try to run it, if not found try the relevant command of your distribution to install it. E.g. apt-get install mdadm for Ubuntu, or yum install mdadm for RedHat, or emerge mdadm for Gentoo).

mdadm --create /dev/md0 --level=linear --raid-devices=2 /dev/loop0 /dev/loop1 

You should now have a new, 6GiB block device called /dev/md0. Format and mount it as desired.

Hennes
  • 65,804
  • 7
  • 115
  • 169