2

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:

https://i.stack.imgur.com/7Yzds.png

LanceBaynes
  • 40,135
  • 97
  • 255
  • 351

3 Answers3

3

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

capdragon
  • 1,187
  • "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
  • 1
    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
3

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>
nwaltham
  • 231
  • 1
  • 2
  • 7
1

Mounting thought loopback device with offset, might be helpful.

VDIfile=VirtData.vdi
mountingpoint=/mnt/VDI
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: https://unix.stackexchange.com/a/45019/9689