Results 1 to 8 of 8

Thread: trying to mount/use linked usb drive in VirtualBox

  1. #1
    Join Date
    Sep 2012
    Location
    Maryland, US
    Posts
    623

    Default trying to mount/use linked usb drive in VirtualBox

    I wonder if someone could help me out with setting up virtualbox to boot from a usb drive instead of .iso file.
    There is a usb /dev/sxx permissions problem I am unable to overcome in order to get virtualbox to boot from usb.

    I am following this guide http://www.metashock.de/2012/11/boot...-a-linux-host/

    In step 5a the author starts virtualbox as root but I do not want to do that. I have already changed the permissions of the my_usb_stick.vmdk file as created in the tutorial but virtualbox still complains that I have no access to the file.

    Is there any way to mount /dev/sdd as normal user or otherwise make the created file/hdd my_usb_stick.vmdk to be opened by virtualbox as my normal user.
    Kernel: 4.12.14-lp150.12.7-default x86_64 bits:
    64 Desktop: Gnome 3.26.2
    Distro: openSUSE Leap 15.0

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: trying to mount/use linked usb drive in VirtualBox

    That article is over a year old, and technology does fly in that amount of time.
    Additionally, I'm amused that article describes creating a vmdk(VMware disk) formatted disk. Should work, I think it's something interesting that may provide some insight into the author's background and/or unstated objectives.

    Since I don't know what is on your USB disk or whether you intend to use it like a LiveCD (maybe that's where your original image came from?), I'm covering several bases in the following...

    Although I haven't done the following, I'm pretty sure it should work and I would guess should be simpler.
    1. Try to boot directly from unmodified media. This would require mounting your USB to look like one of the following accepted VBox boot devices and configuring that boot device in the Guest Settings.

    From the Virtualbox Help
    Boot order
    This setting determines the order in which the guest operating system will attempt to boot from the various virtual boot devices. Analogous to a real PC's BIOS setting, VirtualBox can tell a guest OS to start from the virtual floppy, the virtual CD/DVD drive, the virtual hard drive (each of these as defined by the other VM settings), the network, or none of these.
    If you select "Network", the VM will attempt to boot from a network via the PXE mechanism. This needs to be configured in detail on the command line; please see Section 8.8, “VBoxManage modifyvm”.
    2. If you intend to run as a LiveCD, then make an ISO file (one of the acceptable boot device types described in the Help) and point your Guest to it. Remember in the Guest Settings > Storage > CDROM to check the "LiveCD" box

    3. if you want to create a Guest with a writable image (unlike a LiveCD), then <one> of the options is more or less as described in your reference... Create an empty virtual disk file (format of your choosing), mount it and dd your bootable image into the virgin disk file.

    4. Depending on your situation, you may find that this whole process of using pre-built bootable images is a whole lot of trouble. Just do a regular VM Install pointing to creating a disk file on your USB stick (or whatever media). The only requirement here of course is that the storage media is mountable on the Host. If it can be mounted on the Host, then it can be seen by the Guest.

    5. Although I haven't investigated in Virtualbox, access to a raw file system (not a virtual disk file) is possible in every other virtualization technology I've dealt with so I assume should be possible in VBox as well. The reason why this is not generally exposed or recommended is because it bypasses file locks and checks in an OS so it then is easily possible to corrupt the system (any OS using those files).

    HTH,
    TSU

  3. #3
    Join Date
    Sep 2012
    Location
    Maryland, US
    Posts
    623

    Default Re: trying to mount/use linked usb drive in VirtualBox

    Hello tsu2 and thanks for the reply

    Somehow without answering my direct question (did I have one??) you have managed to enlighten me beyond my first aspirations, thank you.
    I will consider your suggestions and take appropriate action.
    Kernel: 4.12.14-lp150.12.7-default x86_64 bits:
    64 Desktop: Gnome 3.26.2
    Distro: openSUSE Leap 15.0

  4. #4
    Join Date
    Sep 2012
    Location
    Maryland, US
    Posts
    623

    Default Re: trying to mount/use linked usb drive in VirtualBox

    After rethinking my approach from the suggestions above I decided to make an iso from my bootable usb stick and all went smoothly.

    I guess there is a combination of command line programs to do this and wish I did know them as it would be easier but I found this program and it worked good.

    To convert a bootable usb thumb drive to an iso file that can be used by Virtualbox to boot an OS.
    http://software.opensuse.org/package/acetoneiso2

    I am not sure about some aspects of this program, there was a web page advertisement type thing that opened up when I clicked the "update" tab..... Hmmmm, it is gone now but hmmmm? Wait yes, it appears to be a complete advertising bot of some sort.

    Well I wonder what my poor iso bootable file has in it from this program

    Anyway, problem solved thanks.
    Kernel: 4.12.14-lp150.12.7-default x86_64 bits:
    64 Desktop: Gnome 3.26.2
    Distro: openSUSE Leap 15.0

  5. #5

    Default Re: trying to mount/use linked usb drive in VirtualBox

    Hi,

    @tsu2: you wrote:

    Quote Originally Posted by tsu2 View Post
    That article is over a year old, and technology does fly in that amount of time.
    Additionally, I'm amused that article describes creating a vmdk(VMware disk) formatted disk. Should work, I think it's something interesting that may provide some insight into the author's background and/or unstated objectives.
    I'm the author of that article. My intention was to test the boot process of a Linux from Scratch USB stick. I don't wanted to boot a live system. I've installed the OS manually on a stick like on a regular hard drive. (Meaning changes will persist on stick across reboots).

    Unfortunately VirtualBox supports direct host disk access for the vdmk format only. You can basically follow this guide from their documentation: http://www.virtualbox.org/manual/ch09.html#rawdisk (Chapter 9.9.1.1. Access to entire physical hard disk). This was tricky to find out that time but helped me a lot. That's why I wrote the article.

    Reading the article again, I see that requiring root permissions to run the solution looks a bit ugly. I'll review this and hope that I can show a better way then. If so, I'll update the article and drop a message here as well.

  6. #6
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: trying to mount/use linked usb drive in VirtualBox

    Quote Originally Posted by hek2mgl View Post
    Hi,

    @tsu2: you wrote:



    I'm the author of that article. My intention was to test the boot process of a Linux from Scratch USB stick. I don't wanted to boot a live system. I've installed the OS manually on a stick like on a regular hard drive. (Meaning changes will persist on stick across reboots).

    Unfortunately VirtualBox supports direct host disk access for the vdmk format only. You can basically follow this guide from their documentation: http://www.virtualbox.org/manual/ch09.html#rawdisk (Chapter 9.9.1.1. Access to entire physical hard disk). This was tricky to find out that time but helped me a lot. That's why I wrote the article.

    Reading the article again, I see that requiring root permissions to run the solution looks a bit ugly. I'll review this and hope that I can show a better way then. If so, I'll update the article and drop a message here as well.
    Cool,
    Thx for contributing (and finding this thread).

    I find it extremely surprising that VirtualBox should support <only> a rival's disk format and not all VB-supported disk formats (although anything's possible). In fact, after reading your reference, without actual testing I still strongly suspect that the author of your reference likely just chose the .vmdk disk format just to simplify the documentation (choose any that is sufficient, it likely doesn't matter. The danger is to choose something that's not supported)

    Also, it's good that you've reviewed what you wrote and consider the information still valid.

    TSU

  7. #7

    Default Re: trying to mount/use linked usb drive in VirtualBox

    Quote Originally Posted by hek2mgl View Post
    Hi,

    @tsu2: you wrote:



    I'm the author of that article. My intention was to test the boot process of a Linux from Scratch USB stick. I don't wanted to boot a live system. I've installed the OS manually on a stick like on a regular hard drive. (Meaning changes will persist on stick across reboots).

    Unfortunately VirtualBox supports direct host disk access for the vdmk format only. You can basically follow this guide from their documentation: http://www.virtualbox.org/manual/ch09.html#rawdisk (Chapter 9.9.1.1. Access to entire physical hard disk). This was tricky to find out that time but helped me a lot. That's why I wrote the article.

    Reading the article again, I see that requiring root permissions to run the solution looks a bit ugly. I'll review this and hope that I can show a better way then. If so, I'll update the article and drop a message here as well.
    You can avoid running VirtualBox as root if you're just after about the rawdisk access by adding your self to the group disk. First check out the permissions on the device.

    Code:
    ls -l /dev/sd[a-z]
    and

    Code:
    stat -c '%G' /dev/sd[a-z]
    You will see that the owner is root but the group is disk, now add yourself to the group disk by using yast2 users or

    Code:
    gpasswd -a foo vboxusers
    Where foo is the username. You will need to log-out for that to take effect, after that you can run VBoxManage to create your rawdisk. Just keep in mind your user is part of the group disk now, because adding a user to that group might give some surprises even for the most experienced sysadmins .
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  8. #8

    Default Re: trying to mount/use linked usb drive in VirtualBox

    Quote Originally Posted by jetchisel View Post

    Code:
    gpasswd -a foo vboxusers
    My bad, what you want to do is add the user to the group disk and not vboxusers

    Code:
    gpasswd -a foo disk
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •