Suse/NovellThis Forum is for the discussion of Suse Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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
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:
usb 3-1: new full speed USB device using address 2
Initializing USB Mass Storage driver...
scsi2 : SCSI emulation for USB Mass Storage devices
Vendor: TwinMOS Model: Mobile Disk Rev: 1.11
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sdb: 258048 512-byte hdwr sectors (132 MB)
sdb: assuming Write Enabled
sdb: assuming drive cache: write through
Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0
Attached scsi generic sg1 at scsi2, channel 0, id 0, lun 0, type 0
USB Mass Storage device found at 2
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
In this example it shows you that the pendrive is on USB bus 2 and has the device /dev/sdb with one partition sdb1. So the first entry in fstab would be /dev/sdb1
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.
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?
Last edited by apachedude; 12-02-2004 at 04:57 AM.
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 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.