fstab line for auto mount drive that all users can read/write
What can I use in my /etc/fstab file that will allow drives to be mounted and unmounted by all users on the system? (both reading and writing)
If it's a personal computer, it would be best to use something like udisks
(which GNOME uses for (auto-)mounting devices), as in udisks --mount /dev/sdc1
.
Another alternative is pmount
.
But if you require it to work with the mount
utility, and if you can guarantee that the device node will never change, this should work:
/dev/sdc1 /archive auto users,uid=0,gid=0,fmask=0111,dmask=0,file_umask=0111,dir_umask=0,utf8 0 0
fmask
/dmask
are for msdos
/vfat
filesystems, file_umask
/dir_umask
are for hfs
. In both cases, all files have permissions 0666 and directories 0777.
Edit: This could help. Run through sudo
.
#!/usr/bin/env bash
device=/dev/sdc1
mountpoint=/archive
# You can also use "uid=$SUDO_UID,gid=$SUDO_GID"
options="users,uid=0,gid=0,utf8"
# sets TYPE to the detected type; also UUID, LABEL where supported by filesys.
. <(blkid -c /dev/null -o export "$device")
case $TYPE in
vfat) options="$options,fmask=0111,dmask=0" ;;
hfs) options="$options,file_umask=0111,dir_umask=0" ;;
esac
mount -t "$TYPE" -o "$options" "$device" "$mountpoint"
Related videos on Youtube
evilblender
in charge of all computer systems in a very active video post production facility
Updated on September 17, 2022Comments
-
evilblender over 1 year
I have installed a cable that connects from the CPU's SATA motherboard connection to a removable drives' ESATA connection.
I would like to be able to swap drives on the ESATA connection and have all users be able to read and write to these drives.
I have created the directory
/archive/
where I would like the drive(s) to mount.The drives are all formatted Fat 32 - but in the future I may use HFS for formatting.
When I used the command (as root):
mount /dev/sdc1 /archive
the drive was mounted (but read only)
What can I use in my
/etc/fstab
file that will allow drives to be mounted and unmounted by all users on the system? (both reading and writing)Also, will I be able to mount and unmount these drives without shutting down? or will I need to reboot every time I want to change drives?
-
Tog over 13 yearsIf you don't want to manually edit anything, there are utilities that can be installed using either Ubuntu's built-in software centre or the package manager that will allow you to configure drives to automount and set the permissions for read/write and mount/unmount. I can't look up any disk managers for you atm 'cause I don't have an Ubuntu box handy so I won't post this as an answer.
-
Jasen over 13 yearsplease, inform us of which distro you are using.
-
evilblender over 13 yearsThis is a RedHat system. "cat /etc/redhat-release Red Hat Enterprise Linux WS release 4 (Nahant Update 3)"
-
-
user1686 over 13 years1. An answer that just links elsewhere is not a real answer. 2. The "no user can log in as root" statement is a) not related to the question, b) only true for standard Ubuntu Linux setups and not to any other distribution. 3. Regarding "the su command is necessary" - if you cannot login as root, you cannot
su
to root either. (You cansudo -s
on Ubuntu, however.) -
Jasen over 13 years@Tog alright. i shall remove my comments.
-
evilblender over 13 yearsThis is extraordinarily helpful thank you! I used the line you gave, and I am getting an odd error message. when I then 'mount -a' I'm told that "mount: you must specify the filesystem type" I don't know if this matters - but this is a Red Hat system, and not running GNOME.
-
user1686 over 13 years@evilblender: Try replacing
auto
in the third field withvfat
orhfs
, depending on what you are using. (I suggest using something more reliable than that, however. Bothext4
andntfs-3g
have journalling and even supportchown
+chmod
.) -
evilblender over 13 yearsUnfortunately the archive drives have previously been formatted both vfat as well as hfs. Does this kind of screw me? Thanks again. Jeff
-
user1686 over 13 years@evilblender: Take a look at
udisks
andpmount
, then? (sudo
can be useful too, possibly with a script that detects the filesystem withblkid
before giving it tomount
- without a fstab entry.) -
user1686 over 13 years@evilblender: also, fwiw,
udisks
does not depend on GNOME; it should work irrespective of type or existence of desktop environment. -
evilblender over 13 years@grawity thank you very much, I will look at them ASAP