Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:

http://i.imgur.com/IYVKr.png

share|improve this question
add comment

3 Answers

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
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
add comment

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
add comment

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: http://unix.stackexchange.com/a/45019/9689

share|improve this answer
add comment

Your Answer

 
discard

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.