LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-18-2018, 11:00 AM   #1
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
Changing ownership/writing to ext4 USB drive


I have a 4GB USB drive which I used fdisk to format using ext4. Now I can't write to the drive. I have tried chown and chmod to change permissions but I still get permission denied. To be clear, I used:

chown -R lysander /dev/sdb
chown $lysander:$lysander /dev/sdb

I have tried adding a line to the mount point in fstab but that's not working either. I am sure I am just missing something very basic.

lsblk:

Code:
lysander@lysurfer_viii:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
|-sda1   8:1    0    28G  0 part /
|-sda2   8:2    0     1K  0 part 
|-sda5   8:5    0     2G  0 part [SWAP]
`-sda6   8:6    0   203G  0 part /home
sdb      8:16   1   3.8G  0 disk /run/media/lysander/9f73a14b-0397-41de-bcd3-7b4b68897711
ls -ld:

Code:
lysander@lysurfer_viii:~$ ls -ld /dev/sdb
brw-rw---- 1 root plugdev 8, 16 Feb 18 16:45 /dev/sdb
Now, after chown -R lysander /dev/sdb I get:

Code:
bash-4.3# chown -R lysander /dev/sdb
bash-4.3# ls -ld /dev/sdb
brw-rw---- 1 lysander plugdev 8, 16 Feb 18 16:45 /dev/sdb
But I still cannot write.

fstab:

Code:
/dev/sda5        swap             swap        defaults         0   0
/dev/sda1        /                ext4        defaults         1   1
/dev/sda6        /home            ext4        defaults         1   2
#/dev/cdrom      /mnt/cdrom       auto        noauto,owner,ro,comment=x-gvfs-show 0   0
/dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
tmpfs            /dev/shm         tmpfs       defaults         0   0
#/dev/sdb         /run/media/lysander auto user,umask=000,utf8,noauto 0 0
As I say, I am probably missing something quite minor but I'm not sure what it is here.

Last edited by Lysander666; 02-18-2018 at 11:02 AM.
 
Old 02-18-2018, 11:37 AM   #2
Skaendo
Senior Member
 
Registered: Dec 2014
Location: West Texas, USA
Distribution: Slackware64-14.2
Posts: 1,445

Rep: Reputation: Disabled
Have you tried:
Code:
# chown -R lysander:users /run/media/lysander/9f73a14b-0397-41de-bcd3-7b4b68897711
 
1 members found this post helpful.
Old 02-18-2018, 11:49 AM   #3
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178

Original Poster
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
I thought it was something minor - Skaendo, I think you gave me the nudge in the direction I needed.

I tried what you suggested earlier but I just got an error saying the directory didn't exist.

Turns out that the terminal window [when I tried earlier] was not wide enough and as a result lsblk was not printing some of the drive characters [i.e. not just not displaying, but not printing].

e.g.

Code:
lysander@lysurfer_viii:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
|-sda1   8:1    0    28G  0 part /
|-sda2   8:2    0     1K  0 part 
|-sda5   8:5    0     2G  0 part [SWAP]
`-sda6   8:6    0   203G  0 part /home
sdb      8:16   1   3.8G  0 disk /run/media/lysander/9f73a14b-0397-41de-bcd3-7b4b6
lysander@lysurfer_viii:~$
extending window
Code:
lysander@lysurfer_viii:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
|-sda1   8:1    0    28G  0 part /
|-sda2   8:2    0     1K  0 part 
|-sda5   8:5    0     2G  0 part [SWAP]
`-sda6   8:6    0   203G  0 part /home
sdb      8:16   1   3.8G  0 disk /run/media/lysander/9f73a14b-0397-41de-bcd3-7b4b68897711
lysander@lysurfer_viii:~$
I used your command and the drive unlocked. I can now write to it, thank you.
 
Old 02-18-2018, 11:51 AM   #4
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,987

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
For future reference, with linux filesystems like ext4 you change permissions on the moutpoint not the device file to change access permissions on the filesytem. Skaendo's suggestion should work. If not, it's probably because you formatted the raw block device, sdb and did not create a partition on sdb beforehand. That works OK in some environments but can cause problems in others.
 
1 members found this post helpful.
Old 02-18-2018, 11:58 AM   #5
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178

Original Poster
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
Thanks kilgoretrout, you're right, I formatted the raw block and didn't create a partition on it. It worked though, so I'm thankful.

Is the ownership change specific to the Slack install? I'll try to read it from my Debian box which also has the user lysander.

Last edited by Lysander666; 02-18-2018 at 12:16 PM.
 
Old 02-18-2018, 12:34 PM   #6
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,987

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
Quote:
Now, since this device is owned by the user lysander, can it be read/written by any other Linux user on another machine or is the ownership change specific to the Slack install? I'll try to read it from my Debian install which also has the user lysander.
You can run into problems going from one distro to anther even if you're using the same username. That's because linux looks at the numerical user id(uid) to determine access permissions. Debian and Ubuntu based distros all assign the first user created a uid of 1000 whereas Redhat, Mageia, Fedora and other historically RH based distros all assign the first user created a uid of 500. I don't know what Slackware does by default but you can find out by running:
Code:
$ id
It's very annoying for disto hoppers because a username may have access in a Debian based distro and the same user will be denied access in an RH based distro because of the differing uids. The easiest way around the problem is to use chmod to give the world rw access instead of chown which will limit access to a given uid. The downside is the security implications of giving world rw access to the drive. To give the world rw access you would run the following with the deivce mounted:
Code:
# chmod 666 <mount point of the device>
 
1 members found this post helpful.
Old 02-18-2018, 03:35 PM   #7
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178

Original Poster
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
Thanks kilgoretrout, I'll use chmod if I run into problems. If anyone's interested I used the USB drive with Debian and it works, I can read from and write to it. So this has worked out rather nicely.
 
Old 02-18-2018, 03:41 PM   #8
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,062

Rep: Reputation: Disabled
To know more:
man usermod
man stat
 
1 members found this post helpful.
  


Reply



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
Changing ownership after mounting ext4 filesystem at boot time fanoflq Linux - Newbie 6 04-23-2016 04:32 PM
[SOLVED] Changing ownership of USB 'Not Permitted' Why? gael33 Linux - Newbie 5 05-26-2015 03:48 PM
changing ownership of a mounted drive laucian Linux - Newbie 9 11-02-2007 02:50 PM
Can't change root ownership of NTFS USB hard drive rrrssssss Mandriva 14 07-10-2006 04:42 PM
Changing ownership of partition and USB key a thing Linux - Newbie 7 01-27-2005 05:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:27 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