4

I am using a separate HDD as a disk for my Virtualbox machine. I have made a vmdk using the tutorial provided in the VirtualBox manual, but in order for the machine to run I have to constantly change the owner and group of the /dev/sdb device to the user I am logged in with.

Time after time permissions get reset back to root:disk, and I'm not certain when exactly that happens. What can I do to change the owner and group permanently or maybe to not have to do it at all?

2
  • Either you use the whole device ( /dev/sdb ) or you create a vmdk file, not both. If you have a vmdk file then you need permissions for that file, not /dev/sdb.
    – psusi
    Dec 14, 2012 at 15:19
  • @psusi, no, you need to create a vmdk in both cases, check out the docs I have linked to. Dec 14, 2012 at 19:02

2 Answers 2

3

The probably simplest and best way to fix the problem is adding your user to disk group.

sudo adduser %user disk

Then logoff and login back, you should able to interact with hard drive from Virtualbox.

3
  • This solution has occurred to me, but what confused me initially was the device's permissions. They are set to brw-rw---, doesn't that mean that only root can boot from this device? Dec 14, 2012 at 19:04
  • No, the second set of permissions rw- are for the group (disk). Dec 18, 2012 at 8:55
  • 1
    This is a very insecure workaround, an user with root level access to all disks is just one step away from full root power. Better see this solution.
    – Diego V
    Feb 12, 2017 at 20:17
1

This overriding behavior you see is udev daemon, the system service which maintains those device files. It acts at boot time and whenever a device is added or removed.

To configure permissions for that disk so VirtualBox users can have raw access to it, you have to create a rule for udev in a file under /etc/udev/rules.d/. In your particular case, assuming your user is part of vboxusers group, that can be accomplished with a command like this:

$ echo 'ENV{DEVNAME}=="/dev/sdb" GROUP="vboxusers"' | sudo tee /etc/udev/rules.d/92-sdb-permissions.rules

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .