Editing fstab to mount devices?
I'm having some inconsistencies getting SuSE to mount my USB devices (two pen drives and a flash card reader among other things). I understand that the fstab looks something like that
First of all, I have several USB devices--how do I know whether to enter the first string as "/dev/sda" or "/dev/sda1", "/dev/sda2" or the like?
The second, I understand, is wherever I want to mount my device too, and is rather arbitrary. Do I create this folder beforehand? What chmod permissions should I assign to it?
The third part "vfat" I don't understand. Some of my devices are subfs. Is there any difference? I have already set HOTPLUG_USE_SUBFS=no in /etc/sysconfig/hotplug.
The fourth part I don't understand either. Do I just copy it directly?
Thanks for your help in anticipation.
this a extract from a help page i wrote for my LUG
First of all you need to see which partition you want to mount
YOU can see that by running the following command at bash# prompt
If your hard disk is use
Primary master hda
Primary slave hdb
Secondary master hdc
Secondary slave hdd
USB device sda
If you use wrong device then you may get error message such as
"Cannot open device hdc"
If command is successful you get
[root@gaurav qmail]# fdisk /dev/hda
The number of cylinders for this disk is set to 4865.
There is nothing wrong with that, but this is larger than 1024,
And could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help):
At this prompt run ‘p’ single character to see your partition table
Here is the result of my partition table
Command (m for help): p
Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 561 4506201 b Win95 FAT32
/dev/hda2 562 3939 27133785 f Win95 Ext'd (LBA)
/dev/hda3 3940 4385 3582495 a5 FreeBSD
/dev/hda4 4386 4865 3855600 83 Linux
/dev/hda5 562 1096 4297356 7 HPFS/NTFS
/dev/hda6 1097 1606 4096543+ b Win95 FAT32
/dev/hda7 1607 3008 11261533+ b Win95 FAT32
/dev/hda8 3009 3872 6940048+ b Win95 FAT32
/dev/hda9 3873 3939 538146 b Win95 FAT32
You can easily recognize which drive you want to mount
Here I have my windows partitions as
devices Windows Partitions
Do not confuse with /dev/hda2
It is my extended partition you cannot mount that whole partition but you can only mount the logical drives in this partition
Here say if I want mount my E drive in Linux
I need to have an empty folder somewhere to mount.
We can make a folder anywhere but as going by the convention we make all the folders and mount them in
So, go to the mnt folder under root directory
Make a new folder in mnt directory say win_e
If you want to mount it temporarily (till the system is running)
You can mount it by the following command
#mount /dev/hda6 /mnt/win_e
The syntax of the command is easy to interpret
/dev/hda6 gives the device you want to mount
/mnt/win_e gives the path of folder you want to mount
Now if you want to mount your partitions your drives permanently you can do that by making an entry in /etc/fstab file
This file is read each time the system boots.
And so it mounts the partitions listed in this drive
You can add an entry to this file as under corresponding headings
/dev/hda9 /mnt/win_h auto defaults 0 0
for more options
1. The device:
The first USB device that you plug in gets the first free SCSI device (seems to be sda in your case, in my case it is sdb since my HDD is sda). The numbers are specifying the partition on the device. There should always be a partition specified in /etc/fstab. Mostly there is one on a pendrive, however in some cases four partitions are recognized.
To find out which device is used and how many partitions are on that device, type dmesg on console, ahort after you have plugged in the device. The last few lines should give you the desired information:
2.: The mountpoint:
Create the folder wherever you want before you attempt to mount the device, usually you shouldn't worry about the permissions.
3.: The filesystem:
You wonder why it shouldn't be subfs? Because you switched it off as you said (HOTPLUG_USE_SUBFS=no). But you may use auto, if you are not sure how the drive was formated.
4.: The options:
Here you should have a look in 'man fstab'. There are too many option to explain them here. For FAT32 and NTFS devices you should always set the umask=000 option to be able to access the data as normal user. This is because windows fs do not know how to deal with unix permissions and umask is kind of translation. noauto means that the system does not try to mount the device on boot (since it may not be there). users allows all users to unmount the device, even if they did not mount it. user would mean that only the user who mounted the device is allowed to unmount it. rw means writable access. The two 0 also have a meaning related to checking the filesystem, but I am not sure about that.
Thanks for your help, guys
I read your posts. I'm not going to try to mount tonight--it's already 2:33 a.m. (02:33) where I live. However, one question: if I do set up the mounting of the USB drives correctly, can I just pull them out, and expect the kernel to unmount the drive for me?
For instance... I have a SanDisk and a Lexar USB drive.
Suppose I plug in SanDisk first, then Lexar. That would give SanDisk sda and Lexar sdb, right?
Now suppose I take them both out, then plug them Lexar, then SanDisk. Would the orders reverse? Or would SanDisk still be sda?
Would it even matter? Let's suppose I just use sda to refer to whatever device I put in first. Would the fact that sda might point to a key drive, a memory card, or a Palm make any difference to the mounting of the device?
Of course, this last issue technically doesn't matter but suppose I mount sda to /mnt/sandisk. Now, the kernel doesn't really care whether or not the device is really the SanDisk drive. But it might confuse me, if say, I had my Palm connected first. Should I name it something vague like /mnt/usb-device? I guess what I'm really asking is how can I name my mounting points consistently with the actual devices, regardless of the order in which I plug them in.
Edit: while I'm at it, is there a difference between fstab and mtab? If so, do I need to edit mtab too to mount my devices?
1. You should always unmount before unplugging them, especially if you did write operations on the device. Such operations may have been buffered and not performed by the time you pull out the device. I don't know if the protocolls have changed meanwhile (so that the system recognizes a removable source and performes all write operation immediately), but to be on the safe side, you should always unmount. Even if you would use submount, the window that is giving access to the drive should be closed to ensure unmounting.
2. I guess the way you do it would lead to a reverse order of the drives. However if you use submount/subfs, a specific ID will be assigned to the device (some kind of hardware encoded) and it will be mounted always to the same mountpoint.
3. I don't know, but I think it should be possible. Has something to do with the hotplug scripts.
I got the USB key drives working properly with /dev/sda1. I can interchange them (pull one out, put the other one in) and it will mount the next time I access it. This is if I assign /dev/sda1 to a hard disk device.
Now, as I said, this will work with either of my USB key drives. However, this does not work if I take out the USB key drives and plug my flash memory card reader. I ran dmesg, and apparently, it points to either sdb, sdc, or sdd--it is not consistent in regard to where the drive mounts. And once I put the USB flash memory card reader in, it screws up the mounting point for my USB drives. So if I put in a flash memory card reader, then I pull it out and plug in a USB drive, it fails to point to /dev/sda1 anymore. Anyway to resolve this?
I'm not sure this is taking me in the right direction. I followed the instructions in an earlier thread, thinking I'd get the desired results.
Now, I didn't articulate these results I wanted very well, but I believe I was more clear in that post above (to which I linked).
I don't believe I am saying this, but maybe you should re-enable submount.
Usually submount causes more problem than it make live easier, but in your case with many different devices, it might be the better alternative.
Another idea, that includes some scripting:
Kernel 2.6 uses udev to create devices in /dev. This is controled by some scripts that are in /etc/udev. I found a brief description how to tell udev which device it has to create for which hardware. Currently, SuSE uses the script /sbin/udev.get_persistent_device_name.sh, but you could easily assign device names yourself, if you know the vendorID of your hardware.
Here is the link: http://tldp.org/HOWTO/Flash-Memory-HOWTO/linux-2.6.html
The interesting part starts at 12.4.2
Hope this helps !
|All times are GMT -5. The time now is 02:17 PM.|