Convert directly from VHD/VHDX to FOG?

  • In our setup, we create images in a HyperV VM (usually using MBR but now sometimes with UEFI since tablets tend now to only support UEFI). FOG is located on that same server (as a Linux VM).

    Is there any way to directly convert the VHD/VHDX file to FOG without having to “upload” it? Or, could a method for it be created?

    We were just thinking that it, if possible, it could decrease the amount of time it takes for our images to be put into FOG. In our case, uploading doesn’t really make sense; we’re only uploading because we don’t know of any other way to get the image into FOG.

  • @loosus456 While it may be possible, I wouldn’t recommend it.

  • Moderator

    I guess I would have to ask the question to which way is faster?

    1. Just boot the vhd image into pxe boot and capture the image. Deploy and test the image.

    2. Copy the vhd image to the fog server. Mount it with qemu, convert the image to partclone format, test deploy the image.

    My guess is the copy, mount, convert steps will be much slower than the boot, capture. And there is no guaranty that the conversion will work correctly.

    With that said, it would be interesting to know if it actually worked. Especially if you had a fast linux box running with SSD drives the performance may not be too bad, but you still will be limited by the speed of the GbE network adapter for transfer rates when you use the conversion process.

  • Moderator

    @loosus456 Haven’t done this yet but there are numerous tools to read/convert/loopmount all kinds of virtual disk formats. There are ‘VBoxManage’, ‘qemu-img’, ‘vdfuse/virtualbox-fuse’ for example. Personally I’d prefer using qemu-nbd as you can mount the VHD/VHDX image as block device and let partclone read an image from there. See this example:

    # load network block device kernel module
    $ modprobe nbd max_part=16
    # connect your image as a nbd device (kind of like loop mount)
    $ qemu-nbd -c /dev/nbd0 -f VHDX <your-vhdx-image-file>
    # let the kernel find your partitions
    $ partprobe /dev/nbd0
    # check which filesystem you have on the partition(s)
    $ blkid -po udev /dev/nbd0p1 | grep FS_TYPE
    # read from first partition and write (compressed) partclone image
    $ partclone.ntfs -c -s /dev/nbd0p1 -o - | gzip -c -4 > /images/FOO/d1p1.img
    # same for the remaining partitions
    $ blkid -po udev /dev/nbd0p2 | grep FS_TYPE
    $ partclone.ntfs -c -s /dev/nbd0p2 ...

    As well you need to create a backup of the MBR (d1.mbr), the partition layout files (d1.partitions) and other info files depending on what your have on your VHD(X)! So this ist just the start. Give it a try and see how far you get. Examine the files you have in other image directories. If you need further assistance just let us know.

  • Moderator

    @loosus456 Hi, FOG use partclone to backup image, I think there is no way to convert VHD(X) to partclone image. You can check on partclone website :