Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to execute a command as if I am my normal user, but I want to have root certain permissions. In particular, I have created a phyiscal VirtualBox drive that I want to use as a normal user.

I can sudo to VirtualBox, but that gives an unconfigured VirtualBox. On the other hand, if I want to add my raw image (create by VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda as per documentation) as the drive for a virtual machine it gives me a permission error.

So basically I have this: Multiple virtual machines, all with virtual drives in vdi or vmdk images. Now I want to have another VM, but this time with a phyiscal drive and I need my normal user to have permissions to do this (possibly with entering my passwort to give it root access, my main concern is that it should execute as a specific user and not as root, although it has root permissions).

Is this at all possible? If so, how?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

So far most modern systems use udev, and changing any permissions/owners under /dev are effective until host system restart.

I suggest following actions:

  1. ls -l /dev/sda

    On my system it looks like this:

    brw-rw----   1 root   disk        8,   0 янв.  11 13:43 sda
    

    so disk group has read write access

  2. sudo gpasswd -a youruser disk

    We just added youruser to group disk

  3. Most important step: relogin youruser or reboot host system, because until then youruser disk group membership will not be effective

share|improve this answer

You have to change the permissions on /dev/sda so that the VirtualBox user can read and write to it.

from https://forums.virtualbox.org/viewtopic.php?t=333

share|improve this answer

I reckon you can probably solve this problem with file permissions rather than sudo ??

Might be worth checking that your user is in the vboxusers group:

sudo usermod -a -G vboxusers username

Failing that try changing the permissions of the file in question:

chmod 760 /path/to/file.vmdk

should create permissions like the following:

-rwxrw---- 1 user group 0 Jan 23 10:35 /path/to/file.vmdk

where rwx = read/write/execute for the user

where rw- = read/write for the group

where --- = no permissions for other users

You can run the following on the directory to ensure the user has access also:

chmod 770 /path/to/

drwxrwx--- 2 user group 4096 Jan 23 10:40 /path/to/

( more info on chmod here: http://www.computerhope.com/unix/uchmod.htm )

OR if the virtual drive is only ever going to be used by the "user" you mentioned and no other user, then you can simply chown the file to that user, giving them full access to the file when logged in as that user. (and possibly copy the file into their home directory for the sake of being tidy ? optional.)

chown username /path/to/file.vmdk

Still requires the user to have permissions to that directory in order for it to access the file.

( more info on chown here: http://www.computerhope.com/unix/uchown.htm )

share|improve this answer

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.