Change ownership

Forum rules
Before you post please read this
Post Reply
User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Change ownership

Post by cakehead » Sat Dec 30, 2006 4:33 pm

I have just added a new hard drive to my system, I have:
Master HDA1
Slave HDD1

I have set up the drive ok and It has one partition on the drive, that belongs to ROOT. How do I change the ownership so that I can write to the drive.

Thanks

scorp123
Level 8
Level 8
Posts: 2277
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Re: Change ownership

Post by scorp123 » Sat Dec 30, 2006 7:33 pm

cakehead wrote:I have set up the drive ok
First things first ... what did you set the mount point to?

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 8:44 am

Partition is set to /dev/hdd1 and the mountpoint is set to /mnt/hdd1 I have a folder created in /mnt to /mnt/hdd1

scorp123
Level 8
Level 8
Posts: 2277
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 » Sun Dec 31, 2006 9:08 am

cakehead wrote:Partition is set to /dev/hdd1 and the mountpoint is set to /mnt/hdd1 I have a folder created in /mnt to /mnt/hdd1
I'd then suggest to go into this mount point, create a subdirectory which we could name "data", and then give this subdirectory to your normal user. Then, in your home directory, create a symbolic link to that "data" directory. Now when you want to place files on your new HDD just place them into your "data" subdirectory.

The shell commands needed for this:

Code: Select all

cd /mnt/hdd1
sudo mkdir data
sudo chown -R yourusername:yourusername data
cd /home/yourusername
ln -s /mnt/hdd1/data data
Now you should have a new "data" subdirectory in your home folder. You can of course also place it onto your desktop, wherever you wish. Writing to it should not be a problem now.

Regards,
Scorp123

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 9:17 am

I followed the instruction and this is what happened
j
ohn@john-mint:~$ cd /mnt/hdd1
john@john-mint:/mnt/hdd1$ sudo mkdir data
Password:
john@john-mint:/mnt/hdd1$ sudo chown -R john:john data
chown: changing ownership of `data': Operation not permitted
john@john-mint:/mnt/hdd1$

This is the problem I have taking ownership, I keep getting the message
'Operation not permitted !'

scorp123
Level 8
Level 8
Posts: 2277
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 » Sun Dec 31, 2006 11:57 am

cakehead wrote:I followed the instruction and this is what happened
j
ohn@john-mint:~$ cd /mnt/hdd1
john@john-mint:/mnt/hdd1$ sudo mkdir data
Password:
john@john-mint:/mnt/hdd1$ sudo chown -R john:john data
chown: changing ownership of `data': Operation not permitted
john@john-mint:/mnt/hdd1$

This is the problem I have taking ownership, I keep getting the message
'Operation not permitted !'
Can you please give me the output of this command: ls -al /mnt/hdd1/ (<== that's lower case L's there ... LS -AL ... but you have to type it with lower case letters, OK?). Also, please give me the output of this command: cat /etc/fstab

Regards,
Scorp123

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 12:12 pm

drwxr-xr-x 3 root root 16384 2006-12-31 13:13 .
drwxr-xr-x 3 root root 4096 2006-12-30 20:08 ..
drwxr-xr-x 2 root root 16384 2006-12-31 13:13 data

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/hda1
UUID=357078aa-2356-4180-aa99-5c6502adcc4f / ext3 defaults,errors=remount-ro 0 1
# /dev/hda5
UUID=2b49fd24-04d5-429f-8c44-99c8f2e3a2ca none swap sw 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/hdd1 /mnt/hdd1 vfat user,rw,auto 0 0

I am thinking of starting again, delete all reference to the second hard disk partition and format again to EXT3 create a new mount point and create a file called data, hopefully this will let me own the file. What do you think of my idea. I have only been using Mint for a couple of weeks or so and all this is completely new to me.

scorp123
Level 8
Level 8
Posts: 2277
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 » Sun Dec 31, 2006 12:16 pm

cakehead wrote:/dev/hdd1 /mnt/hdd1 vfat user,rw,auto 0 0
Why oh why are you using a Windows formatted drive for this? You really need this? Or wouldn't you rather want a Linux-formatted drive?
Depending on what you want here we either have to modify the mount options above or we have to change the formatting of that drive! You decide. :wink:

Regards,
Scorp123

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 12:26 pm

I would rather format the drive to EXT3 or reiserfs, I used fat 32 because I had the command for /etc/fstab to get it working.

I am very willing to change the drive to a Linux format !

scorp123
Level 8
Level 8
Posts: 2277
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 » Sun Dec 31, 2006 1:52 pm

cakehead wrote:I would rather format the drive to EXT3 or reiserfs, I used fat 32 because I had the command for /etc/fstab to get it working.

I am very willing to change the drive to a Linux format !
OK ... Let's do it step by step. Don't skip any step, and if any step fails please STOP and come back here and tell me what's wrong ... It's only around 18:45 here so I won't be going off to my new year party until later in the evening :wink:

1.) Boot your PC

Stupid I know ... you probably already did that :-)

2.) Open a terminal

We will use it for a bunch of commands ...

3.) Unmount the partition in question

Code: Select all

sudo umount /mnt/hdd1
This part should finish without errors ... If there is an error, stop here!

4.) Modify /etc/fstab
We become root and open an editor:

Code: Select all

gksudo gedit /etc/fstab
Change this line (taken from your posting) .... :

Code: Select all

/dev/hdd1 /mnt/hdd1 vfat user,rw,auto 0 0 
... into this:

Code: Select all

/dev/hdd1 /mnt/hdd1 ext3 defaults 0 0 
When done, save the file and close the editor. You should be back in the terminal and have your input prompt again.

5.) Format the drive
You make yourself root again and format the drive now:

Code: Select all

sudo mkfs -t ext3 -L MyDataHDD1 /dev/hdd1
"MyDataHDD1" is a volume label ... you can leave this (incl. that "-L" parameter) away if you want. Depending on the drive and its size formatting might take a few minutes. If there is any error it should show up right there in the terminal

6.) Let's test this ...
You make yourself root again and try if you can mount the new drive:

Code: Select all

sudo mount /mnt/hdd1
Because we entered all neded parameters into /etc/fstab the drive should be mounted without errors. Try if you can list it's directory:

Code: Select all

ls -al /mnt/hdd1
7.) Create the "data" subdirectory and needed symlink

Code: Select all

cd /mnt/hdd1
sudo mkdir data
sudo chown -R john:john data
cd /home/john
ln -s /mnt/hdd1/data data
These commands should work now without error.

Try if you can create and delete an empty file from your home directory, as normal user "john":

Code: Select all

cd /home/john/data
touch test-file
ls -al
rm test-file
Again ... this should work without error

8.) Reboot!
Final test .... reboot your machine. Let's see if it still works! If yes, you're done, happy new year :D

Regards,
Scorp123

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 2:24 pm

Yes it does work, I now have a drive 156Gb of space which is owned by root containing a file called test-file. I own this file and I can copy,cut and paste to it. All that remains is to study your instructions and work out how it all works. Thanks you so much for helping me.

Just one more thing, on the drive HDD1 there is a file called lost+found; it has always been there, where has this come from ?

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 2:53 pm

Can you tell me what 'gk' does in this command: gksudo gedit /etc/fstab
I am familiar with sudo but not the gk bit.

scorp123
Level 8
Level 8
Posts: 2277
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 » Sun Dec 31, 2006 3:14 pm

cakehead wrote:Can you tell me what 'gk' does in this command: gksudo gedit /etc/fstab
I am familiar with sudo but not the gk bit.
gksudo is the GNOME graphical equivalent of "sudo". It's useful if you want / need to run GUI stuff as root. Though "sudo" might work just as well. Your mileage may vary :lol:

User avatar
cakehead
Level 2
Level 2
Posts: 83
Joined: Sat Dec 30, 2006 4:24 pm
Location: Aberdeen, Scotland

Post by cakehead » Sun Dec 31, 2006 4:00 pm

Thats great thanks again for your help.

Happy New Year

Post Reply

Return to “Mounting Partitions”