How to change drive ownership from root?

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
dirtyernie

How to change drive ownership from root?

Post by dirtyernie »

How do I gain permission/ownership of a added on HD currently owned by root?

Just installed 500gb hard-drive as an external drive. root is owner and I want to take ownership to read and write to drive?
I know this can be done through the terminal but cannot find an example to get me there. Any help is appreciated. I know how to become rooot user but how to change the drive permissions?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
austin.texas
Level 20
Level 20
Posts: 12003
Joined: Tue Nov 17, 2009 3:57 pm
Location: at /home

Re: How to change drive ownership from root?

Post by austin.texas »

dirtyernie wrote:How do I gain permission/ownership of a added on HD currently owned by root?

Just installed 500gb hard-drive as an external drive. root is owner and I want to take ownership to read and write to drive?
I know this can be done through the terminal but cannot find an example to get me there. Any help is appreciated. I know how to become rooot user but how to change the drive permissions?
You don't want to become root user.
When logged in as the ordinary administrative user, take ownership of the mount point with the command:

Code: Select all

sudo chown $USER:$USER /media/<username>/<mountpoint>
Discover the actual <mountpoint> with the command:

Code: Select all

lsblk
Mint 18.2 Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Linux Linx 2018
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: How to change drive ownership from root?

Post by Flemur »

Just installed 500gb hard-drive as an external drive. root is owner and I want to take ownership to read and write to drive?
Actually nobody owns the drive itself: directories on partitions are owned and have permissions.
Is it a new drive?
Is it partitioned?
What kind of partition(s)?
What makes you think root owns stuff?
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
dirtyernie

Re: How to change drive ownership from root?

Post by dirtyernie »

It is not a new drive. I formatted the drive in ext4 in Gparted.
When the drive is mounted it will not let me save files to it.
Right clicking drive under Properties/permissions it says drive is owned by root and is in Group root.
I don,t understand quite know to proceed from this point?
dirtyernie

Re: How to change drive ownership from root?

Post by dirtyernie »

sblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
└─sda1 8:1 0 931.5G 0 part /media/greg541/3ac9aff5-7b2
sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part /media/greg541/985ab4a5-64b
sdc 8:32 0 931.5G 0 disk
├─sdc1 8:33 0 243M 0 part /boot
├─sdc2 8:34 0 1K 0 part
└─sdc5 8:37 0 931.3G 0 part
├─mint--vg-root (dm-0) 252:0 0 915.5G 0 lvm /
└─mint--vg-swap_1 (dm-1) 252:1 0 15.7G 0 lvm [SWAP]
User avatar
austin.texas
Level 20
Level 20
Posts: 12003
Joined: Tue Nov 17, 2009 3:57 pm
Location: at /home

Re: How to change drive ownership from root?

Post by austin.texas »

Just follow the instruction I gave you:

Code: Select all

sudo chown $USER:$USER /media/<username>/<mountpoint>
In this case that would be:

Code: Select all

sudo chown $USER:$USER /media/greg541/985ab4a5-64b
Mint 18.2 Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Linux Linx 2018
dirtyernie

Re: How to change drive ownership from root?

Post by dirtyernie »

Thanks that worked. :D
theraja57

Re: How to change drive ownership from root?

Post by theraja57 »

Sorry about tagging on an old post but I'm having the same issue and I suspect there's maybe a syntax issue. I'm running Mint 19. No problem formatting the new HDD but getting current info on how to get r/w access has been frustrating. When I type the command line as austin.texas suggests the reply is chown: cannot access '/media/my username/f559-c14a. My mount point for sda1 (my new HDD partition) is shown as /mnt/f559c14a. I tried including the "mnt" part of the path in the command line in different locations but got the same message. I don't know if the method has been updated or my syntax is incorrect. Anyone know the current quick way to get this drive r/w? Thanks!
mediclaser
Level 4
Level 4
Posts: 492
Joined: Tue Mar 20, 2018 2:28 pm

Re: How to change drive ownership from root?

Post by mediclaser »

theraja57 wrote: Sun Dec 30, 2018 9:19 am Sorry about tagging on an old post but I'm having the same issue and I suspect there's maybe a syntax issue. I'm running Mint 19. No problem formatting the new HDD but getting current info on how to get r/w access has been frustrating. When I type the command line as austin.texas suggests the reply is chown: cannot access '/media/my username/f559-c14a. My mount point for sda1 (my new HDD partition) is shown as /mnt/f559c14a. I tried including the "mnt" part of the path in the command line in different locations but got the same message. I don't know if the method has been updated or my syntax is incorrect. Anyone know the current quick way to get this drive r/w? Thanks!
Please post what you get when you do lsblk in the terminal.
If you're looking for a greener Linux pasture, you won't find any that is greener than Linux Mint. ;)
User avatar
52ROSt
Level 5
Level 5
Posts: 737
Joined: Mon Apr 14, 2014 10:01 am

Re: How to change drive ownership from root?

Post by 52ROSt »

LM17.3 KDE

I found this old thread as it matches exactly my problem however I am doing something wrong and appreciate your help

I ran lsblk and get:

Code: Select all

rost@rost-X240:~ > lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   477G  0 disk 
├─sda1   8:1    0  29.8G  0 part /
├─sda2   8:2    0   7.7G  0 part [SWAP]
└─sda3   8:3    0   394G  0 part /home
sdb      8:16   0   1.8T  0 disk 
└─sdb1   8:17   0   1.8T  0 part 
sdc      8:32   0   1.8T  0 disk 
└─sdc1   8:33   0   1.8T  0 part 
sdd      8:48   0   1.8T  0 disk 
├─sdd1   8:49   0   1.2T  0 part /media/rost/HDD3_iodata
└─sdd2   8:50   0   667G  0 part /media/rost/680GBForImage
sr0     11:0    1  1024M  0 rom  
rost@rost-X240:~ > 
I need to change rights from root to me (rost, have admin rights) and used chown command in following form:

Code: Select all

rost@rost-X240:~ > sudo chown $rost:$rost /media/rost/680GBForImage
rost@rost-X240:~ > 
I as I was not sure about the "$" I also tried the command in this form:

Code: Select all

rost@rost-X240:~ > sudo chown rost:rost /media/rost/680GBForImage
rost@rost-X240:~ > 
Result is both cases no reaction at the terminal.

What am I doing wrong?

Thanks in advance for your help!
User avatar
52ROSt
Level 5
Level 5
Posts: 737
Joined: Mon Apr 14, 2014 10:01 am

Re: How to change drive ownership from root?

Post by 52ROSt »

LM17.3 KDE

I found this old thread as it matches exactly my problem however I am doing something wrong and appreciate your help

I ran

Code: Select all

lsblk
and got:

Code: Select all

rost@rost-X240:~ > lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   477G  0 disk 
├─sda1   8:1    0  29.8G  0 part /
├─sda2   8:2    0   7.7G  0 part [SWAP]
└─sda3   8:3    0   394G  0 part /home
sdb      8:16   0   1.8T  0 disk 
└─sdb1   8:17   0   1.8T  0 part 
sdc      8:32   0   1.8T  0 disk 
└─sdc1   8:33   0   1.8T  0 part 
sdd      8:48   0   1.8T  0 disk 
├─sdd1   8:49   0   1.2T  0 part /media/rost/HDD3_iodata
└─sdd2   8:50   0   667G  0 part /media/rost/680GBForImage
sr0     11:0    1  1024M  0 rom  
rost@rost-X240:~ > 
I need to change rights from root to me (=rost, have admin rights) and used
chown
command in following form:

Code: Select all

rost@rost-X240:~ > sudo chown $rost:$rost /media/rost/680GBForImage
rost@rost-X240:~ > 
As I was not sure about the "$" I also tried the command in this form:

Code: Select all

rost@rost-X240:~ > sudo chown rost:rost /media/rost/680GBForImage
rost@rost-X240:~ > 
Result is both cases no reaction at the terminal.

What am I doing wrong?

Thanks in advance for your help!
mediclaser
Level 4
Level 4
Posts: 492
Joined: Tue Mar 20, 2018 2:28 pm

Re: How to change drive ownership from root?

Post by mediclaser »

52ROSt, try this:

Code: Select all

sudo chown rost:rost /media/rost/680GBForImage -R
If you're looking for a greener Linux pasture, you won't find any that is greener than Linux Mint. ;)
User avatar
52ROSt
Level 5
Level 5
Posts: 737
Joined: Mon Apr 14, 2014 10:01 am

Re: How to change drive ownership from root? [SOLVED]

Post by 52ROSt »

Thanks for your help. I could change the ownership

I used first:

Code: Select all

rost@rost-X240:~ > sudo chown rost:rost /media/rost/680GBForImage -R
rost@rost-X240:~ >
As there was no reaction from the machine I also tried to add the "$" in front of name und group name

Code: Select all

rost@rost-X240:~ > sudo chown $rost:$rost /media/rost/680GBForImage -R
rost@rost-X240:~ > 
Again no reaction from the machine.

However I checked the partition directly and one of the commands I used changed the ownership. Thus if someone has the same problem, I recommend to try all commands I used and check after each command the ownership of the partition. This is necessary because I did not get any information at the terminal screen that the ownership was changed.
mediclaser
Level 4
Level 4
Posts: 492
Joined: Tue Mar 20, 2018 2:28 pm

Re: How to change drive ownership from root?

Post by mediclaser »

There are many terminal commands which don't display any message when the command is successful, and chown is one of those. By the way the -R option is to make sure the existing sub-directories (sub-folders) and their files are also affected by the ownership change.
If you're looking for a greener Linux pasture, you won't find any that is greener than Linux Mint. ;)
User avatar
52ROSt
Level 5
Level 5
Posts: 737
Joined: Mon Apr 14, 2014 10:01 am

Re: How to change drive ownership from root?

Post by 52ROSt »

Thanks for your additional information.

If learned something. The hard way! Hope it helps someone else.
razorrob

Re: How to change drive ownership from root?

Post by razorrob »

Hi everyone

Hope you can help. I'm having similar problem, i followed the instructions here .. but no luck. I just installed an extra HDD drive on my laptop via eSATA internally and wanted to use it to put most of my files. But as others, its owned by root and root group.
I get ...

Code: Select all

chown: cannot access '/media/rob/Lix': No such file or directory
chown: cannot access 'Work': No such file or directory
chown: cannot access 'Files': No such file or directory
Please help!
This is the full bit i tried which includes my mount info ...

Code: Select all

sudo] password for rob: 
chown: cannot access '/media/rob/Lix': No such file or directory
chown: cannot access 'Work': No such file or directory
chown: cannot access 'Files': No such file or directory

Code: Select all

rob@rob-Dell-linux:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  56.2M  1 loop /snap/bitwarden/33
loop1    7:1    0 184.1M  1 loop /snap/blender/51
loop2    7:2    0  97.9M  1 loop /snap/core/10577
loop3    7:3    0  55.4M  1 loop /snap/core18/1944
loop4    7:4    0 162.9M  1 loop /snap/gnome-3-28-1804/145
loop5    7:5    0 217.9M  1 loop /snap/gnome-3-34-1804/60
loop6    7:6    0  66.5M  1 loop /snap/thunderbird/97
loop7    7:7    0  64.8M  1 loop /snap/gtk-common-themes/1514
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   100M  0 part 
├─sda2   8:2    0 111.5G  0 part /media/rob/263C88E13C88ACFD
├─sda3   8:3    0     1K  0 part 
├─sda5   8:5    0   953M  0 part /boot
├─sda6   8:6    0  18.8G  0 part /
├─sda7   8:7    0  74.5G  0 part /home
└─sda8   8:8    0  17.7G  0 part [SWAP]
sdb      8:16   0 698.7G  0 disk 
├─sdb1   8:17   0     1K  0 part 
├─sdb5   8:21   0  13.7G  0 part [SWAP]
├─sdb6   8:22   0  13.7G  0 part 
├─sdb7   8:23   0  78.5G  0 part /media/rob/Lix Work Files
├─sdb8   8:24   0  68.4G  0 part /media/rob/Win Work Files
└─sdb9   8:25   0 524.4G  0 part /media/rob/StorageX

Code: Select all

rob@rob-Dell-linux:~$ sudo chown $rob:$rob /media/rob/Lix Work Files
chown: cannot access '/media/rob/Lix': No such file or directory
chown: cannot access 'Work': No such file or directory
chown: cannot access 'Files': No such file or directory

Code: Select all

rob@rob-Dell-linux:~$ sudo chown rob:rob /media/rob/Lix Work Files
chown: cannot access '/media/rob/Lix': No such file or directory
chown: cannot access 'Work': No such file or directory
chown: cannot access 'Files': No such file or directory
User avatar
Larry78723
Level 14
Level 14
Posts: 5476
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: How to change drive ownership from root?

Post by Larry78723 »

There is no Lix mount point. Also, mount points with spaces in the name have to be enclosed in double quotes. For example:

Code: Select all

sudo chown $rob:$rob /media/rob/Lix Work Files
should be

Code: Select all

sudo chown $USER:$USER /media/rob/"Lix Work Files"
You don't need to change $USER:$USER because it is interpreted as the currently logged in user.
Image
If you have found the solution to your initial post, please open your original post, click on the pencil, and add (Solved) to the Subject, it helps other users looking for help, and keeps the forum clean.
Locked

Return to “Hardware Support”