Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to have a file on a VirtualBox guest's HDD. What are the solutions for this? How can I put a file on a Virtualbox guest's HDD?

Version: virtualbox-4.1 4.1.8-75467~Ubuntu~lucid

I mean I need a solution that doesn't require to have a VirtualBox guest (when putting the file to a vbox hdd). I just need to prepare Vbox disks that contain the given files for later use.

UPDATE: or it would be enough to create a vbox hdd from a physical disk! But If I:

VBoxManage internalcommands createrawvmdk -filename /home/USERNAME/Desktop/vboxhdd.vmdk -rawdisk /dev/sdb1

I get this error message after I configure a vbox guest to use the newly created disk:


share|improve this question

I'm guessing the VBoxManager account does not have access to /home/USERNAME/Des... Try creating it in another location.

share|improve this answer
"chmod 777 /dev/sdb1" solved it – LanceBaynes Jan 20 '12 at 19:36
but I can't see the physical disk, I mean the partition of my flashdrive in the host machine. – LanceBaynes Jan 20 '12 at 19:57
So you would like your guest machine to view a partition on your host machine? If so, you're going to need to configure "Shared Folders" in the VBox Manager for the particular guest. I much prefer just mounting a network drive on the guest's sftab to a location both machines have access to. But i don't know what you're end goal is. – capdragon Jan 20 '12 at 20:20

I would create a loopback device on a raw image

dd if=/dev/zero of=imagefile bs=1 count=1 seek=40G
mkfs -t ext3 imagefile
mount -t ext3 imagefile -o loopback /mnt/someplace

and then unmount and convert to a Vbox VDI afterwards

VBoxManage convertdd <filename> <outputfile>
share|improve this answer
I will try this one out!, ty! – LanceBaynes Jan 23 '12 at 5:31

Mounting thought loopback device with offset, might be helpful.

offData=$( VBoxManage internalcommands dumphdinfo "$VDIfile" |grep offData | sed 's:.*offData=\([0-9]*\).*:\1:' )
offset=$(( $offData + 32256 ))
mount -t ext4 -o rw,noatime,noexec,loop,offset="$offset" "$VDIfile" "$mountingpoint"

More details here: http://unix.stackexchange.com/a/45019/9689

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.