LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 05-17-2004, 07:38 AM   #1
Lifix
LQ Newbie
 
Registered: May 2004
Distribution: Suse 9.1
Posts: 3

Rep: Reputation: 0
New Linux user, need help with a second hard drive


First of all I would like to say Hi to everyone here!

Okies, my problem. I am currently running a IBM X40, dual booting winxp and suse9.1. I have one bay in the dock and I switch a dvd-cdr combo drive in and out with a 80 gig hard drive. Before I installed Linux, I killed the NTFS partition on the drive and left it unpartitioned. When I booted up linux, it found the drive, and I partitioned it Fat32. Now to my problem:

The permissions are all screwed up. I have tried everything I can think of. The obvious stuff: Logged in as root and changed all the permissions (they didn't save) | Changed the Owner (didn't save) | Had a friend who knows linux chmod 777 . (i believe was the command) it. I also repartitioned it and made sure I didn't have any strange partition rules in it then. I could really use a link to a toutorial (I checked this site, and google) or a step by step to get it running. Thanks in advance, and thanks for your time.

Lifix.
 
Old 05-17-2004, 08:32 AM   #2
fdservices
LQ Newbie
 
Registered: Dec 2003
Location: France
Distribution: Mandrake 10.1
Posts: 8

Rep: Reputation: 0
You should read through the manual pages on fstab and mount.
Open a terminal and type "man fstab" and "man mount". You copuld also look at "man hd".

As with all linux be careful when you make changes to /etc/fstab, you could mess up the existing set up

I am a bit surprised Susie does not have a utility to install a new hd?
 
Old 05-17-2004, 10:52 AM   #3
Jimbo99
Member
 
Registered: Nov 2003
Distribution: Ubuntu 7.04
Posts: 241

Rep: Reputation: 31
I think his problem is with permissions and not with mounting/partitioning. He's asking about how to get his file security to work properly.
 
Old 05-17-2004, 10:53 AM   #4
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
FAT/VFAT/FAT32 (and FAT32X and so on...) does not support UNIX-style permissions such as the ones we use on the common Linux filesystems. To circumvent this you can mount the FAT partition with special options to indicate what permissions should be given to all files and directories on the drive.

Let's do this Linux style.
First we add a group to which we then will add users that should be able to read (and optionally write) to the Windows partition. I call this group "winread" but you can call it whatever you want. As root (type su to become root, and type exit when done to become your old boring self again) type the following to add a group called "winread":
groupadd winread

Very painless, don't you think?
Now open up the file /etc/group (still as root) with a text editor. At the bottom of the file you should see your newly created group, something like this:
Code:
windisk:x:408:
I'm not going to do Linux 101 here so let's just skip to what's important: The first field is the name of the group and the third field, with a number in it, is the group id, or gid. This is important so remember it. The fourth field, after the last colon, is empty right now. Here is where we put a list of usernames that we want to have access to the Windows partitions. The list is comma-separated (no spaces!), so I'm adding myself and you:
Code:
windisk:x:408:hw,lifix
Save the file and exit the editor.

Now we will change the way we mount our Windows partitions. Open up the file /etc/fstab in a text editor, but make a backup copy first! I keep files like this one in /root/backups/conffiles/ so I know I can roll back if I mess up (and with these files you really can mess up!). Find the line referring to your FAT32 partition that you want to have write access to. Linux calls FAT32 "vfat", so that's what you should be looking for. I assume you can find it since you're talking about weird permissions on it, and it wouldn't be mounted automatically if it wasn't in this file. Here's the one I want to mount nicely:
Code:
/dev/hda1               /mnt/win_e      vfat            defaults  0 0
The first line is the device (you can type fdisk -l /dev/hda to get a list of partitions on a disk, in this example I use /dev/hda but yours could be anything), the second is the mountpoint (where the contents of the partition will appear when mounted), the third is the filesystem type and the fourth is the mount options. The last two digits are for fsck and it doesn't matter to us in this case - use "0 0" for that.

Anyway, we want better permission, right? I will only touch the options part here since I feel the others are OK. Instead of defaults we add this:
Code:
noatime,user,gid=408,umask=007
"noatime" means the files shouldn't get their access times updated (Windows can get confused by this), "user" means users should be able to mount the partition, and here's the important two parts: "gid" is the group is of our group. Refer to your /etc/group file if you're uncertain. "umask" is the file mask for files and directories. 007 indicates that the owner (root) and group members (you and me in my example) can read, write and execute files and directories. Execute permission is needed on directories, otherwise you cannot list their contents. Users who are not root and who are not members of our winread group will have no acccess at all - they will not even be able to read files from the partition.

So, now our fstab line looks like this:
Code:
/dev/hda1               /mnt/win_e      vfat            noatime,user,gid=408,umask=007  0 0
Save the file and exit your editor. If the partition is mounted, unmount it by typing umount /dev/hda1 (replace /dev/hda1 with your actual device). In order for the group membership changes you need to log out and then log in again (no need to reboot, this isn't Windows ). You can type groups as yourself (not root) before logging out and after logging in again and you should see that when you're in again you are indeed a member of the winread group. Now you should have full access to your FAT32 drive.

I realize this is all kind of long winded and may appear a bit tricky but once you get used to group permissions it's very very usable and an effective way of granting or restricting access to services, files and so on.


Håkan
 
Old 05-17-2004, 01:32 PM   #5
Lifix
LQ Newbie
 
Registered: May 2004
Distribution: Suse 9.1
Posts: 3

Original Poster
Rep: Reputation: 0
Okies, before I go in and do all of that, the hard drive will be linux only, so how should I format it to get the permissions to work? Its not a drive I will want to access with windows.
 
Old 05-17-2004, 03:34 PM   #6
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Oh, since you formatted it as FAT32 originally I thought you would. Setting up a Linux disk in Linux is pretty straightforward:

1. Partition the disk. Type fdisk /dev/hdd (replace /dev/hdd with the actual device name). You will see a simplistic prompt. Press P to view the partitions or H to get help, W is the only option that actually writes the partition table to the disk so you can quit anytime using Q. Press N for new partition, number 1, set up size and so on...Type should be 83/Linux.

2. Choose your filesystem. I prefer journalling filesystems, ext3fs and reiserfs are the most common choices. To create an ext3 partition type mke2fs -j /dev/hdd (again, /dev/hdd is only an example), to use reiserfs type mkreiserfs /dev/hdd.

3. Create a mountpoint. This is the directory where you will access the contents of the partition. For storage I prefer /usr/local/storage or /mnt/storage but you can use whatever you like.

4. Set up /etc/fstab so the partition is mounted automatically. A simple example:
Code:
/dev/hdd1    /mnt/storage   reiserfs    noatime    0 0
Mount it using mount /mnt/storage or mount /dev/hdd1. That's it. Verify it's mounted using cat /etc/mtab or df -h to get usage information as well.


Håkan
 
  


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
user access to second hard drive.. jsheffie SUSE / openSUSE 6 11-01-2005 03:34 PM
user ntfs hard drive access problem Th3_J3st3R Slackware 4 08-28-2005 09:59 PM
External Hard Drive --No Access as USER only ROOT (10.1) 1kyle Mandriva 1 10-31-2004 09:09 AM
New Linux user, need help with a second hard drive Lifix Linux - Distributions 1 05-17-2004 08:02 AM
fat32 hard drive cant read as user bennythepitbull Slackware 3 10-30-2003 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:11 AM.

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