midge
Posts: 1
Joined: Fri Sep 07, 2012 10:54 pm

USB Hard Drive Permissions

Fri Sep 07, 2012 11:12 pm

Has anybody got any advice on setting the permissions for an external USB HD ?

My Raspberry sees the device but I can only read from it - the OS prevents me from writing to it !

I've tried several solutions suggested by Google but to no avail.

LXDE's file manager sees the device but wont let me write to it. it never appears in etc/fstab - adding it just makes it disappear in LXDE. I've followed a tutorial adding it to Samba but that also didn't work. I've reformatted it to ext2 in parted (hoping erasing any trace of windows would help). I've tried many chown & chmod settings,from various websites, again with no luck ?

Any hints/ideas appreciated as an 8Gb SD card is a bit restrictive when I've got a 200Gb drive at the ready?

Many thanks Simon

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Sun Sep 09, 2012 7:48 pm

I'm struggling with this issue too, did you find an answer?

User avatar
Licaon_Kter
Posts: 240
Joined: Wed Sep 05, 2012 10:12 am
Location: Between the keyboard and the chair.

Re: USB Hard Drive Permissions

Mon Sep 10, 2012 9:03 am

Licaon_Kter wrote:install ntfs-3g
in fstab change ntfs to ntfs-3g
BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 7:30 am

You have to mount it as owner. What distro are you using?

In Squeeze you had to do it all manually. In Raspbian wheezy it should be taken care of automatically.

This blog post shows how to manually mount and unmount a usb hdd.http://raspi.tv/2012/how-to-mount-and-u ... spberry-pi

I had the exact same issue before I found out how to mount the drive as owner.
If you are logged on as the default Raspberry Pi Debian user, pi, you will need to use this command to mount the drive with read/write permission.

Code: Select all

sudo mount  -o uid=pi,gid=pi /dev/sda1 /media/usbdrive/
having first created /media/usbdrive directory and set the permission on it.
Alex Eames RasPi.TV, RasP.iO

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 12:43 pm

alexeames wrote:This blog post shows how to manually mount and unmount a usb hdd.http://raspi.tv/2012/how-to-mount-and-u ... spberry-pi
Thanks very much for this blog post by the way, I found it via a Google search and it taught me how to access my external drive. The only thing missing however was the requirement to install ntfs-3g using "sudo apt-get install ntfs-3g".

Quick question, and sorry to hijack the thread but it is related, your blog post advises to create a directory in /media/USBHDD, however other instructions I've found advise /mnt/USBHDD. What's the difference?

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 12:44 pm

Licaon_Kter wrote:install ntfs-3g
in fstab change ntfs to ntfs-3g
I've got to thank you for this tip too!

itimpi
Posts: 1090
Joined: Sun Sep 25, 2011 11:44 am
Location: Potters Bar, United Kingdom
Contact: Website

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 1:48 pm

bigdavethehorn wrote:
alexeames wrote: Quick question, and sorry to hijack the thread but it is related, your blog post advises to create a directory in /media/USBHDD, however other instructions I've found advise /mnt/USBHDD. What's the difference?
This is down to personal preference as to where devices should be mounted, so go with whatever you find most intuitive (if Linux can ever be called that :D )

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 1:57 pm

itimpi wrote:This is down to personal preference as to where devices should be mounted, so go with whatever you find most intuitive (if Linux can ever be called that :D )
Thanks, coming from a plug n play Windows background, Linux is certainly not intuitive yet! I still have to learn how to permanantly, or automatically mount my external HDD and safely unmount it (or is it demount?).

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 7:19 pm

Exactly - it's down to personal preference. :) I think you can mount a drive pretty much anywhere you want as long as you have permissions in that location (and it exists).

I believe you can generally omit the -t ntfs-3g altogether in the manual mount - not sure about fstab. I hadn't come across the need to install ntfs-3g. I wonder if that's a Raspbian issue? The blog post was written for squeeze, but works in wheezy beta too. Not tried it in Raspbian as everything seems to mount automatically for me. :lol:

If you type

Code: Select all

df -h
after attaching a drive you should be able to see where it's been mounted.
My USB HDD auto-mounts at /media/label, where label is the name of the drive. I'm puzzled why yours is not auto mounting correctly. Are you using a username you created or the pi account?
Alex Eames RasPi.TV, RasP.iO

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Wed Sep 12, 2012 7:49 pm

bigdavethehorn wrote: I still have to learn how to permanantly, or automatically mount my external HDD and safely unmount it (or is it demount?).
unmounting manually is fairly easy...

if your drive is mounted at /media/USBHDD

Code: Select all

sudo umount /media/USBHDD
note it is umount, not uNmount. But you can't do it if the current directory is at or below USBHDD. You can do it from /media or somewhere else in your file system.
Alex Eames RasPi.TV, RasP.iO

startreksteve
Posts: 44
Joined: Tue Mar 13, 2012 10:23 am

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 7:35 am

I just do it in roots crontab

sudo crontab -e

@reboot /usr/bin/mount -o uid=pi,gid=pi /dev/sda1 /media/usbdrive/

a bit easier than fiddling with fstab

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 7:56 am

Interstingly enough, last night I reformatted a 500G USBHDD to Ext4, which massively speeds up the performance on a Pi. I encountered the same issue you guys have had with the permissions.

I could read from it but not write to it with the pi ID.

After much piddling about reading up on ext4 and fstab, I managed to get read-write access through pi
by doing a

Code: Select all

sudo chown pi:pi /media/usbhdd
sudo chmod 777 /media/usbhdd
and now pi has ownership and all users should have full r/w/x permissions

This might not be the safest way to go, but it got the job done. :lol:

I also added this line to fstab, but it seems to work even after rebooting with it commented out, so not sure it's needed. Except that if commented out, the drive is auto mounted at usbhdd_ instead of usbhdd

Code: Select all

/dev/sda1      /media/usbhdd    ext4    rw,suid,dev,exec,auto,user,async          0       0
Alex Eames RasPi.TV, RasP.iO

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 9:58 am

alexeames wrote:Interstingly enough, last night I reformatted a 500G USBHDD to Ext4, which massively speeds up the performance on a Pi.
Got any figures?

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 10:38 am

bigdavethehorn wrote:
alexeames wrote:Interstingly enough, last night I reformatted a 500G USBHDD to Ext4, which massively speeds up the performance on a Pi.
Got any figures?
I wrote a whole post about it here. Will probably blog it at some point. But basically I get about 8.3 megs/s copying a large file from my NAS to my USBHDD and 6.75 megs/s from USBHDD to NAS.

On NTFS (with the exact same drive but through sftp) I was getting something of the order of 2 megs/s. It's a massive improvement. The Pi's ethernet port is theoretically capable of 12.5 megs/s but we're getting closer. In the thread linked above, using a cut down kernel is said to improve things further, but since I already have a NAS, I don't really need that. All I wanted was a nice big HDD accessible from anywhere - personal cloud - if you like. :lol:
Alex Eames RasPi.TV, RasP.iO

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 11:32 am

Thanks for pointing me toward your other thread, off for a read now.

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 11:38 am

startreksteve wrote:I just do it in roots crontab

sudo crontab -e

@reboot /usr/bin/mount -o uid=pi,gid=pi /dev/sda1 /media/usbdrive/

a bit easier than fiddling with fstab
To my non-linux eyes, that looks like a script to enable auto mount at boot. Is that correct?

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 12:12 pm

bigdavethehorn wrote:
startreksteve wrote:I just do it in roots crontab

sudo crontab -e

@reboot /usr/bin/mount -o uid=pi,gid=pi /dev/sda1 /media/usbdrive/

a bit easier than fiddling with fstab
To my non-linux eyes, that looks like a script to enable auto mount at boot. Is that correct?
kind of. crontab is a way of running scripts or commands at specific times/events e.g. reboot
for example a lot of web servers will use crontab to run their nightly backups at a specific time
Alex Eames RasPi.TV, RasP.iO

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 12:20 pm

Sounds ideal for my purposes, shut down Pi and unplug HDD. Plug HDD into laptop and transfer data, plug HDD back into Pi and restart Pi.

No more faffing with mnt commands or fstabs!

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 2:15 pm

bigdavethehorn wrote:Sounds ideal for my purposes, shut down Pi and unplug HDD. Plug HDD into laptop and transfer data, plug HDD back into Pi and restart Pi.

No more faffing with mnt commands or fstabs!
If your laptop is windows, you might be better off not doing the ext4 thing, as I think ext4 can't be read by windows.
Alex Eames RasPi.TV, RasP.iO

The_Pixie
Posts: 11
Joined: Tue May 22, 2012 10:21 am
Location: Welbeck

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 2:17 pm

I'd like to say, that I too am having an issue.
I tried the /mount -o pid=pi,gid=pi etc...
Didnt work :(
Any ideas?

User avatar
Licaon_Kter
Posts: 240
Joined: Wed Sep 05, 2012 10:12 am
Location: Between the keyboard and the chair.

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 3:22 pm

lsusb ?
installed ntfs-3g already if NTFS?
BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Thu Sep 13, 2012 3:49 pm

alexeames wrote:If your laptop is windows, you might be better off not doing the ext4 thing, as I think ext4 can't be read by windows.
A good point. I'll leave the HDD as NTFS for easy reading in Windows.

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Fri Sep 14, 2012 7:07 am

alexeames wrote:My USB HDD auto-mounts at /media/label, where label is the name of the drive. I'm puzzled why yours is not auto mounting correctly. Are you using a username you created or the pi account?
I'm using the default Pi account on a very much untouched Wheezy install. My HDD auto-mounts at boot, however I don't have write access to it.

My solution at the moment is to VNC into the Pi, unmount the HDD, then re-mount it from terminal using the info from your blog "sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/usbdrive/"

There has to be an easier way!

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: USB Hard Drive Permissions

Fri Sep 14, 2012 8:11 am

bigdavethehorn wrote:
alexeames wrote:My USB HDD auto-mounts at /media/label, where label is the name of the drive. I'm puzzled why yours is not auto mounting correctly. Are you using a username you created or the pi account?
I'm using the default Pi account on a very much untouched Wheezy install. My HDD auto-mounts at boot, however I don't have write access to it.

My solution at the moment is to VNC into the Pi, unmount the HDD, then re-mount it from terminal using the info from your blog "sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/usbdrive/"

There has to be an easier way!
It's probably mounting as root. Do you get r/w if you put sudo in front of your cp, mv etc. commands?

There is a way to make it mount as pi using fstab. Unfortunately I'm not very versed in fstab.

You could put your umount and mount commands in a little file, make it executable (chmod +x filename) and run it as a script, to shorten the process, but fstab is probably the best permanent way to go, to be honest. Did you see this post yesterday? http://www.raspberrypi.org/phpBB3/viewt ... 95#p172395

It might help you a bit (or a lot). :D
Alex Eames RasPi.TV, RasP.iO

User avatar
bigdavethehorn
Posts: 56
Joined: Thu Jan 19, 2012 8:46 pm
Location: Scotland

Re: USB Hard Drive Permissions

Fri Sep 14, 2012 11:24 am

alexeames wrote:It's probably mounting as root. Do you get r/w if you put sudo in front of your cp, mv etc. commands?
I haven't tried creating, moving or deleting files via the terminal, a simple right-click "create folder" was my r/w test!
alexeames wrote:Did you see this post yesterday? http://www.raspberrypi.org/phpBB3/viewt ... 95#p172395
Yes I did thanks, however I need to get a better understanding about manual mounting, auto mounting by Wheezy and the role of the fstab.

For example, if I run a "sudo mount..." crontab script at boot, will this script be superseded, and the drive unmounted, when Wheezy boots to the desktop?

Return to “Beginners”