I need to find out how to set the permissions of a USB flash drive at the device (not filesystem) level. In other words, I need to grant the user read/write access to a USB device identified by
diskutil which is
/dev/diskX where X is some integer.
For example, I insert a USB flash drive and according to
diskutil it's identifier is
/dev/disk5. If I check the permissions of it:
$ ls /dev/disk5* brw-r----- 1 root operator 1, 15 May 15 08:35 /dev/disk5 brw-r----- 1 root operator 1, 16 May 15 08:35 /dev/disk5s1 brw-r----- 1 root operator 1, 17 May 15 08:35 /dev/disk5s2
root:operator ownership and
rw access limited to root and
r access to
operators only (this is why you must issue commands that modify the device as
What I need to do is give
rw access to the operator as well and it's not as simple as just
chmod 660 /dev/disk5. The moment you unplug the device and plug it back in, it loses the permissions.
Why do I need to do this?
I need to boot a USB flash drive in VirtualBox. To do so, I need to be able to create a "raw" disk image as a passthrough to the actual USB device. The problem is, to do this, I must issue the command via
sudo which then changes the user I am executing
VBoxManage which causes a number of errors since
root has an environment completely different than the logged in user.
This can be accomplished in FreeBSD (I am sure Linux as well via a different method) by modifying the
devfs.rules file and adding in a line like:
add path 'da*' mode 0660 group operator
Which essentially gives
rw access to any USB storage device (USB storage is identified by FreeBSD as
How do I do this on macOS?