You are not logged in.

#1 2015-04-18 20:48:56

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

[Solved] How to fix default messy disk permissions?

Whenever I set up a new linux install, be it Fedora or Arch, I'm facing the same mess with the default mounting configuration. This time is no different. I gave up on it with one of my previous installs (Arch) but this time I'd like to tackle the problem and learn WHY this happens. I'd appreciate any help.

$ lsblk -f
NAME   FSTYPE LABEL                   UUID                                 MOUNTPOINT
sda                                                                        
├─sda1 ext4   S_50                    81013467-61c5-4fca-a8b1-6471ab2ff66e /run/media/hg1/S_50
├─sda2 ext4   S_140                   ada1868a-eb43-40ac-87ba-8a99bb9800f6 /run/media/hg1/S_140
├─sda3 ext4   S_740                   9ca4788c-b6ab-4f2e-aa10-b8167ae76d4c /run/media/hg1/S_740
└─sda4 ntfs   S_10ntfs                457FAFD72A8942B7                     /run/media/hg1/S_10ntfs
sdb                                                                        
├─sdb1 ntfs                           208A713C8A711010                     
├─sdb2 ntfs   ss_win                  0A80775A80774AE9                     
├─sdb3                                                                     
├─sdb5 ext4   ss_boot                 ac72a869-6615-418c-8ded-0d332031cad5 /boot
├─sdb6 ext4   ss_var                  916eb67e-b963-4781-b434-6ec3281bd1b1 /var
├─sdb7 ext4   ss_root                 61c35767-58d5-44cd-9be0-de43e88c4b25 /
└─sdb8 ext4   ss_home                 35390a6a-8220-4a90-9065-227bdfcb2946 /home
sdc                                                                        
└─sdc1 ntfs   500_ntfs                7062D4863AD9B32D                     
sdd    udf    Parted Magic 2014_11_19 2014-11-19-06-59-19-00               /run/media/hg1/Parted Magic 2014_11_19
sr0          
$  ls -l /mnt
total 8
drwxr-xr-x 2 root root 4096 Mar 25 20:45 sdb5
drwxr-xr-x 2 root root 4096 Mar 25 20:25 sdd
$  ls -l /run/media/hg1
total 18
dr-x------  6 hg1 hg1   312 Nov 19 13:59 Parted Magic 2014_11_19
drwxrwxrwx  1 hg1 hg1  4096 Apr 18 20:58 S_10ntfs
drw-rw-rw-  3 hg1 hg1  4096 Apr 17 21:08 S_140
drw-rw-rw-  2 hg1 root 4096 Apr 17 21:08 S_50
drwxr-xr-x 14 hg1 root 4096 Apr 18 20:58 S_740
$ cat /etc/fstab
# 
# /etc/fstab: static file system information
#
# <file system>	<dir>	<type>	<options>	<dump>	<pass>
# /dev/sdc7
UUID=61c35767-58d5-44cd-9be0-de43e88c4b25	/         	ext4      	rw,relatime,data=ordered	0 1

# /dev/sdc5
UUID=ac72a869-6615-418c-8ded-0d332031cad5	/boot     	ext4      	rw,relatime,data=ordered	0 2

# /dev/sdc6
UUID=916eb67e-b963-4781-b434-6ec3281bd1b1	/var      	ext4      	rw,relatime,data=ordered	0 2

# /dev/sdc8
UUID=35390a6a-8220-4a90-9065-227bdfcb2946	/home     	ext4      	rw,relatime,data=ordered	0 2
$ mount | column -t | grep /dev/sd
/dev/sdb7   on  /                           type   ext4             (rw,relatime,data=ordered)
/dev/sdb6   on  /var                        type   ext4             (rw,relatime,data=ordered)
/dev/sdb5   on  /boot                       type   ext4             (rw,relatime,data=ordered)
/dev/sdb8   on  /home                       type   ext4             (rw,relatime,data=ordered)
/dev/sdd    on  /run/media/hg1/PartedM      type   udf  	    (ro,nosuid,nodev,relatime,uid=1000,gid=1000,umask=77,iocharset=utf8,uhelper=udisks2)
/dev/sda3   on  /run/media/hg1/S_740        type   ext4             (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sda1   on  /run/media/hg1/S_50         type   ext4             (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sda2   on  /run/media/hg1/S_140        type   ext4             (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sda4   on  /run/media/hg1/S_10ntfs     type   fuseblk          (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2)

0. Could anyone tell me why the order of assigned letter codes is so weird? Does it even matter? External drive is sda and my main drive (SSD) is sdb. I always connect my drives to match drive importance vs motherboard disk channel number.

1. I'd like to start with the sda which is an external USB 3.0 HDD (Seagate BK+):
a) why by default I have read/write access to sda3 but not to sda1 and sda2?
b) how do I get read/write permissions to all partitions on sda persistently?

Last edited by bbarcher (2015-05-02 13:10:22)


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

#2 2015-04-19 09:45:56

PaterSiul
Member
Registered: 2015-04-01
Posts: 18

Re: [Solved] How to fix default messy disk permissions?

Hi bbarcher,

I have no Idea about 0.

1: I would assume, this is because of the permissions of the root directory of the partitions. The question is: what did you do to fix the problem in the past ("persistently" indicates that you tried something).

Offline

#3 2015-04-19 10:05:50

Spider.007
Member
Registered: 2004-06-20
Posts: 1,176

Re: [Solved] How to fix default messy disk permissions?

The order of disks is determined by the motherboard; and since you it could use different chips for different ports, the physical order doesn't necessarily have any relation to their names. As for permissions 'on partitions', this is determined by the filesystem on that partition, and has little to do with the os that mounts them. Since you use ext4 for those it's simply a mather of chmodding them correctly.

Last edited by Spider.007 (2015-04-19 10:06:11)

Offline

#4 2015-04-19 13:15:16

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

Re: [Solved] How to fix default messy disk permissions?

PaterSiul wrote:

Hi bbarcher,

I have no Idea about 0.

1: I would assume, this is because of the permissions of the root directory of the partitions. The question is: what did you do to fix the problem in the past ("persistently" indicates that you tried something).

Yes, I did try to address this on my previous installs. I've used a combination of Gnome Disks (hence udisks?), fstab and chmod. I ended up with a random behavior similar to the current situation (I could write to some partitions, to other partitions I couldn't) topped with automatically created Gnome Disks entries in fstab which looked nothing like the usually recommended lines. A mess I'd rather not bring up if possible. Please let's focus an a 'reset existing configuration, whatever it was, and make it right' approach.

Spider.007 wrote:

The order of disks is determined by the motherboard; and since you it could use different chips for different ports, the physical order doesn't necessarily have any relation to their names. As for permissions 'on partitions', this is determined by the filesystem on that partition, and has little to do with the os that mounts them. Since you use ext4 for those it's simply a mather of chmodding them correctly.

I see.
What general path should I take? Simply chmod /run/media/hg1?

I reckon there's no chance for a 'per disk' (all partitions on the indicated disk) solution on linux? I'm currently going through a dozen of articles on linux file and user permissions and I haven't stumbled on anything along the lines of 'per disk'.


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

#5 2015-04-19 13:57:33

PaterSiul
Member
Registered: 2015-04-01
Posts: 18

Re: [Solved] How to fix default messy disk permissions?

bbarcher wrote:
Spider.007 wrote:

The order of disks is determined by the motherboard; and since you it could use different chips for different ports, the physical order doesn't necessarily have any relation to their names. As for permissions 'on partitions', this is determined by the filesystem on that partition, and has little to do with the os that mounts them. Since you use ext4 for those it's simply a mather of chmodding them correctly.

I see.
What general path should I take? Simply chmod /run/media/hg1?

I reckon there's no chance for a 'per disk' (all partitions on the indicated disk) solution on linux? I'm currently going through a dozen of articles on linux file and user permissions and I haven't stumbled on anything along the lines of 'per disk'.

The advantage of modern file systems (as opposed to fat) is that there are per directory/file-permissions. So, no, there is no per-disk-solution. There isn't even a per-partition solution. There are mount options that can limit the effect of permissions (like rw, nodev or noexec).

As the root directory of a partition is just another directory, you can set permissions there. That would be

chmod 777 $MOUNTPOINT

, yes. But /run/media/hg1 won't work for $MOUNTPOINT since it is the directory above the mountpoint. So you would have to use /run/media/hg1/S_50 for /dev/sda1, for example.

Offline

#6 2015-04-19 15:22:50

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

Re: [Solved] How to fix default messy disk permissions?

OK, so no fstab alteration required per se for now.

PaterSiul wrote:

The advantage of modern file systems (as opposed to fat) is that there are per directory/file-permissions. So, no, there is no per-disk-solution. There isn't even a per-partition solution. There are mount options that can limit the effect of permissions (like rw, nodev or noexec).

PaterSiul wrote:

As the root directory of a partition is just another directory, you can set permissions there. That would be

chmod 777 $MOUNTPOINT

, yes. But /run/media/hg1 won't work for $MOUNTPOINT since it is the directory above the mountpoint. So you would have to use /run/media/hg1/S_50 for /dev/sda1, for example.

These two bits bring me to the question I wanted to ask since like 2 years ago: What's the difference between a mountpoint and a path? For example, if you issue

chmod 777 /home/hg1

(or is it chmod -R ?)
the operation applies to every file, directory and sub-directory in /home/hg1 but it's different with mountpoints. Issuing

chmod 777 /mount

won't apply to to every file, directory and sub-directory in /mount including e.g. /mount/sda1/..., /mount/sda2/... etc.
Similarly issuing

rm -rf /home/hg1

won't remove everything down the line if there's for example sdb1 mounted to /home/hg1/mumbo/sdb1.

One more additional question:
computer 1, all files on an external disk with permissions restricted to computer 1 user by the name of theone
computer 2, has a user by the name theone as well
Q: Will theone from computer 2 be able to access the files on the external disk?
Note: I use Parted Magic often. Everything I write there gets restricted to 'root'. I have no problem taking over such resources using chown on my regular linux installation. So what's the point?

Last edited by bbarcher (2015-04-19 15:25:10)


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

#7 2015-04-19 15:59:10

PaterSiul
Member
Registered: 2015-04-01
Posts: 18

Re: [Solved] How to fix default messy disk permissions?

bbarcher wrote:

OK, so no fstab alteration required per se for now.

Right.

These two bits bring me to the question I wanted to ask since like 2 years ago: What's the difference between a mountpoint and a path?

A mountpoint is always a path, but not vice versa. A partition has to be accessible somehow and that is the unix way with a unified hierarchy. Windows differs insofar as by default every file system has a seperated one, starting with the drive letter - although in recent versions file systems can be mounted in directories as well.

A consequence of a path being a mountpoint, as you have already discovered, shows in that not every operation crosses file system boundaries - be it for technical reasons or to counter human stupidity.

For example, if you issue

chmod 777 /home/hg1

(or is it chmod -R ?)
the operation applies to every file, directory and sub-directory in /home/hg1

if you want it recursively, it has to be chmod -R. Otherwise chmod affects only the file/directory it is called on.

but it's different with mountpoints. Issuing

chmod 777 /mount

won't apply to to every file, directory and sub-directory in /mount including e.g. /mount/sda1/..., /mount/sda2/... etc.
Similarly issuing

rm -rf /home/hg1

won't remove everything down the line if there's for example sdb1 mounted to /home/hg1/mumbo/sdb1.

And that is probably for the best.

One more additional question:
computer 1, all files on an external disk with permissions restricted to computer 1 user by the name of theone
computer 2, has a user by the name theone as well
Q: Will theone from computer 2 be able to access the files on the external disk?

That depends. User and group IDs are stored numerically. If theone has the same ID on both systems, then yes.

Note: I use Parted Magic often. Everything I write there gets restricted to 'root'. I have no problem taking over such resources using chown on my regular linux installation. So what's the point?

Do you mean, since you can issue chmod/chown using e.g. sudo, it shouldn't be created with uid/gid root?
In that case, how else should it be? Since it's your machine, you had better be able to somehow become root. And, even if not, which user should be the owner, if not root? root is always a safe bet since every system has that user. Also, if it is a true multi-user-system it'd be a bad idea if you'd start a partition with any other permissions.

Offline

#8 2015-04-19 16:28:41

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

Re: [Solved] How to fix default messy disk permissions?

The difference between a mountpoint and a path:
So 'not every operation crosses mountpoint boundaries'. I'm also fine with the reasoning smile Thank you.
Notably you can go through a dozen of guides on the subject and neither will even mention this issue. Some don't even include the term 'path'.

PaterSiul wrote:

That depends. User and group IDs are stored numerically. If theone has the same ID on both systems, then yes.

I've looked into the users and groups files using cat command and I haven't seen any IDs similar to UUIDs. Are root users also identifiable by such unique IDs? If so, this would contradict what I've seen so far.  I have never encountered a situation where I couldn't chown with my root.*** Isn't it the case that to stop a root on another computer from accessing my data on an external drive (all permissions) I'd have to encrypt the entire file system of that drive?

PaterSiul wrote:

Do you mean, since you can issue chmod/chown using e.g. sudo, it shouldn't be created with uid/gid root?
In that case, how else should it be? Since it's your machine, you had better be able to somehow become root. And, even if not, which user should be the owner, if not root? root is always a safe bet since every system has that user. Also, if it is a true multi-user-system it'd be a bad idea if you'd start a partition with any other permissions.

My notion is that any kind of restricted permissions on removable drives don't make sense for the reason I stated above***
How it should be in my opinion? Given the purpose of Parted Magic (live rescue usb) I'd imagine it should assign any resources it writes 'no restrictions' i.e. 777.

Please don't take my comments above as 'claims'. I'm in the dark here, just trying to figure out the nuances most guides fail to explain.


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

#9 2015-04-19 16:39:50

PaterSiul
Member
Registered: 2015-04-01
Posts: 18

Re: [Solved] How to fix default messy disk permissions?

bbarcher wrote:

I've looked into the users and groups files using cat command and I haven't seen any IDs similar to UUIDs. Are root users also identifiable by such unique IDs? If so, this would contradict what I've seen so far.

They are not unique.  root is always 0.

I have never encountered a situation where I couldn't chown with my root.*** Isn't it the case that to stop a root on another computer from accessing my data on an external drive (all permissions) I'd have to encrypt the entire file system of that drive?

Yes. Permissions are useful for online systems. Preventing an attacker with physical access from accessing your data is something else entirely.

PaterSiul wrote:

Do you mean, since you can issue chmod/chown using e.g. sudo, it shouldn't be created with uid/gid root?
In that case, how else should it be? Since it's your machine, you had better be able to somehow become root. And, even if not, which user should be the owner, if not root? root is always a safe bet since every system has that user. Also, if it is a true multi-user-system it'd be a bad idea if you'd start a partition with any other permissions.

My notion is that any kind of restricted permissions on removable drives don't make sense for the reason I stated above***
How it should be in my opinion? Given the purpose of Parted Magic (live rescue usb) I'd imagine it should assign any resources it writes 'no restrictions' i.e. 777.

Please don't take my comments above as 'claims'. I'm in the dark here, just trying to figure out the nuances most guides fail to explain.

parted magic is just a distribution built around parted, which, in turn, is a general partitioning tool. There are a lot of things one can do with partitions. parted cannot know what you want. So as few permissions as necessary seems like a good default. It's not like you couldn't change them.

Offline

#10 2015-04-19 16:55:05

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

Re: [Solved] How to fix default messy disk permissions?

PaterSiul wrote:

They are not unique.  root is always 0.
Yes. Permissions are useful for online systems. Preventing an attacker with physical access from accessing your data is something else entirely.

Ah, OK.

PaterSiul wrote:

parted magic is just a distribution built around parted, which, in turn, is a general partitioning tool. There are a lot of things one can do with partitions. parted cannot know what you want. So as few permissions as necessary seems like a good default. It's not like you couldn't change them.

Of course they can be changed. I'm talking about convenient defaults. But obviously what is convenient for one may not be that convenient (or even sane) for others.

Thank you for your help. Off to chmod everything! smile


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

#11 2015-04-20 21:07:00

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

Re: [Solved] How to fix default messy disk permissions?

OK, it worked.
Should chmod 777 work recursively? I'm asking because a /run/media/hg1/S_140/WD500 directory remained not accessible. I had to issue chmod -R 777 /run/media/hg1/S_140

One more thing.
So far we were dealing with partitions that would mount but contained inaccessible files. Later I was facing a problem with 3 ntfs partitions that, if selected in Nautilus for mounting, trigger an 'Authentication required' prompt. These are sdb2 and sdc1. Notably it doesn't apply to sda4.
I dealt with it using Gnome Disks > Mount options. It adds lines to /etc/fstab. My questions:
1. Why was I getting the password prompt on mounting sdb2 and sdc1 but not when mounting other partitions? Is it a generic linux behavior or something to do with Gnome components/configuration/policy?
2. Was /etc/fstab the right way to address the problem with sdb2 and sdc1?

Note:
I got ntfs-3g installed on setting up my Arch installation.


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

#12 2015-04-21 04:48:52

PaterSiul
Member
Registered: 2015-04-01
Posts: 18

Re: [Solved] How to fix default messy disk permissions?

bbarcher wrote:

OK, it worked.
Should chmod 777 work recursively? I'm asking because a /run/media/hg1/S_140/WD500 directory remained not accessible. I had to issue chmod -R 777 /run/media/hg1/S_140

I already answered that. Read "man chmod". That answers that question, too.

One more thing.
So far we were dealing with partitions that would mount but contained inaccessible files. Later I was facing a problem with 3 ntfs partitions that, if selected in Nautilus for mounting, trigger an 'Authentication required' prompt. These are sdb2 and sdc1. Notably it doesn't apply to sda4.
I dealt with it using Gnome Disks > Mount options. It adds lines to /etc/fstab. My questions:
1. Why was I getting the password prompt on mounting sdb2 and sdc1 but not when mounting other partitions? Is it a generic linux behavior or something to do with Gnome components/configuration/policy?
2. Was /etc/fstab the right way to address the problem with sdb2 and sdc1?

Note:
I got ntfs-3g installed on setting up my Arch installation.

I neither know nor care why nautilus asked you for your password on only those partitions. When it comes to ntfs, I generally find it best to do things manually. Especially, since in the past I managed to fuck up permissions for windows. So, while /etc/fstab is the path I would have chosen (path in the metaphorical sense), having a program do it automagically is not.

Offline

#13 2015-04-21 06:05:41

bbarcher
Member
From: Poland
Registered: 2014-02-27
Posts: 174
Website

Re: [Solved] How to fix default messy disk permissions?

OK, thanks.


Put up or shut up. 
--Austin Meyer, the lead developer of X-Plane
[ url=http://... ]  Text  [ /url ]

Offline

Board footer

Powered by FluxBB