Screwed drive permissions, share between OSX and Ubuntu
2014-07
I was looking on how to share files between my OSX and Linux systems, with this in mind, I've formatted the file system to HFS+, disabled journaling in OSX, and finally dumped all my files as "Storage"(label of the drive).
This worked fine, however, in linux, I apparently still couldn't write to the file system, it said "Can't write, not owner", the properties window showed onwer #99. After a little digging up I've found that this indeed is the uid OSX uses to easy share of drives between different file systems. But still linux couldn't write to it.
So I've thought "hey, let me chmod this to a free for all permissions" big mistake, I've made chmod -R 777 /pathto/volume, this made all subfolders un-accessible. Now I'm trying to connect the drive again in OSX and somehow "fix" the drive, if thats possible, but the drive isn't even showing up in disk utility when I connect it.
How can I proceed here? How can I fix permissions in Linux or OSX. And after that whats the best way to share between the two? I mean, can't I use uid #99 in linux??
I have an external hard drive connected to my Linux box. I wanted to setup a web server to access files on it, but the permission on all files and directories on the drive are rwx
for the owner which is my local login, and the group is the root
group.
I need the files readable by the apache user, I was trying to set all files to be chmod a+rwx -R *
, but this doesn't do anything (gives no errors, just has no effect.) I tried changing the group using chgrp
to my user group, but that won't work either, it gives me errors that I lack permission even when I run all those commands as sudo
!
What's up with this hard drive??? sudo chmod a+rwx *
should work on anything, right?
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
It's probably formatted as FAT, which doesn't support file permissions. Use ext3 instead.
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:
.