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?
Best Answer
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:
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
or
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.