Only Root Can Mount on Raspberry Pi

0

I am new to UNIX and I have been trying to setup Transmission on my new Raspberry Pi. I have formatted my external USB drive to ext4 and added the following line to the /etc/fstab.

/dev/sda1         /media/USB96    ext4    defaults           0       0

It works fine but when I login as pi (instead of root) it returns an error when mounting the drive

mount: only root can do that

I'm stuck here because when I try to download a torrent with the Transmission web interface it also returns an error:

Permission denied (/media/USB96/torrents/complete/my torrent link)

Please help me to solve this problem and tell me how to allow the normal user pi to mount and have access to the USB drive.

Damanjit Singh

Posted 2013-06-22T06:15:04.490

Reputation: 1

Answers

1

You should change your /etc/fstab entry to this:

/dev/sda1         /media/USB96    ext4    defaults,user           0       0

According to the fstab(5) manpage, the user option allows any user to mount the file system.

Alessandro Dotti Contra

Posted 2013-06-22T06:15:04.490

Reputation: 434

This is the "proper" way to do it. Alternatively, if the device names aren't predictable, use sudo. – BowlesCR – 2014-01-27T17:36:44.453

0

ext4 (and indeed most *nix-native filesystems) are not meant to be used on removable media for not only the reason you've found, but also because of things such as user and group IDs. Reformat the drive to something foreign, such as VFAT or NTFS.

Ignacio Vazquez-Abrams

Posted 2013-06-22T06:15:04.490

Reputation: 100 516

If i format it to NTFS and use ntfs-3g instead of ext4.. Will it auto mount on user "pi"? – Damanjit Singh – 2013-06-22T06:24:28.577

Depends on other factors. – Ignacio Vazquez-Abrams – 2013-06-22T06:25:10.367

Which factor, will you please explain? – Damanjit Singh – 2013-06-22T06:26:21.740

Whether or not you're running anything that will automount it. – Ignacio Vazquez-Abrams – 2013-06-22T06:26:51.857

If you have any good tutorial in mind on how to setup transmission with external usb, please tell me. – Damanjit Singh – 2013-06-22T06:27:20.963

Transmission doesn't get "setup" with an external USB drive. – Ignacio Vazquez-Abrams – 2013-06-22T06:27:57.130

0

The pi user shouldn't need to mount the USB drive. By adding that line to the /etc/fstab file, the USB drive will be automatically mounted when the Pi boots up.

The problem you are experiencing is with permissions. The root user is likely the owner of /mnt/USB96, unless you explicitly changed it. This means that, unless the permissions have been altered for the directory, only root can create new files/folders within. This can be verified with

$ ls -l /media/USB96

To change the owner of /media/USB96 and all of the subdirectories withen to pi so that Tranmission can write to the directory, execute the following as root with the USB drive mounted:

# chown -R pi:pi /media/USB96

Then try downloading a torrent again.

Rain

Posted 2013-06-22T06:15:04.490

Reputation: 2 238

Still not working! – Damanjit Singh – 2013-06-22T07:24:59.900

help me please! – Damanjit Singh – 2013-06-22T07:32:03.103

Sorry. I meant /media/ instead of /mnt/. Check my edit above. If you noticed this already, as pi, can you cd /media/USB96 and create a file with touch test.file? If not, what error does it throw? – Rain – 2013-06-22T07:43:37.797