How to ‘Fix’ Auto-Mounted Drives with ‘Wrong’ Permissions

  • Posted on: 30 July 2020
  • By: Michael

Those new to Linux hit this quickly.

I can mount the drive, but permissions show the owner as 'Root'. I can not add or delete anything!

They stick a USB Flash Drive or external Hard Drive into their system and the system automagically added the drive for them. Usually popping up the drive in their default file manager. Then they can’t use the drive at all. Thanks auto-mounter! It doesn’t happen always, but frequently enough that one has to wonder why there are still bugs in ~20+ year old software.

These are the generalized command line instructions on how to ‘fix’ auto-mounted drives. Basically these same commands will work to ‘fix’ a manually mounted drive with ‘wrong’ permissions as well.

First mount the drive however you’re going to routinely do it. Then follow the bouncing ball...

Root, while dangerous, is your friend in situations like this.

michael@local [~]# su -
Password:
root@local [~]#     
root@local [~]# alias ll='ls -al --color=always'

If you really don’t like being root, just add sudo to everything, and continue...

I use the above alias extensively, so make sure you set it or you're going to hit "-bash: ll: command not found" a lot. You can also use 'ls -al --color=always' everywhere I've used 'll'.

root@local [~]# df
Filesystem            1K-blocks       Used  Available Use% Mounted on
{snip}
/dev/sdc1    5813266544 4267002176 1253221960  78% /media/michael/new hard drive
{snip}

Note whatever corresponds to the device "/dev/sdc1" and mount point "/media/michael/new hard drive" on your system.

Now lets find out if your media directory is owned by yourself. Replace my username (michael) with your username in everything below.

root@local [~]# ll /media
total 12
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 .
drwxr-xr-x  18 root    root    4096 Jul 26 21:25 ..
drwxr-x---+  4 root    root    4096 Jul 28 13:27 michael

No? Then
{Skip to the next step if you own you.}

root@local [~]# cd /media
root@local [/media]# chown michael:michael michael                                
root@local [/media]# ll
total 12
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 .
drwxr-xr-x  18 root    root    4096 Jul 26 21:25 ..
drwxr-x---+  4 michael michael 4096 Jul 28 13:27 michael

Okay now we own our media area, now check if we own the mount point:

root@local [/media]# cd michael/
root@local [/media/michael]# ll
total 16
drwxr-x---+  4 michael michael 4096 Jul 28 13:27 .
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 ..
drwxr-xr-x  10 root    root    4096 Jul 15 13:14 'new hard drive'

Stupid auto-mounter! To fix that we need to get the drive out of the way so we can ‘fix’ its mount point. Use your device name that corresponded to "/dev/sdc1" we noted earlier.

root@local [/media/michael]# umount /dev/sdc1

You should see the drive icon on your desktop somewhere, right click on it and select your distributions version of “Safely remove.” Then, if it’s a USB plug in, unplug the flash drive or USB cable.

root@local [/media/michael]# ll
total 16
drwxr-x---+  4 michael michael 4096 Jul 28 13:27 .
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 ..

Good auto-mounter cleaned up after itself. If it didn’t you’ll continue to see the 'new hard drive' directory, in that case skip the first step (‘mkdir’) in the next section.

root@local [/media/michael]# mkdir "new hard drive"
root@local [/media/michael]# chown michael:michael "new hard drive"
root@local [/media/michael]# ll
total 16
drwxr-x---+  4 michael michael 4096 Jul 28 13:27 .
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 ..
drwxr-xr-x  10 michael michael 4096 Jul 15 13:14 'new hard drive'

Okay, we now own the mount point, no backsies for you auto-mounter. Now re-mount the drive however you mounted it the first time.

root@local [/media/michael]# ll
total 16
drwxr-x---+  4 michael michael 4096 Jul 28 13:27 .
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 ..
drwxr-xr-x  10 michael michael 4096 Jul 15 13:14 'new hard drive'

Did it stick? e.g. Do you own the 'new hard drive' directory?

Yes! Yeah, done!

Nope? What a finicky beast Linux is (okay that was the auto-mounter’s fault too), redo the last chown...

root@local [/media/michael]# chown michael:michael "new hard drive"
root@local [/media/michael]# ll
total 16
drwxr-x---+  4 michael michael 4096 Jul 28 13:27 .
drwxr-xr-x   3 root    root    4096 Jul 26 21:45 ..
drwxr-xr-x  10 michael michael 4096 Jul 15 13:14 'new hard drive'

And we’re finished and you can use the drive.

Best,
Michael

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
You know what to do... (an image you see? there is one finger less than two hands of items to find.)
Image CAPTCHA
Enter the characters shown in the image.