[opensuse] Accessing a USB-disk as normal user
Hi, This is not the first time I experience this, but now I wanted to ask. I formatted (EXT4) a new disk in a USB-to-SATA enclosure. All is fine. But when it is mounted via the "tray", I can't access it, I don't have rights to write on the disk. What I'm doing now is adding a directory as root and chowning that directory to my user. Then I can use that directory as storage. Is this the way to go or am I missing something ? On OS13.1. Koenraad. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Am Montag, 19. Januar 2015 17:44 CET, Koenraad Lelong <k.lelong@ace-electronics.be> schrieb:
This is not the first time I experience this, but now I wanted to ask. I formatted (EXT4) a new disk in a USB-to-SATA enclosure. All is fine. But when it is mounted via the "tray", I can't access it, I don't have rights to write on the disk. What I'm doing now is adding a directory as root and chowning that directory to my user. Then I can use that directory as storage.
Is this the way to go or am I missing something ?
Yes, the approach is correct. FAT file systems don't understand the concept of "user", so you can say "mount this and give all files to user XYZ". EXT4, on the other hand, is a Unix file system and it stores permissions (owner, group, permissions). So if you create a file as user X, then the file is owned by that user, even if you mount the disk on a different computer. Caveat: The file system actually stores only the user ID, not the name. The ID is resolved via /etc/passwd, so the names which ls reports can change. Regards, -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://blog.pdark.de/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2015-01-19 17:53, Aaron Digulla wrote:
Am Montag, 19. Januar 2015 17:44 CET, Koenraad Lelong <> schrieb:
Is this the way to go or am I missing something ?
Yes, the approach is correct.
Chowning the disk mount point, when mounted, can also work (some say, maybe dependent on desktop, dunno). But I'm not sure if the mountpoint can be a volatile one for this to work. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
On 1/19/2015 11:49 AM, Carlos E. R. wrote:
On 2015-01-19 17:53, Aaron Digulla wrote:
Am Montag, 19. Januar 2015 17:44 CET, Koenraad Lelong <> schrieb:
Is this the way to go or am I missing something ? Yes, the approach is correct. Chowning the disk mount point, when mounted, can also work (some say, maybe dependent on desktop, dunno). But I'm not sure if the mountpoint can be a volatile one for this to work.
I don't think this will work with auto-mount, because the permissions on the disk are on every file and every directory. I've had several of these disks in external enclosures, and use them to carry large blocks of date to different sites. And the perennial problem is that user number for my account on one system will be different than my number on another system, especially when they located at at different installations. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2015-01-20 06:20, John M Andersen wrote:
On 1/19/2015 11:49 AM, Carlos E. R. wrote:
I don't think this will work with auto-mount, because the permissions on the disk are on every file and every directory.
Someone tried, time ago, and said it worked. Of course, on the same machine, because as you say, a different machine may have a different set of UID numbers. There is no mapping mechanism. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
On 01/20/2015 07:06 AM, Carlos E. R. wrote:
On 2015-01-20 06:20, John M Andersen wrote:
On 1/19/2015 11:49 AM, Carlos E. R. wrote:
I don't think this will work with auto-mount, because the permissions on the disk are on every file and every directory.
Someone tried, time ago, and said it worked. Of course, on the same machine, because as you say, a different machine may have a different set of UID numbers. There is no mapping mechanism.
LOL! NFS comes to mind. But the mapping mechanism that uses won't work with locally mounted disks will it? Oh, wait! Export that mounted FS using NFS then import it somewhere else with the mapping ... -- /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Am 21.01.2015 um 20:16 schrieb Anton Aylward:
Someone tried, time ago, and said it worked. Of course, on the same machine, because as you say, a different machine may have a different set of UID numbers. There is no mapping mechanism.
LOL! NFS comes to mind. But the mapping mechanism that uses won't work with locally mounted disks will it?
Oh, wait! Export that mounted FS using NFS then import it somewhere else with the mapping ...
Actually, you should be able to mount an NFS share from localhost (127.0.0.1). The NFS service runs as root. The problem might be the mapping. If the FS uses different users, you will need to map your user ID to two IDs for the NFS. But if all files on the disk are owned by the same user ID, this might actually work. Regards, -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://blog.pdark.de/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 01/21/2015 03:01 PM, Aaron Digulla wrote:
Am 21.01.2015 um 20:16 schrieb Anton Aylward:
Someone tried, time ago, and said it worked. Of course, on the same machine, because as you say, a different machine may have a different set of UID numbers. There is no mapping mechanism.
LOL! NFS comes to mind. But the mapping mechanism that uses won't work with locally mounted disks will it?
Oh, wait! Export that mounted FS using NFS then import it somewhere else with the mapping ...
Actually, you should be able to mount an NFS share from localhost (127.0.0.1). The NFS service runs as root.
The problem might be the mapping. If the FS uses different users, you will need to map your user ID to two IDs for the NFS. But if all files on the disk are owned by the same user ID, this might actually work.
If the files on the mounted disk are similarly owned then there's no point in all this. What we are discussing is the case where the ownerIDs of the (removable) disk are different NUMERICALLY from the system the disk is being mounted on. That is exactly the situation with a NFS mount. The same symbolic names might exist on both the remote and local machines but with different numerical IDs. When we are faced with that with NFS there is a mapping tool. What is basically does is numberX on the specific NFS mount corresponds to numberY here. If you think about it, that has to be possible for each possible NFS mount from different machines, so adding it for localhost is not a problem. The whole point is that this mapping is only done for the NFS mounted volume. So what we have is * all the local file systems These are not NFS mounted so no mapping is done. * the mounted removable drive This is locally mounted so no mapping is done, but being a 'foreign generated' the owner & group numericalIDs are not the ones we need * the NFS mounted view of the locally mounted removable drive Because this is NFS mounted it can have the IDs mapped. -- /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 01/21/2015 12:19 PM, Anton Aylward wrote:
That is exactly the situation with a NFS mount. The same symbolic names might exist on both the remote and local machines but with different numerical IDs.
When we are faced with that with NFS there is a mapping tool. What is basically does is numberX on the specific NFS mount corresponds to numberY here.
These days that exists, and is almost usable. It didn't always exist, and it was a huge nightmare to always assign and maintain universal UIDs across a large network. Its one of the things that drove me to SAMBA even in an all-linux environment. -- After all is said and done, more is said than done. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2015-01-21 20:16, Anton Aylward wrote:
On 01/20/2015 07:06 AM, Carlos E. R. wrote:
On 2015-01-20 06:20, John M Andersen wrote:
On 1/19/2015 11:49 AM, Carlos E. R. wrote:
I don't think this will work with auto-mount, because the permissions on the disk are on every file and every directory.
Someone tried, time ago, and said it worked. Of course, on the same machine, because as you say, a different machine may have a different set of UID numbers. There is no mapping mechanism.
LOL! NFS comes to mind. But the mapping mechanism that uses won't work with locally mounted disks will it?
Oh, wait! Export that mounted FS using NFS then import it somewhere else with the mapping ...
Yes... But I have never figured out that translation. Now and then some one mentions it, but then it turns out that all files are treated as is from the anonymous user, which I think you can choose who it is. It is not "user 1357 will be user 2432. Or I'm mistaken, and a full mapping exists, but as I have not used it myself I have forgotten about it. Dunno. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
On 01/21/2015 03:05 PM, Carlos E. R. wrote:
On 2015-01-21 20:16, Anton Aylward wrote:
On 01/20/2015 07:06 AM, Carlos E. R. wrote:
On 2015-01-20 06:20, John M Andersen wrote:
On 1/19/2015 11:49 AM, Carlos E. R. wrote:
I don't think this will work with auto-mount, because the permissions on the disk are on every file and every directory.
Someone tried, time ago, and said it worked. Of course, on the same machine, because as you say, a different machine may have a different set of UID numbers. There is no mapping mechanism.
LOL! NFS comes to mind. But the mapping mechanism that uses won't work with locally mounted disks will it?
Oh, wait! Export that mounted FS using NFS then import it somewhere else with the mapping ...
Yes...
But I have never figured out that translation. Now and then some one mentions it, but then it turns out that all files are treated as is from the anonymous user, which I think you can choose who it is. It is not "user 1357 will be user 2432.
Or I'm mistaken, and a full mapping exists, but as I have not used it myself I have forgotten about it. Dunno.
Yes, you can 'squash' all userIDs to one ID. That may be a solution to the OPs problem :) But you can also do individual mapping. http://serverfault.com/a/632315 See also nfsidmap(5) RPC.IDMAPD(8) idmapd.conf(5) yes, its complicated because its comprehensive. -- /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 21.01.2015 um 21:05 schrieb Carlos E. R.:
But I have never figured out that translation. Now and then some one mentions it, but then it turns out that all files are treated as is from the anonymous user, which I think you can choose who it is. It is not "user 1357 will be user 2432.
Usually, you will want to use the user mapping from the remote NFS server, so you'll use idmapd. If you're insane or want to be, you can set up NIS or the more recent LDAP mapping via nsswitch. If you want to squash all user and group IDs to a single value, then this post explains it: http://serverfault.com/questions/514118/mapping-uid-and-gid-of-local-user-to... This explains it more detail: http://www.troubleshooters.com/linux/nfs.htm Regards, - -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://blog.pdark.de/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlTAETQACgkQbiq/qNASPmNYbwCgn37T9c/gfKNbvOaE2DDymrsK yd0AnR//DGhcNXSP3h76kNM0pBq5kV4r =5WV0 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Am Montag, 19. Januar 2015 20:49 CET, "Carlos E. R." <robin.listas@telefonica.net> schrieb:
On 2015-01-19 17:53, Aaron Digulla wrote:
Am Montag, 19. Januar 2015 17:44 CET, Koenraad Lelong <> schrieb:
Is this the way to go or am I missing something ?
Yes, the approach is correct.
Chowning the disk mount point, when mounted, can also work (some say, maybe dependent on desktop, dunno). But I'm not sure if the mountpoint can be a volatile one for this to work.
That only works if you do a chown -R but that would change the owner of every file. That said: If only a single users uses this drive, then that's probably the correct thing to do. Note that the ownership of the root note on the drive will become the owner of the mount point, no matter what permissions the underlying folder had before. The mount point "hides" or "overrides" the underlying folder as long as it exists. If you umount, the folder becomes visible again. Regards, -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://blog.pdark.de/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 19/01/15 16:44, Koenraad Lelong wrote:
Hi,
This is not the first time I experience this, but now I wanted to ask. I formatted (EXT4) a new disk in a USB-to-SATA enclosure. All is fine. But when it is mounted via the "tray", I can't access it, I don't have rights to write on the disk. What I'm doing now is adding a directory as root and chowning that directory to my user. Then I can use that directory as storage.
Is this the way to go or am I missing something ?
I have three empty folders, ~/A1, ~/A2, ~/A3, that I use for mounting external media. Because of their names, they naturally sort to the top of a file manager view (defaulting to sorting by name, of course). A python script mounts an external SATA drive on ~/A3, does an rsync-based backup, then unmounts the drive. I haven't worked out how to get it turn the external enclosure on and off, though ;-) Bob - -- Bob Williams System: Linux 3.16.7-7-desktop Distro: openSUSE 13.2 (x86_64) with KDE Development Platform: 4.14.3 Uptime: 06:00am up 7:55, 3 users, load average: 0.16, 0.05, 0.06 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlS+U74ACgkQ0Sr7eZJrmU480ACeOLz1DvVMfV+uD7zK8PM9kLYk 08YAniLLYF1GYPmmjcW2+0M369dBURpp =FmOq -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Am Dienstag, 20. Januar 2015 14:10 CET, Bob Williams <linux@barrowhillfarm.org.uk> schrieb:
A python script mounts an external SATA drive on ~/A3, does an rsync-based backup, then unmounts the drive. I haven't worked out how to get it turn the external enclosure on and off, though ;-)
If you just want the drive to go to sleep (turn off the spindle), then you can use hdparm -y Regards, -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://blog.pdark.de/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, 20 Jan 2015 14:16, Aaron Digulla wrote:
Am Dienstag, 20. Januar 2015 14:10 CET, Bob Williams schrieb:
A python script mounts an external SATA drive on ~/A3, does an rsync-based backup, then unmounts the drive. I haven't worked out how to get it turn the external enclosure on and off, though ;-)
If you just want the drive to go to sleep (turn off the spindle), then you can use
hdparm -y
That works for most enclosures, but some enclosures I use do that only with "eject", go figure. And, please use the commands (hdparm,eject) on the base device, not the partiton. Some devices do not like that, some commands abort on that. - Yamaban -- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (8)
-
Aaron Digulla
-
Anton Aylward
-
Bob Williams
-
Carlos E. R.
-
John Andersen
-
John M Andersen
-
Koenraad Lelong
-
Yamaban