ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Making the Switch-04: The "User Guide" as life raft, more n00b problems

<< < (3/4) > >>

Gothi[c]:
typing in: man fstab
at the command prompt will give you lots of information explaining how that file works, in detail, but i'll have a shot at it,...

As you know, the concept of a C-drive, D-drive, or drive letters in general does not exist. In windows, hard drives, cd's and even floppy disks also have to be `mounted`, but all this goes on behind the scenes, and the user is unaware of it. Windows (and DOS) will automatically assign drive letters to any drive it finds, and automatically 'mount' the drive on these 'drives'.

In linux, a drive, partition, or filesystem( could be an .iso image too for example ) can be mounted in any directory, and drive letters don't exist.
When the kernel (the core of the operating system) starts up, it will first see if any parameters were given along with it's startup (there is a root parameter which you can pass to the kernel in a boot loader, to tell it which drive/partition/filesystem should be mounted as 'root' filesystem). When referring to the 'root' filesystem, I am referring to the filesystem on which the directory / and all it's subdirectories are located. After mounting this filesystem, it will continue booting up, running what is called 'init' scripts which start different programs required on startup. And it will also check the /etc/fstab file to see which other filesystems it must mount. So naturally this file is of great importance to linux.

Lets look at a typical fstab file:


--- ---/dev/VolGroup00/LogVol00 /                      ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
sysfs                   /sys                    sysfs   defaults        0 0
/dev/sdb1   /media/windows ntfs    uid=500,gid=500,user                  0 0
/dev/cdrom  /media/cdrom   iso9660 ro,user,noauto,unhide,uid=500,gid=500 0 0
/dev/VolGroup00/LogVol01 swap                   swap    defaults        0 0

The first column on each line, tells linux where to FIND the filesystem. Typically this will be something like /dev/sdb1 or /dev/hda1 etc,... (SATA drives are labeled as sda,sdb,sdc,etc,... IDE harddrives are labeled as hda,hdb,sdc,etc,... followed by the partition number)
The second column on each line tells linux where to MOUNT the filesystem. This is where you will find the files on that particular partition.
The third column on each line tells linux what TYPE of filesystem it is. (eg: ext2, ext3, ntfs, fat32, etc,...)
the Fourth column is for any additional OPTIONS you with to pass when mounting the filesystem (such as whether or not it should be allowed for regular (non-root) users to mount the partition, and what the default file permissions would be.
The last two columns (0 0 or 0 1 or 1 1 etc) are parameters telling how frequently that particular filesystem should be checked for errors on startup.

The particular example above may look a bit strange, because it uses LVM (Logical Volume Management) (see http://en.wikipedia.org/wiki/Logical_volume_management ) This is why you see stuff like the volgroup lines in there.

The devpts, tmpfs, procfs, and sysfs mount points are special directory trees containing information on running processes, hardware, temporary files, etc,...
For example, when you type the following command:

cat /proc/cpuinfo

Various information about your CPU will be shown. This just goes to show that ANYTHING can be treated as a filesystem and can be mounted.

I really hope this clears up at least a little bit,... Please be brave, strong, and don't be intimidated by any of this to stop learning! It really isn't half bad once you get the hang of it! I understand it's easy to be overwhelmed, because there are vast culture differences between Windows and Linux. There may or may not be some GUI applications out there that update the fstab file automatically, but I still think it's important to know what goes on behind the GUI, because at least then you know what to do if the GUI doesn't work ;)

Gothi[c]:
You're probably better of using fdisk to determine what the name of the device of your second drive is, Zaine, because it shows more information about the filesystem... eg:


--- ---sudo fdisk -l
Password:

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       30401   244091610   8e  Linux LVM

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       19456   156280288+   7  HPFS/NTFS

As you can see, it also shows whether or not a filesystem is NTFS or ext3 or whatever else. (I use LVM though)
So if i wanted to add a line for my windows drive, I know windows uses NTFS, so i know the device would be sdb1 so the line to add in fstab, would have /dev/sdb1 in it's first column.

Edvard:
Zaine: Maybe it is easier to imagine taking a disk labeled '/dev/somedisk' and plugging it into a directory labeled '/mnt/somefolder'. That's the dirty basics of what you are doing. You can't just access the disk as it is, it has to have a place to sit so it can interact with you.
In windows it would be something like IDE (or SATA) plug-in #1 "mounted" at C:/

If you're up for more reading, go here: http://www.tldp.org/guides.html

That first book "Introduction to Linux" is a good one. Read the chapter on filesystem management and the 'mount' command.

Darwin: The same goes for you, but check out the "GNU/Linux Command Line Tools Summary" and "BASH Guide for Beginners". There are a lot of tricky things going on in that little black box that whips the pants off cmd.exe.

Also check out Linux 101 at Linux.org: http://www.linux.org/lessons

For further brain melting, check out why the device filesystem underwent radical change between kernel 2.4 and 2.6:
http://www.kroah.com/linux/talks/ols_2003_udev_paper/Reprint-Kroah-Hartman-OLS2003.pdf
I like the idea of a dynamic /dev directory that lists only those devices detected, but all of a sudden all my hard drives are detected and mounted as scsi devices (for example, my shared drive, formerly /dev/hdb1 is now /dev/sdb1) ????

Tonurics: thanks for the tip on mounting a disk by UUID. An update breaking my mountpoint is exactly what happened. I fixed it in /etc/fstab as I described above, but I've been worrying about what will happen next time.

Darwin:
Thanks Edvard, that explanation helped me, a bit, anyway!

Tonurics:
That is weird the system only reported the one disk UUID... I still recommend trying to use the virtual symbolic links since they should never change between distributions or kernel updates.

I don't like it as much as it goes by the disk serial number but use this: ls -l /dev/disk/by-id/

It should out put something like this:

lrwxrwxrwx 1 root root  9 2007-06-19 08:41 scsi-1ATA_ST3160021A_5KJ2348LN -> ../../sdb
lrwxrwxrwx 1 root root 10 2007-06-19 08:41 scsi-1ATA_ST3160021A_5KJ2348LN-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  9 2007-06-19 08:41 scsi-1ATA_ST3160022A_5VX84HJB -> ../../sda
lrwxrwxrwx 1 root root 10 2007-06-19 08:41 scsi-1ATA_ST3160022A_5VX84HJB-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 2007-06-19 08:41 scsi-1ATA_ST3160022A_5VX84HJB-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 2007-06-19 08:41 scsi-1ATA_ST3160022A_5VX84HJB-part5 -> ../../sda5

You'll need to identify the first partition on your second disk, in my cause that is scsi-1ATA_ST3160021A_5KJ2348LN-part1 which you'll want to use in place of hdb1 (sdb1 in my case).

Since you should already have the /mnt/2drive folder in place, your next command would be (change the disk id to match yours): sudo mount /dev/disk/by-id/scsi-1ATA_ST3160021A_5KJ2348LN-part1 /mnt/2drive

And you should be able to read and write to your second disk by going to /mnt/2drive.

For your fstab you would put (again use your disk id): /dev/disk/by-id/scsi-1ATA_ST3160021A_5KJ2348LN-part1 /mnt/2drive ext3 defaults 0 2

That should be it. I don't know where you are getting the rest of your information from but /dev/mapper/ is a container for _special_ file systems, such as in the case of on the fly encryption using luks, you would unlock your encrypted disk and have luks create a virtual device in /dev/mapper/ for you to mount with (as if it was a normal hard drive).

Even by switching to KDE your keystrokes here for mounting disks would be the same... However, I know Kubuntu has a easy to use GUI file system management tool similar to the one in windows that would let you do all of this without having to use the shell or edit fstab manually. Since you are just getting started with learning Linux, it might be better for you to stick with GUI tools for these sort of processes. The worst thing is for you to get needlessly frustrated with trying to learn a small manual process when there are tools to do this for you, and ultimately have a negative experience. Last time I'll say it, but to reiterate my KDE suggestion, if you are a windows user, KDE is still a world of difference but with a similar methodology. Personally (not to start a flame war of anything), I think gnome looks great with wonderful fonts and themes, but mind numbingly irritating to use. :)

Since then, here's what I've done:

              ls -l /dev/disk/by-uuid/

which returned:

              total 0
              lrwxrwxrwx 1 root root 10 2007-06-14 04:36 6068b6ae-9b08-4ce9-a6fe-08add83228c0 -> ../../sda1

So I did the following:

              mkdir /mnt/2drive

Open fstab file and added this line:

              /dev/hdb1 /mnt/2drive ext3 defaults 0 0

__________________________________
I read this, but I didn't understand the following command:

              mount /dev/mapper/<other_thing> /<mountpoint_directory>

What is the "other thing"?

Oy, nothing. Maybe I should consider doing this under KDE as Tonurics suggests. Gnome is making my tiny dinosaur brain hurt.
-zridling (June 14, 2007, 09:06 PM)
--- End quote ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version