I mount a USB HDD used for intermittent plugin backup via the fstab entry:
# <file system> <mount point> <type> <options> <dump> <pass> UUID=cd9f3fc4-f67f-42c4-8190-21d2766d2b65 /mnt/Bu-ehd2 ext4 rw,nosuid,noexec,nodev,noauto,nofail,relatime,user_xattr,acl,comment=x-gvfs-show 0 2
sudo umount /mnt/Bu-ehd2 works, but trying to unmount as a regular (non-root) user:
$ umount /mnt/Bu-ehd2 umount: only root can unmount UUID=cd9f3fc4-f67f-42c4-8190-21d2766d2b65 from /mnt/Bu-ehd2
Why it is so is covered by @MariusGedminas' answer on AU, but not how to circumvent the usage restriction on
userto the mount options does not help.
usersdoes help but unmounting by any user becomes possible even after mounting was done based on an
/etc/fstabentry. A possible but poor solution.
uid=1000,ownerbreaks the mount process altogether with:
Error mounting system-managed device /dev/sdc1:
Command-line `mount "/mnt/Bu-ehd2"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/sdc1,...
$ df -l | grep Bu-ehd2 /dev/sdc1 192162396 60744 182317284 1% /mnt/Bu-ehd2 $ ls -lAsF /dev/disk/by-uuid | grep sdc1 0 lrwxrwxrwx 1 root root 10 Mar 29 11:24 cd9f3fc4-f67f-42c4-8190-21d2766d2b65 -> ../../sdc1 $ stat /mnt/Bu-ehd2 | head -4 File: ‘/mnt/Bu-ehd2’ Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 821h/2081d Inode: 2 Links: 3 Access: (0770/drwxrwx---) Uid: ( 1000/someuser) Gid: ( 0/ root) $ stat /dev/sdc1 | head -4 File: ‘/dev/sdc1’ Size: 0 Blocks: 0 IO Block: 4096 block special file Device: 5h/5d Inode: 176539 Links: 1 Device type: 8,21 Access: (0660/brw-rw----) Uid: ( 0/ root) Gid: ( 6/ disk) $ blkid | grep Bu-ehd2 # yields nothing on /dev/sdc1 when actually $ #+ mounted on `/mnt/Bu-ehd2`
Q: Is unmouting as a regular user impossible due to the fact that the mounted device is owned by root ? If so, how do I make the device umountable by
someuser just by issuing cmd
umount /dev/sdc1 ? Ideally that would be by making
someuser the owner of its own external usb HDD device.
Note: I prefer not to resort to
sudo visudo in order to write a sudo-exception rule for every different user, for
umount. It would still force every
someuser to type
sudo umount /mnt/Bu-ehd2 instead of just
umount /dev/sdc1 anyway.