Boot block devices as virtual devices in Virtual Box

VBoxManage internalcommands createrawvmdk -filename [path/to/file/name.vmdk] -rawdisk /dev/[block_device]
eg: VBoxManage internalcommands createrawvmdk -filename ~/.VBox_sdc.vmdk -rawdisk /dev/sdc In order to start virtual box using block devices, ( Or to boot from it) run as ROOT sudo VirtualBox Then add & select the vmdk file as a device. At last Start the virtual box. - This cmd needs to run once for a device. - See command 8936 to run with out using ROOT power and easy handling of Virtual m/c

0
By: totti
2011-08-19 14:26:22

These Might Interest You

  • Outputs contents of virtual hosts containing PATTERN. Particularly useful for pefrorming complex searches. E.g. search for docroot of www.example.com: sed -n '/^[^#]*<Virtual/{:l N; /<\/Virtual/!bl;}; /www\.example\.com/p' /etc/apache2/sites-enabled/* |grep DocumentRoot Note that "Virtual" here is case sensitive. In GNU sed you may add I (capital i) modifier for case-insensitive matching: sed -n '/^[^#]*<Virtual/I{:l N; /<\/Virtual/I!bl;}; /PATTERN/p' ...


    1
    sed -n '/^[^#]*<Virtual/{:l N; /<\/Virtual/!bl;}; /PATTERN/p' vhosts.conf
    smax · 2011-02-10 02:25:49 0
  • Shows all block devices in a tree with descruptions of what they are.


    2
    sudo lsblk -o name,type,fstype,label,partlabel,model,mountpoint,size
    bugmenot · 2018-04-25 00:16:39 0
  • There is no output from this command. The command boots a virtual machine and you will have to wait for the boot sequence to complete before you can ping or connect to the virtual machine via ssh/rdp/vnc/nx/etc.


    0
    vmrun start /path/to/virtual_machine.vmx nogui
    linuxrawkstar · 2009-07-07 12:11:45 0
  • Usage: VBoxBlockBoot [Virtual_Machine] [Block_device] Eg: VBoxBlockBoot WinXP /dev/sdc In another words vm=usb; usb=sdc;sudo umount /dev/$usb* ; sudo chmod 777 /dev/$usb ; VBoxManage storageattach $vm --medium ~/raw-HD-4-VB/$usb.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm $vm Where vm --> Name of the virtual machine to start usb --> Block device to use. (/dev/sdc) This can used after setup up a boot loader on to my USB pen drive or HDD (After creating Live USB). Here root privilege is needed but not granted to Virtual Box. Thus we can access all our VM.( If we run VBox as root we can't access our VMs). Root privilege is used to - Unmount the storage device - Chmod to full access (777) Requirements:- 1. Device information file (rawvmdk file) created by the following command. Need to run only once. Not bad to run many. VBoxCreateRawDisk() { VBoxManage internalcommands createrawvmdk -filename ~/.rawHD4VB_`basename "$1"`.vmdk -rawdisk "$1"; } 2. Root privilege to umount & chmod 3. Real storage medium (ie /dev/*) (Non-virtual such as USB HD, pen drive, a partition) 4. A virtual m/c already available (here "usb") vm=usb; usb=sdc;sudo umount /dev/$usb* ; sudo chmod 777 /dev/$usb ; VBoxManage storageattach $vm --medium ~/raw-HD-4-VB/$usb.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm $vm VBoxBlockBoot() { sudo umount "$2"*; sudo chmod 777 "$2"; VBoxManage storageattach "$1" --medium ~/.rawHD4VB_`basename "$2"`.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm "$1"; } Show Sample Output


    0
    VBoxBlockBoot() { sudo umount "$2"*; sudo chmod 777 "$2"; VBoxManage storageattach "$1" --medium ~/.rawHD4VB_`basename "$2"`.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm "$1";}
    totti · 2011-07-29 13:04:19 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: