Ubuntu – How to mount a drive so that it is readable by me

mountpermissionsrootsshusb

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:

/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.