Linux-Noob Forums

Full Version: Set chown and chmod in external HDD
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

Hi at all,

 

I connected an external HDD. I need to set permissions, user and group. If I type commands chmod and chown I can not set them. How do I do?

 

If I type "fdisk -l" the result is:

 



Code:
255 heads, 63 sectors/track, 182401 cylinders
Unit  = cilindri di 16065 * 512 = 8225280 byte

Dispositivo Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      182401  1465135448+   c  W95 FAT32 (LBA)




 

Thankyou in advance for your help and sorry for my English


"chown" and "chmod" set permissions on *nix filesystems, such as EXT2, EXT3, EXT4, ReiserFS, JFS, etc.



Code:
/dev/sdb1               1      182401  1465135448+   c  W95 FAT32 (LBA)




As you can see there, the filesystem is FAT32, which doesn't honour *nix permissions.

 

If, on the other hand, you want to allow ordinary users to read/write to that external HDD, there are mount options that allow the disk to be "owned" by another user, which permits non-root access.

 

By the way - your English is fine. Much better than many English speakers I've seen on Facebook/Youtube!


Hi Dungeon-Dave,

 

thank You for your replay. I mounted the external HDD with this command

 



Code:
mount -t vfat -o rw,umask=0000 /dev/sdb1 /backup




 

Can you give me an indication of the command?

 

Thank You very very much for your help




Code:
mount -t vfat -o rw,umask=0000,uid=500,gid=700 /dev/sdb1 /backup




That will mount it as the user specified by UID 500 and group ownership GID 700.

 

The mount point won't be "owned" by root anymore, so user 500 can read/write to that filesystem happily.

 

(substitute these with your UID and GID - use the "id" command to return what they are)

 

For more information, try "man mount" to see options for the mount command.

 

Hope that helps!

 

(one final point: you can put this information in the /etc/fstab file so that a normal user can also perform the mount, rather than root having to do it)


Hi Dungeon-Dave,

 

I Type



Code:
id admin




This is the result: uid=501(admin) gid=501(admin) gruppi=501(admin)

 

I Type



Code:
mount -t vfat -o rw,umask=0000,uid=501,gid=501 /dev/sdb1 /backup




 

I connect to SSH with admin but if I type "mkdir /backup/test" the result is "Permission denied"

 

How can I fix this problem?


Worked okay for me without the -t option (and the umask option).

 

What do you see if you type in "mount" or "ls -ald /backups" - look at the permissions of that first.


If I type "ls -ald /backup" the result is "drwxr-xr-x 7 root root 32768 27 ott 13:30 /backup"

 

user and group is root, but should be admin o_Oo_O

 

I've try:

 

#umount -l /backup/

#mkdir /backup

#chown admin:admin /backup

#mount -t vfat -o rw,umask=0000,uid=501,gid=501 /dev/sdb1 /backup

 

but if I type "ls -ald /backup" the result is "drwxr-xr-x 7 root root 32768 27 ott 13:30 /backup"

 

[img]<___base_url___>/uploads/emoticons/default_mad.gif[/img]o_O[img]<___base_url___>/uploads/emoticons/default_ohmy.png[/img]


It looks like the "umount -l" is not working, or rather, not actually dismounting the volume.

 

You shouldn't need to use "mkdir" to create the directory if it already exists.

 

Try the following:

 

"mount" - check that it isn't mounted.

"ls -ald /backup" - check the permissions

"mount -o uid=501,gid=501 /dev/sdb1 /backup" - should mount the USB pen

"ls -ald /backup" - check the ownership again. This should now reflect "admin:admin".


Hi Dungeon-Dave,

 

I've type thath commands:

 

#mount (to check if /backup is mounted)

#rm -rf backup (for delete the backup directory)

#mkdir /backup;chown admin:admin /backup (to create the backup directory)

#ls -ald /backup (for check user and group of backup directory)

#mount -o uid=501,gid=501 /dev/sdb1 /backup (for mount the external HDD)

#ls -ald /backup

 

the final result: drwxr-xr-x 7 root root 32768 27 ott 13:30 /backup

 

o_Oo_Oo_Oo_O

Can you post the output of your "mount" and "df" commands at all?
Pages: 1 2