3

I am trying to mount a USB HDD. A create a folder here:

/media/pi/HDD

My HDD is formated to ext2

After that, I modified my /etc/fstab and add this line:

/dev/sda1       /media/pi/HDD   ext2    rw,defaults,user     0       0

Then reboot, and I can see, the mounted HDD, but the owner and the group is root.

Thus, any app can't write this folder. For example, Chromium cannot download anything to this folder, and I also can't use transmission to download in this folder neither.

If i check the /media folder belongs to pi:pi

My question is, how can I mount this HDD as pi user on boot?

2
  • Please run lsblk --fs from the command line, and include the output of that command in your question.
    – Seamus
    May 30, 2018 at 23:42
  • 1
    Check permissions on /media/pi/HDD (where you presumably want to write), not on /media. Sep 14, 2020 at 13:13

3 Answers 3

2

Since you already have user in the options of your fstab, I'd suggest you try to run sudo chown -R pi:pi /media/pi/HDD once it is mounted. This applies the owner recursively to all files and directories of the drive.

I'm not sure if this is appropriate if you have some user rights management going on on the drive though.

0

When you have unplugged the HDD, run chown pi:pi on the actual mount pount not just the parent folder, so in your case /media/pi/HDD.

In Linux a subfolder or a file can have totally different file access flags than its parent folder.

2
  • hello, if i unplug the HDD and run sudo chown pi:pi /media/pi/HDD nothing happens. And afther check who is the owner of the folder i can see it's pi. But if i replug the hdd the system mount it to media but with this name: 2c9227b9-1f54-4971-bae2-f8bfaa16ae8b at this state i can write.. Then i restart and fstab mount the device again o /media/pi/HDD and this 2c9227b9-1f54-4971-bae2-f8bfaa16ae8b drive not shown anymore and canno write he mounted folder again.. :( what shold i do ?
    – solarenqu
    Oct 20, 2017 at 16:05
  • Are you sure, your device name is sda1? To check this, plug in your HDD and run df -h
    – nee6AGag
    Oct 21, 2017 at 16:31
0

Better than use 'sda1' is to know the UUID with this command:

sudo blkid /dev/sda1

Using this number go and edit 'fstab' file:

UUID=whathever_you_obtain_from_blkid /media/pi/HDD  ext2  defaults,user  0  0

And give permission to everybody (777) to try, after that you can search to fine tune permission to HDD folder:

sudo chmod 777 /media/pi/HDD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.