Automounted External Drive Owned By Root

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
tinker123
Level 4
Level 4
Posts: 234
Joined: Sun Jan 20, 2013 9:17 pm

Automounted External Drive Owned By Root

Post by tinker123 »

I have an external, USB, SSD hard drive in the EXT4 file system.

When I plug it into my computer Mint has it as owned by root.

How do I get Mint/Cinnamon to automount USB drives with myself as the owner?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Mint 21.2 Victoria
Cinnamon 5.8
Intel© Core™ i7-8700K CPU @ 3.70GHz × 6
Graphics Card: NVIDIA Corporation GP107 [GeForce GTX 1050]
Mother board: ASUSTeK COMPUTER INC. PRIME Z370-P Rev X.0x
mikeflan
Level 17
Level 17
Posts: 7136
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Automounted External Drive Owned By Root

Post by mikeflan »

Hi Tinker.
The person who answers this (probably not me) will want the output of each of these commands:

Code: Select all

blkid
df -Th
cat /etc/fstab
Plug in the drive before running those commands.

Also run this command to backup fstab. There will be no response if it works.

Code: Select all

sudo cp /etc/fstab /etc/fstab.bak
tinker123
Level 4
Level 4
Posts: 234
Joined: Sun Jan 20, 2013 9:17 pm

Re: Automounted External Drive Owned By Root

Post by tinker123 »

mikeflan wrote: Wed Mar 10, 2021 4:37 pm Hi Tinker.
The person who answers this (probably not me) will want the output of each of these commands:

Code: Select all

blkid
df -Th
cat /etc/fstab
Fair enough!


The last line is odd as I formatted the drive ( via the file manager ) this morning to be ext4 and changed the label to something else.

Code: Select all

Mint20UlyanaCinnamon4.6.7> blkid
/dev/sda1: UUID="5FkZP2-Ktpo-UBJ6-xjpo-vIBW-kl5E-5pBcKr" TYPE="LVM2_member" PARTUUID="7c398459-01"
/dev/mapper/mint--vg-root: UUID="2b8f311f-04ff-4a08-a236-7804a18ad5cb" TYPE="ext4"
/dev/mapper/mint--vg-swap_1: UUID="29291e62-cd4b-4bfb-a757-22f02f84052b" TYPE="swap"
/dev/sdb1: LABEL_FATBOOT="FAT32USBSTK" LABEL="FAT32USBSTK" UUID="84CE-0298" TYPE="vfat" PARTUUID="837e3546-01"
Mint20UlyanaCinnamon4.6.7>
...

Code: Select all

Mint20UlyanaCinnamon4.6.7> df -Th
Filesystem                Type      Size  Used Avail Use% Mounted on
udev                      devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs                     tmpfs     1.6G  1.6M  1.6G   1% /run
/dev/mapper/mint--vg-root ext4      213G  136G   67G  68% /
tmpfs                     tmpfs     7.8G  172K  7.8G   1% /dev/shm
tmpfs                     tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs                     tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs                     tmpfs     1.6G   28K  1.6G   1% /run/user/1000
/dev/sdb1                 ext4      916G   77M  870G   1% /mnt/wwn-0x5000c500450f95eb-part1
Mint20UlyanaCinnamon4.6.7> 
...

Code: Select all

Mint20UlyanaCinnamon4.6.7> cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/mint--vg-root /               ext4    errors=remount-ro 0       1
/dev/mapper/mint--vg-swap_1 none            swap    sw              0       0
/dev/disk/by-id/wwn-0x5000c500450f95eb-part1 /mnt/wwn-0x5000c500450f95eb-part1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
Mint20UlyanaCinnamon4.6.7> 
Last edited by karlchen on Sat Mar 13, 2021 2:31 pm, edited 1 time in total.
Reason: replaced [quote] tags by [code] tags
Mint 21.2 Victoria
Cinnamon 5.8
Intel© Core™ i7-8700K CPU @ 3.70GHz × 6
Graphics Card: NVIDIA Corporation GP107 [GeForce GTX 1050]
Mother board: ASUSTeK COMPUTER INC. PRIME Z370-P Rev X.0x
mikeflan
Level 17
Level 17
Posts: 7136
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Automounted External Drive Owned By Root

Post by mikeflan »

Like I say - I'm not the one to fix this.
I see this page:
https://askubuntu.com/questions/769460/ ... ly-as-root
but I don't know what to do.
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Automounted External Drive Owned By Root

Post by AndyMH »

Try adding sdd2 to fstab with the same options as sdd1, e.g.

Code: Select all

/dev/sdd2 /media/intel/somewhere_else auto nosuid,nodev,nofail,noauto,x-gvfs-show 0 0
personally I prefer to specify the filesystem and identify it by UUID not device reference

Code: Select all

#mount point for HDD in ultrabay
UUID=5cdf25ee-93ed-41a0-96f5-31ff2f85862c	/media/ultrabay	ext4	defaults,nofail	0	2
works for me (above asks for pwd to unmount which is okay by me, if you want to allow user unmount then put users in the options).
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
tinker123
Level 4
Level 4
Posts: 234
Joined: Sun Jan 20, 2013 9:17 pm

Re: Automounted External Drive Owned By Root

Post by tinker123 »

To clarify, what I am talking about I am referring to the feature that when you plug a USB drive into the computer, Mint will mount it for you, without you having to do anything.

When I do this with my USB hard drive, in the EXT file system, it gets mounted as root rather than as me.

Below is a copy of my fstab.

Code: Select all

Mint20UlyanaCinnamon4.6.7> cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/mint--vg-root / ext4 errors=remount-ro 0 1
/dev/mapper/mint--vg-swap_1 none swap sw 0 0
/dev/disk/by-id/wwn-0x5000c500450f95eb-part1 /mnt/wwn-0x5000c500450f95eb-part1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
Mint20UlyanaCinnamon4.6.7> [/quote]

Was the 3rd line created by Mint to mount whatever is plugged in?

People have mentioned adding UID into the options to mount EXT4 file systems as myself rather than root.

I tried that, but only made it so I couldn't mount the drive at all

[quote]/dev/disk/by-id/wwn-0x5000c500450f95eb-part1 /mnt/wwn-0x5000c500450f95eb-part1 auto uid=1000,gid=1000,nodev,nofail,x-gvfs-show 0 0
Would someone care to post a full example of that line or another line that will make mint mount USB drives for me, and mount it as me rather than root, even EXT4 file systems?
Last edited by karlchen on Sat Mar 13, 2021 2:34 pm, edited 1 time in total.
Reason: replaced [quote] tags by [code] tags
Mint 21.2 Victoria
Cinnamon 5.8
Intel© Core™ i7-8700K CPU @ 3.70GHz × 6
Graphics Card: NVIDIA Corporation GP107 [GeForce GTX 1050]
Mother board: ASUSTeK COMPUTER INC. PRIME Z370-P Rev X.0x
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Automounted External Drive Owned By Root

Post by AndyMH »

I note that you are using encryption.

The reason is that you have it mounting as root is that it is mounting in /mnt, which is owned by root. Don't like disks for various reasons, one being that it creates messy entries in fstab:

Code: Select all

/dev/disk/by-id/wwn-0x5000c500450f95eb-part1 /mnt/wwn-0x5000c500450f95eb-part1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
compare to:

Code: Select all

#mount point for HDD in ultrabay
UUID=5cdf25ee-93ed-41a0-96f5-31ff2f85862c	/media/ultrabay	ext4	defaults,nofail	0	2
which mounts an ext4 partition on an external drive in /media/ultrabay. I assume from what you've said that the partition you are talking about is ext4. If ntfs the options are slightly different.

You have choices:
  • remove the fstab entry and udisks will mount it automatically when you plug it in at /media/you/labelname or /media/you/UUID. Good practice to assign a label to a partition, much more user friendly than using the UUID.
  • change the fstab entry. You can mount it wherever you like, but if you mount it outside home or /media/you it will be owned by root. If you do that, with the drive plugged in:

Code: Select all

sudo chown -R $USER:$USER /wherever_you_mounted_it
that will change ownership back to you.

You get the UUID by running blkid in a terminal. Don't try to retype, copy/paste. You need to edit fstab as root.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
altair4
Level 20
Level 20
Posts: 11458
Joined: Tue Feb 03, 2009 10:27 am

Re: Automounted External Drive Owned By Root

Post by altair4 »

Still confused:

blkid says this:
/dev/sdb1: LABEL_FATBOOT="FAT32USBSTK" LABEL="FAT32USBSTK" UUID="84CE-0298" TYPE="vfat" PARTUUID="837e3546-01"
df -Th says this:
/dev/sdb1 ext4 916G 77M 870G 1% /mnt/wwn-0x5000c500450f95eb-part1
Could you please run blkid again this way:

Code: Select all

sudo blkid -c /dev/null
Last edited by altair4 on Sat Mar 13, 2021 1:37 pm, edited 1 time in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
tinker123
Level 4
Level 4
Posts: 234
Joined: Sun Jan 20, 2013 9:17 pm

Re: Automounted External Drive Owned By Root

Post by tinker123 »

remove the fstab entry and udisks will mount it automatically when you plug it in at /media/you/labelname or /media/you/UUID. Good practice to assign a label to a partition, much more user friendly than using the UUID.
That worked!

I commented out that line in my /etc/fstab and now it all works smoothly.

Thank you.
Mint 21.2 Victoria
Cinnamon 5.8
Intel© Core™ i7-8700K CPU @ 3.70GHz × 6
Graphics Card: NVIDIA Corporation GP107 [GeForce GTX 1050]
Mother board: ASUSTeK COMPUTER INC. PRIME Z370-P Rev X.0x
User avatar
karlchen
Level 23
Level 23
Posts: 18222
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Automounted External Drive Owned By Root

Post by karlchen »

<mod>
Questions by jvaes and replies to jvaes split off from this thread and turned into a dedicated thread here: viewtopic.php?f=50&t=344921.
Thread hijacking is not appreciated and it is counter-productive.
</mod>
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
Locked

Return to “Storage”