Can't change permission/ownership/group of external hard drive on Ubuntu
Check the filesystem type it's using first with df -T
:
sys@p:~$ df -T Filesystem Type 1K-blocks Used Available Use% Mounted on ext3 ext3 19222656 1050948 17195164 6% / tmpfs tmpfs 1684988 0 1684988 0% /lib/init/rw udev tmpfs 10240 64 10176 1% /dev tmpfs tmpfs 1684988 0 1684988 0% /dev/shm
If it's mounted on /mnt/external
for example you will see that in the far right column. You can see the filesystem type in the second column. If it's NTFS, you'll want NTFS-3G (probably already installed, if not sudo apt-get install ntfs-config
then gksu ntfs-config
). Linux already has FAT support for read & write although they do not support permissions.
If you want an NTFS partition mounted with ownership applied to a specific user/group, specify it in the mount switches:
mount -o uid=username,gid=groupname /dev/sdc /path/to/mount
If you change to ext3 as suggested above, you can use chown
:
chown -R user *
chown -R user .
As Kim said, you'll only get Unix permissions and ownership on a Unix filesystem. ext3 is a good candidate.
If you must use this drive without reformatting, you can do it with options to the mount
command that specify the owner, group, and/or read/write permissions. These options affect all files on the drive (see John T's answer for how to determine the FSTYPE):
# list files as owned by X, use numerical UID as found in /etc/passwd
$ mount -t <FSTYPE> -o uid=X /dev/?? /path/to/mount/point
# list files as owned by group Y, use numerical GID found in /etc/passwd
$ mount -t <FSTYPE> -o gid=Y /dev/?? /path/to/mount/point
# list files as accessible per umask
# (022 gives rwx permissions to owner, r-x permissions to everyone else)
$ mount -t <FSTYPE> -o umask=022 /dev/?? /path/to/mount/point
# combine all of the above:
$ mount -t <FSTYPE> -o uid=X,gid=Y,umask=022 /dev/?? /path/to/mount/point
I did this and it worked:
sudo umount /dev/sda3 /media/windows1
sudo umount /dev/sda5 /media/windows2
and then
sudo mount -o rwx /dev/sda3 /media/windows1
sudo mount -o rwx /dev/sda5 /media/windows2
Note that I am Using Ubuntu 11.10 and sda3
is my Windows C:
, sda5
is G:
.