Chown user:group directory not changing user or group (automonted partition)

Hello,

I have an automounted (by systemd) partition that I’d like to change from root ownership to my own user.
I have tried root chown leebut:leebut web but the owner and group remain as root.

The reason for the change is that I’m using buildozer, but it fails to build, and I saw that directory ownership may be a problem.

I’m thinking that perhaps it’s not possible since the system is mounting the drive.
I am a member of leebut, and another not automounted drive is owned by leebut.

Thanks,
Lee.

Hi @tharangalion,

Change the directory it’s mounted TO’s ownership and permission before the mount is done.

$ /usr/bin/ls -lah /mnt
total 36K
[...]
drwxr-xr-x  4 mirdarthos mirdarthos 4.0K Jun 16 12:00 4tb_backup
drwxr-xr-x 12 mirdarthos mirdarthos 4.0K Jan 24  2022 5TB
[...]

Inside those I’ve mounted my 2 hard drives:

$ mount
[...]
systemd-1 on /mnt/4tb_backup type autofs (rw,relatime,fd=48,pgrp=1,timeout=10,minproto=5,maxproto=5,direct,pipe_ino=22542)
/dev/sda1 on /mnt/5TB type ext4 (rw,relatime)/dev/sda1 on /mnt/5TB type ext4 (rw,relatime)
[...]

The 4TB is an automounted one. With the following systemd unit files:

/etc/systemd/system/mnt-4tb_backup.mount:

[Unit]
Description=Mount Backup disk (/mnt/4tb_backup)

[Mount]
What=/dev/disk/by-uuid/c47c5a52-db30-4aef-bcbc-af35b7b021fd
Where=/mnt/4tb_backup
Type=ext4
Options=defaults,rw
TimeoutSec=10
TimeoutIdleSec=300

/etc/systemd/system/mnt-4tb_backup.automount:

[Unit]
Description=Automount backup drive
ConditionPathExists=/mnt/4tb_backup

[Automount]
Where=/mnt/4tb_backup
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target

This automounts the drive on demand.

I figured out how to do this from here:

And here:

That might help, and I hope it does!

1 Like

Using system folders like /mnt /home or /run for permanent mountpoints should be shunned as they are bound to create permission errors.

Always use a dedicated structure e.g. /data as this is the only way to ensure permissions stay the same.

4 Likes

Thanks. I’ll check it out in the morning.
I did follow the first tutorial to set up the automounts.

1 Like

Thanks for the warning.
It’s mounted /automounts/webdev

You mean sudo ?

The directory is not web but rather webdev

So wouldn’t the proper command be:

sudo chown leebut:leebut /automounts/webdev

Or even to apply to all files and folders within:

sudo chown -R leebut:leebut /automounts/webdev
2 Likes

Hello,

I have no idea why I posted ‘root’ and ‘web’, but yes those correction are what I actually used.
Thanks for pointing it out anyway.

So is the issue resolved? Did changing the ownership work and resolve the issue with buildozer?

Hold your horses, I had to do some life things, and my wife is ordering me to read stories to my son, so I don’t know yet.

I’ve just disabled the mount and automount files, rebooted, and drive reverted back to leebut ownership. While I was at it, I changed the name and label to one without spaces.

drwxrwxrwx 1 leebut leebut 28672 Nov 3 09:28 WebDev

Some files:

drwxrwxrwx 1 leebut leebut      4096 Sep  2 22:12  grid_2022
drwxrwxrwx 1 leebut leebut         0 Jul  1  2021  grid_challenge

After reboot, the auto-mounted drive is owned and grouped to root again.

drwxrwxrwx 1 root root 28672 Nov 3 09:28 webdev

[MOUNT]

[Unit]

Description=Mount Webdev disk (/automounts/webdev)

[Mount]
What=/dev/disk/by-uuid/01D5A3BB92BBCA10
Where=/automounts/webdev
Type=ntfs
Options=defaults,rw,noatime

[AUTOMOUNT]

[Unit]
Description=Automount webdev partition
ConditionPathExists=/automounts/webdev

[Automount]
Where=/automounts/webdev
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target

Of course it is. You haven’t specified any options that it should be owned by someone else.

Hello,

It might be an ‘of course’ situation for you since you know what to do. I on the other hand, do not, hence my original post. What options would you be referring to? I guess that should be applied to the .mount file.

The previously posted tutorials by @Mirdarthos do not show how to do that, except for on a network drive, which mine is not, and I’m not sure whether or not those options are applicable or safe in a different environment. I don’t want to try adding options randomly in case I brick something.

I don’t know anything by heart after 1 week. I have to google specifics just like anyone else. :smiley:

Sure they do. There are various Options= specified in those examples, among them uid= and gid=.

Well, it’s not random if it’s in documentation. Also, you just have to #yolo it sometimes.

2 Likes

Well, I’ll look into uid. I misunderstood since I have use uuid.

I used the options shown in the tutorial for a disk that is not networked. uid is featured in the network share section, mine is not a network drive and it says that uid and gid cause errors. The Disk Partition section has no mention of those.

UserID is not the same as UniversallyUniqueID. The former identifies a user, the latter identifies a partition.

The options are for the filesystem.

Most of those examples use ext4 which is a native filesystem. You’re using ntfs which is not a native filesystem, ie it doesn’t have the same permissions.

In order to match ntfs permissions to linux permissions you need to provide a UserID and GroupID for the user and group which you want to own it, and perhaps also define the permissions which should apply.

2 Likes

Thank you all for your help and pointers.

Once I knew what to look for, @zbe, I followed the trail.
The second tutorial posted by @Mirdarthos threw me a bit because it looked like uid and gid were specific to samba.
@dmt mentioning permissions led me to umask.

The searches put me onto fstab first, then I found out that mount uses the same options as fstab.

The final .mount works like this.

[unit]

Description=Mount Webdev disk (/automounts/webdev)

[Mount]
What=/dev/disk/by-uuid/01D5A3BB92BBCA10
Where=/automounts/webdev
Type=ntfs
Options=defaults,user,rw,noatime,group,uid=1000,gid=1000,umask=0000

drwxrwxrwx 1 leebut leebut 28672 Nov 3 09:28 webdev

Perhaps I should change the umask to 0003 so that root and I have full access but others can only read. I think that’s how it works.

1 Like

Another thing I needed to do was to include the exec option to the .mount file since, noexec was set and Kivy (a python program) was not working properly (executing something) on the auto-mounted partition but worked on the home partition.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.