• Cannot create fixed-size VirtualBox disk image

    Hi all,

    I’m having trouble creating a new fixed-size VirtualBox disk image. I can create a new virtual machine just fine, but I cannot create fixed-size disk images. Dynamic disk images work just fine. However, I need a fixed-size disk because I need to mount and manipulate this disk directly from the host.

    Running the following command:

    vboxmanage createhd --filename LFS.vdi --size 20000 --variant Fixed

    gives me the following output:

    Progress state: VBOX_E_FILE_ERROR
    VBoxManage: error: Failed to create medium
    VBoxManage: error: Could not create the medium storage unit 'LFS.vdi'.
    VBoxManage: error: VHD: cannot set the file size for 'LFS.vdi' (VERR_INVALID_PARAMETER)
    VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
    VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 450 of file VBoxManageDisk.cpp

    The following applications and versions are in use:

    • virtualBox, version 5.1.8-1
    • virtualbox-guest-iso, version 5.1.8-1
    • virtualbox-host-dkms, version 5.1.8-1
    • linux, version 4.8.4-1
    • linux-api-headers, version 4.7-1
    • linux-headers, version 4.8.4-1

    All applications are up-to-date and I have rebooted the host a few times to ensure that most recent updates are in effect.

    Any and all help is welcome 😟

  • @antkes first do a normal install in a dynamic disk file, then create an .img file of a fixed size with something like

    dd if=/dev/zero of=~/theFile.img bs=1M count=10240

    but with the names and sizes you want and create a filesystem in it with something like

    mkfs.ext4 ~/theFile.img

    . Mount this file with

    sudo mount -o loop ~/theFile.img /media/mountPoint

    and copy the contents of your dynamic file into your static image, don’t forget to copy it with the right rights like with

    cp -ax /. /media/mountPoint

    then you should edit your /boot/grub/grub.cfg to boot from this .img file and create a bootable
    .iso file of your /boot/ folder and use the .iso file in virtualbox as bootdisk then place your static .img file in a the shared folder of the vm and boot

    i dont know if this works but i see no reason why it should not since virtualbox can boot from iso files and grub can work with filesystems in files,also this is more of an universal approach so it should work with any VM capable of booting from iso files and using a shared folder

  • @hm_ Thanks for your reply and the instructions. While they don’t quite solve the problem, they do give a few good ideas.

    The root cause why I need a fixed-size disk image is so that I can follow the “Linux From Scratch” -guide. The idea is to build a working Linux instance on the disk image and then use VirtualBox to boot it.

    I think I’ll give the ‘dd’ command a try. I’m not sure if VirtualBox can boot the final disk image once it’s ready, but at least I have something to keep me busy meanwhile 😄

  • @antkes that makes it easier just chroot into the mounted file and follow the linux from scratch instructions and copy it afterwards into an dynamic file so you dont need any custom iso.

virtualbox47 image18 disk15 fixed-size1 Posts 4Views 2391
Log in to reply
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.