Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 3031  / 3 Years ago, mon, may 3, 2021, 4:50:38

I'm working with over SSH with an external hard drive connected by USB.



I know I can manually mount a drive with the following command:




sudo mount /dev/sdc ~/dirToMountTo




The problem is, if I don't do it as root, then it says "mount:only root can do that".



If I do it as root, though, I can't access, read, or write files as a regular user. Only root has permissions to do anything in the directory.



How do I mount it so that I can work within it without being root?


More From » usb

 Answers
7

If you do this often, you may add a line to your /etc/fstab which will tell that the partition can be mounted by a non-root user. Something like this:



/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0


here, the 'user' option does what you need. See 'The non-superuser mounts' in mount's manfile.



The 'noauto' option tells the boot scripts not to attempt to mount the filesystem on boot (see the documentation for -a switch for mount command). Instead, you will be able to mount it explicitly by issuing



mount /dev/fd0


or



mount /media/floppy0


Also, the user who mounted the filesystem should be able to unmount it too.



For a one-off mount you need to specify uid=value or gid=value to make all the files on the mounted filesystem to be owned by that user. See "Mount options for fat" in mount's manfile.


[#43922] Tuesday, May 4, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
musining

Total Points: 171
Total Questions: 124
Total Answers: 121

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;