LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva
User Name
Password
Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.

Notices


Reply
  Search this Thread
Old 11-01-2008, 09:17 PM   #1
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Rep: Reputation: 18
chmod and chown not working


I want to be able to write files outside of my /home directory, more precisely, onto my second hard disk, /media/hd on my system. Having just read up about chown, I ran "chown -R stuart.stuart hd" at the command line (at the media directory), but got a 'permission not allowed' error at each file and directory listing.

Then I learnt about chmod, which not did I think more suitable, seemed in its output at least, to have worked, giving me a 'changed permissions' message, now at (777) rwxrwxrwx (I had typed "chmod -vR a+w hd".) Listing the directory (ls -l) showed all was as before - no change.

I did all of this as root, so don't why no changes occur. Any ideas?

NirvanaII
 
Old 11-01-2008, 09:36 PM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
How was /media/hd mounted? If from /etc/fstab, what does /etc/fstab look like? It might be mounted ro.
Dave
 
Old 11-01-2008, 10:00 PM   #3
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Original Poster
Rep: Reputation: 18
media/hd only ever mounts when I click on drive icon in KDE, if not this, when I do it myself (mount -t vfat /dev/hdb1 /media/hd)

Each has the same effect. In Windows at the moment, don't know if it's etc/fstab is related but sometimes I see a different location in KDE, something like: media:hdb1

I don't know anything about etc/fstab, but am willing to take a brief lesson.

NirvanaII
 
Old 11-01-2008, 10:43 PM   #4
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
What is the output from mount (with no options - should give a list of all the mounts and how they are mounted)?
Dave
 
Old 11-01-2008, 11:45 PM   #5
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Original Poster
Rep: Reputation: 18
I get this:
[root@localhost stuart]# mount
/dev/hda5 on / type ext3 (rw)
none on /proc type proc (rw)
/dev/hda7 on /home type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)



Here's what I got earlier on today when running chmod:

[root@localhost media]# chmod -v a+w hd
mode of `hd' changed to 0777 (rwxrwxrwx)
[root@localhost media]# ls -l
total 44
drwxr-xr-x 2 root root 4096 2007-10-08 08:57 cdrom/
drwxr-xr-x 2 root root 4096 2007-10-08 08:56 floppy/
drwxr-xr-x 15 root root 32768 1970-01-01 01:00 hd/
drwxr-xr-x 2 root root 4096 2008-10-14 18:39 hd2/
[root@localhost media]#

I went on to check the files and directories at hd/, still as before.

NirvanaII
 
Old 11-02-2008, 06:20 AM   #6
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
Well, mount shows that only /dev/hda is mounted, no /dev/hdb, so you are only seeing the mountpoint directory on /dev/hda contents and not anything from /dev/hdb1 as it is not there. The message "permission not allowed" also means in this case "File not found".

Dave
 
Old 11-02-2008, 02:45 PM   #7
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Original Poster
Rep: Reputation: 18
Oops! Forgot to mount before getting that output. Here's the extra (and only other) line you'd perhaps expected:

/dev/hdb1 on /media/hd type vfat (rw)

So a re-writeable fat 32 partition, as would have been yesterday when running the chmod and chown commands. No surprise to me, but it is perhaps significant I am using a vfat formatted drive? Or is the failure related to something else?

NirvanaII
 
Old 11-02-2008, 03:03 PM   #8
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
It shows rw so it should be writeable if you have proper permissions. I don't know ANYTHING about windows as I came from OS/2 directly to linux. I know my stick is formatted as fat and I can read and write to it. Perhaps some maven will see this thread and help you.
Dave
 
Old 11-02-2008, 04:06 PM   #9
jkerr82508
Member
 
Registered: Dec 2006
Location: Fife, Scotland
Posts: 268

Rep: Reputation: 69
I don't think that it's possible to change permissions on files on a vfat partition, since vfat doesn't understand unix permissions. I don't use windows at all any more but this is what I have in my notes:

Quote:
Set the fstab entry to be similar to
/dev/sda1 /mnt/backup vfat defaults,users,umask=0,iocharset=iso8859-15,codepage=850 0 0

The users option allows anyone to mount it.
The umask=0 sets everything in the file system to world writeable,
so that anyone can write to it.
I hope that this points you toward a solution.

Jim
 
Old 11-03-2008, 02:36 PM   #10
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Original Poster
Rep: Reputation: 18
Success! I changed my etc/fstab file from umask=0022 to umask=0, but had to go one extra step: mounting the filesystem as normal, "mount /dev/hdb1" (or not so normal; hitherto I always ran "mount -t vfat /dev/hdb1 /media/hd") I still got the same old permissions when running ls-l. I checked the man page for mount and saw this option:

-f Causes everything to be done except for the actual system call;
if it's not obvious, this ‘‘fakes'' mounting the file system.
This option is useful in conjunction with the -v flag to deter‐
mine what the mount command is trying to do. It can also be used
to add entries for devices that were mounted earlier with the -n
option. The -f option checks for existing record in /etc/mtab
and fails when the record already exists (with regular non-fake
mount, this check is done by kernel).

I faked a mount (mount -f /dev/hdb1), and so was then able to change group and user ownership of the files in /hd (chown -R stuart:stuart hd), and write the fstab changes, I guess because my drive was not invoked as it would have otherwise been with a regular mount. Because mount was faked, strictly, the files and directories weren't at the the hd mount point at this time, but I guess a flag was set (think that's the right term), so that when I did mount proper, the permissions had been altered as expected, (rwxrwxrwx as per umask=0). Group and user ownership changed at ls-l too, but only a further umount and mount later. (though making this change was actually pointless after changing the umask value, but I forgot this at three in the morning!)

One side effect: I now have all green text at listings (ls) within the hd directory, and rather blue directory names, it's blue but 'green-blocked'. Anyone? Should I be concerned?

Still not 100% sure on the rationale as descibed by man page excerpt, so if anyone understands this well, i'd like to know myself.

NirvanaII
 
Old 11-03-2008, 03:11 PM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You use the uid= and gid= mount options to change the ownership (when mounted). You don't use chmod or chown after mounting. You can also use the fmask= and dmask= mount options to change the permissions. These options are global. The ownership and permissions of all the files on the filesystem will be the same. There is a separate dmask option because you need the 'x' bit set for directories. It isn't advisable to have the 'x' bit sit for file.

Other Options:
If this is an external drive, consider running "udevinfo -q env -n /dev/hdb1" to get the UUID number of the filesystem. It is better to use
UUID=<uuid number> in the /etc/fstab entry. An external device could be assigned a different device node the next time. Also use the "noauto" option. This will prevent problems when booting if the device isn't connected. If you use the "user" or "users" option, in combination with the uid=<yourusername> option, you will be able to mount the device as a regular user. For pendrives, also use the "noatime" option to reduce the number of writes to the device.

Good Luck!
 
Old 12-06-2008, 08:08 PM   #12
NirvanaII
Member
 
Registered: Jun 2005
Posts: 139

Original Poster
Rep: Reputation: 18
Only a follow up to say the whole business of faking a mount is needless, I mention this only because I learnt this recently and don't want other new (to Linux) people reading this post thinking it is.

As you were.

NirvanaII
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chown v/s chmod justmovedtolinux Linux - Newbie 3 10-02-2008 06:43 AM
chmod chown permissions not working operation not allowed UMG:Chicken_Soüp Slackware 1 11-06-2007 12:15 AM
chown and chmod specialized Linux - Hardware 9 04-04-2006 09:26 PM
Chmod ,chown ,chgrp commands not working proper---------------- pal Linux - Newbie 12 03-07-2005 09:55 AM
Understanding chmod, chown mikemrh9 Linux - Newbie 4 11-19-2004 03:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva

All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration