LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 04-24-2024, 06:37 AM   #1
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Rep: Reputation: 0
NVMe disk mounted by user but can't be accessed by user


I have an internal NVMe disk and when I mount it using a file manager it mounts to /media/<disk-id> which is fine. The problem is that after mounting the directory is owned by root:root and the permissions are 0700 which means that the user that just mounted the filesystem can't actually access it.

The system is a custom Yocto project using systemd so I suspect there is a udev rule somewhere that controls the mount options or falls back to some default values. The problem was evident after a semi-large update which might have updated systemd, polkit or any other software that is involved in managing the mounting of disks.

Is there a way to monitor what .rules-files are applied when I mount the filesystem? I seems to only affect the internal nvme-disk and not usb-sticks. USB-sticks are mounted (/media/<usb-device>) "correctly", owned by the user:usergroup with 0755 permissions.

EDIT:
After comparing with a different system that also contains an NVMe-disk it seems like it is also mounting it owned by root:root but with 0755 permissions, which at least lets the user read the filesystem. In my case I need the user to be able to test the disk so the user has to be able to write to the disk as well.

EDIT 2:
Manually setting the permissions with 'sudo chmod 666 /media/<disk-id>' works but I would prefer this to be done automatically during mounting. This also has to work on multiple systems with disks of different manufacturers and models, preferrably on all kind of disks no matter if it's a SATA, NVMe etc.

Last edited by minuzed; 04-24-2024 at 09:22 AM.
 
Old 04-24-2024, 09:49 AM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Hi, I have had similar problems in the past and I found that I could add the drive to /etc/fstab and have the drives partition/s mounted automatically at boot using the uuid for the partition or the drive designation, like /dev/nvmexxxxx (/dev/nvme0n1p3 in my case, I'll use that discriptor in this example).

The information you'll need may be found using lsblk, blkid. you may need root access to get one of those to give you a read out.

lsblk
Code:
...
nvme0n1     259:0    0   1.8T  0 disk 
├─nvme0n1p1 259:1    0     8M  0 part 
├─nvme0n1p2 259:2    0  44.7G  0 part /
├─nvme0n1p3 259:3    0  23.9G  0 part /usr
├─nvme0n1p4 259:4    0  14.4G  0 part [SWAP]
├─nvme0n1p5 259:5    0  10.8G  0 part /tmp
...
blkid
Code:
...
/dev/nvme0n1p5: UUID="c3737cc7-39d2-4106-ada8-bec1b1854c67" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="snipped, not required for this demonstration"
/dev/nvme0n1p3: UUID="1c1068d5-59ae-4294-9e86-614b0db16e95" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="snipped"
/dev/nvme0n1p1: PARTUUID="9c56b000-efdb-4a61-b035-7ce9ba198261"
/dev/nvme0n1p4: UUID="0b2464d0-641c-46f7-a472-ffcee19dc462" TYPE="swap" PARTUUID="snipped"
/dev/nvme0n1p2: UUID="ce6a2394-4d9b-47f2-b000-68ad43fc2a4a" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="snipped"
...
note, /dev/nvme0n1p1 is not mounted, but is a system boot partition.

Then you could add the info to fstab like so,
add the lines for the partition. The comment (#) is for your information and is not read by the system.
Code:
# /dev/nvme0n1p3: 
UUID=1c1068d5-59ae-4294-9e86-614b0db16e95 /usr            ext4    defaults        0       2
The directory must exist, you could add it to the $USER home directory, not /usr... in this example.

If the directory is in /media/(some-name) you may have to set permissions for it after you mkdir /media/(some-name)
Code:
mkdir /media/(some-name)
chown -hR user:usergroup /media/(some-name)
chmod -R 755 /media/(some-name)
I hope this helps, regards Glenn

Last edited by GlennsPref; 04-24-2024 at 09:51 AM.
 
Old 04-25-2024, 12:58 AM   #3
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
That would be a solution if it wasn't for the fact that I need this to work on multiple different systems with different hardware so I'm not able to use the UUID.

I would prefer it to make the mountpoint (/media/<disk-id>) owned by root and belong to group disk with a mode of 0664. That way I can make the user a member of the disk group and it would have full read/write access.

Last edited by minuzed; 04-25-2024 at 01:23 AM.
 
Old 04-25-2024, 03:57 AM   #4
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Sorry for the setting off in the wrong direction. It shows my limited experience.

I thought that the uuid was set when a partition was formatted because the uuid changes when formatted.

I don't have a solution.

I have seen an artical on ArchLinux site, but I haven't investigated it fully as I have only one system with multiple disks.

see this link for the artical...
https://wiki.archlinux.org/title/Per...orld_Wide_Name

I hope you find a solution asap. All the best.
 
Old 04-25-2024, 04:21 AM   #5
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
No worries, I appreciate all suggestions and ideas that might lead me in the direction towards a possible solution.

I will check the link and see if it gives me any new ideas. Cheers!
 
Old 04-26-2024, 09:56 PM   #6
friendlysalmon8827
Member
 
Registered: Dec 2023
Distribution: Anfroid,Debian
Posts: 99

Rep: Reputation: 5
Could the OP please further explain why he/she needs the drive(storage asset) to be available for use on multiple machines/ If this is a hard and fast requirement than I would recommend that the OP highly consider investing in an external m2 sata drive encl user

There are several hardware manufacturers out there that have devices such as the one that I mention in the above shortened paragraph
 
  


Reply

Tags
nvme, polkit, systemd, udev rules



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: NVMe Base for Raspberry Pi 5 with M-Key NVMe SSD Support LXer Syndicated Linux News 0 12-03-2023 09:30 PM
[SOLVED] Slackware 15 - NVME clone to external NVME - Boot problem from external NVME Klaus150 Slackware 35 10-16-2022 04:29 PM
LXer: Data in a Flash, Part II: Using NVMe Drives and Creating an NVMe over Fabrics Network LXer Syndicated Linux News 0 05-20-2019 11:41 PM
Migrate Linux/win10 dual boot from MBR nvme drive to a new GPT nvme drive bluemoo Linux - Software 7 09-25-2018 06:42 PM
mounted partiton can not be accessed by user eliassal Fedora 6 11-19-2010 05:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration