LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   change permissions of the second hard drive (https://www.linuxquestions.org/questions/linux-hardware-18/change-permissions-of-the-second-hard-drive-511493/)

jmding 12-18-2006 12:07 AM

change permissions of the second hard drive
 
I have two 160G hard drives. On the first one, I have two operating system: windows XP(pro) and Linux Red Hat. The second hard drive is only available in XP or root under Linux. as a common user in Linux, the second HD is only readable but not writable. I had tried to login as root and change the permission by chmod. But it didn't change anything.

For example: (/DATA is the folder of second HD)

ls -l /DATA
total 288
drwxr-xr-x 2 root root 32768 Nov 28 23:07 ancova
drwxr-xr-x 9 root root 32768 Nov 29 13:03 multi
drwxr-xr-x 9 root root 32768 Oct 11 13:41 oldbackupUCD
drwxr-xr-x 11 root root 32768 Nov 15 09:25 paper
drwxr-xr-x 3 root root 32768 Nov 23 16:24 projects
drwxr-xr-x 2 root root 32768 Sep 29 13:09 Recycled
drwxr-xr-x 3 root root 32768 Sep 28 12:49 System Volume Information
drwxr-xr-x 4 root root 32768 Oct 1 17:20 teaching
-rwxr-xr-x 1 root root 8 Dec 17 19:38 test.txt

When I type:
chmod o+w /DATA/test.txt
ls -l /DATA
............
-rwxr-xr-x 1 root root 8 Dec 17 19:38 test.txt

Nothing changed ???

Any suggestion?

I googled for a while and it seems that if I change /etc/fstab, it might be helpful. But I don't know how to change it. Here is my current /etc/fstab:

This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0
/dev/hdb /media/cdrom auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/dev/hda /media/cdrecorder auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0

jschiwal 12-18-2006 12:30 AM

I'm guessing that the second drive is formatted as a single NTFS partition. It isn't listed in your /etc/fstab.

If it is an ntfs partition, you determine the permissions for the entire partition when you mount it. You can use the "umask=" option, or use separate "fmask=" and "dmask=" options. The second options allows read-only access for files and "rx" permissions for directories. You can also use the "uid=youusername" and "gid=yourgroup" to change the ownership of the drive.

If the drive is formatted using the fat32 filesystem, then use the filesystem type "vfat" in your fstab line. Like ntfs, the permissions on the partition are set globally when the partition is mounted. You can have write access however.

You can read through "man mount" for more options, and general instructions. If you have the kernel source and kernel-docs packages installed, there is a ntfs.txt file in the kernel source.

jmding 12-18-2006 12:39 AM

Sorry I am really new to Linux and I have spend all my this week on googling help :( Could you tell me how to tell whether it is fat or ntfs? And whether it should be /dev/hda ? or /dev/hdb?
or /dev/hdc? Any example lines?

Thanks!!!

jschiwal 12-18-2006 02:19 AM

Run as root: fdisk -l
This will list all of your drives and partitions.

( You caught me when I rarely reboot my laptop into Windows to keep up with the updates. No problem, I just used cygwin to ssh into the desktop for an example. )

My fstab entry may look different because Red Hat and FC like to use labels. Anyway, this is how the entry for my Windows XP partition is mounted:
Code:

/dev/sda1      /windows/C      ntfs    uid=jschiwal,gid=jschiwal,ro,defaults,umask=0002,utf8=true 0 0
Your devices are probably different. If the drive is the second ide drive it is probably /dev/hdb and the first partition is /dev/hdb1. However if you partitioned it as an extended partition, then it probably is /dev/hdb5.

jmding 12-18-2006 02:55 PM

You are right that my second hard drive is NTFS (partition type). But the file system is vfat32, since it is shared with windows.
When I type df -k it shows:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 124928728 11072652 107510000 10% /
none 2073360 0 2073360 0% /dev/shm
/dev/sdb1 156242112 11787648 144454464 8% /DATA

So sda2 is the linux on the first hard drive and sdb1 is the second HDD.
But still I don't have those lines in /etc/fstab, so how should I change the fstab file?

BTW, I am using Red Hat.

jschiwal 12-18-2006 08:40 PM

NTFS and FAT32 are two distinct filesystems. I already included a sample line from my desktop for reading an NTFS formatted partition.

For a fat32 drive you could use something like this:
sudo mount -t vfat /dev/sda1 /mnt/ -o defaults,uid=jschiwal,umask=0007
to mount it manually or add a line like
/dev/sda1 /windows/D vfat defaults,uid=jschiwal,umask=0007 0 0
to /etc/fstab. This is for a usb flash drive on my laptop. Use your own username of course, and you can select a different mount point.

The man mount command will give more options. For a flash drive, if it were using a different filesystem that stores individual inodes on the filesystem itself, using noatime would be recommended. Reducing the number of writes can extend the life of flash memory. Sometimes the noatime option is used on servers to speed up access.
For removable drives, you would want to use the noauto option. Then the device won't be mounted at boot automatically with the "mount -a" command. So if the device isn't plugged in, it won't cause booting to fail.

jmding 12-19-2006 03:42 PM

Thanks! I got this problem solved under your help. In fact, my second hard drive is automatically mounted in the file /etc/rc.d/rc.local and adding a line in /etc/fstab doesnot work (it says too many mount... during booting). So I add the uid=jmding in that file. But umask does not work there. So I still cannot give permission to group. But at least I have the ownership now :) Thanks again!


All times are GMT -5. The time now is 03:13 PM.