< Overview of the file >
Of course everybody has a bit different /etc/fstab
file because the partitions, devices and their properties are different on different systems. But the basic structure of fstab
is always the same. Here's an example of the contents of /etc/fstab
:
/dev/hda2 | / | ext2 | defaults | 1 1 |
/dev/hdb1 | /home | ext2 | defaults | 1 2 |
/dev/cdrom | /media/cdrom | auto | ro,noauto,user,exec | 0 0 |
/dev/fd0 | /media/floppy | auto | rw,noauto,user,sync | 0 0 |
proc | /proc | proc | defaults | 0 0 |
/dev/hda1 | swap | swap | pri=42 | 0 0 |
What does all this gibberish mean? As you see, every line (or row) contains the information of one device or partition. The first column contains the device name, the second one its mount point, third its filesystem type, fourth the mount options, fifth (a number) dump options, and sixth (another number) filesystem check options. Let's take a closer look at this stuff.
< 1st and 2nd columns: Device and default mount point >
The first and second columns should be pretty straightforward. They tell the mount
command exactly the same things that you tell mount
when you mount stuff manually: what is the device or partition, and what is the mount point. The mount point specified for a device in /etc/fstab
is its default mount point. That is the directory where the device will be mounted if you don't specify any other mount point when mounting the device.
Like you already learned from the Mounting tuXfile, most Linux distros create special directories for mount points. Most distros create them under /mnt
, but some (at least SuSE) under/media
. As you probably noticed when looking at the example fstab
, I use SuSE's mount points as an example.
What does all this mean? If I type the following command:You can freely change the default mount points listed in
/etc/fstab
if you're not satisfied with the defaults your distro has given you. Just make sure the mount point is a directory that already exists on your system. If it doesn't, simply create it.
nbsp;mount /dev/fd0
... my floppy will be mounted in /media/floppy
, because that's the default mount point specified in /etc/fstab
. If there is no entry for /dev/fd0
in my fstab
when I issue the command above, mount
gets very confused because it doesn't know where to mount the floppy.
You can freely change the default mount points listed in /etc/fstab
if you're not satisfied with the defaults your distro has given you. Just make sure the mount point is a directory that already exists on your system. If it doesn't, simply create it.
Some partitions and devices are also automatically mounted when your Linux system boots up. For example, have a look at the example fstab
above. There are lines that look like this:
/dev/hda2 / ext2 defaults 0 0
/dev/hdb1 /home ext2 defaults 0 0
As you've learned, these lines mean that /dev/hda2
will be mounted to / and /dev/hdb1
to /home
. This is done automatically when your Linux system boots up... if it wouldn't, you'd have a hard time using your cool Linux system because all the programs you use are in / and you wouldn't be able to run them if / wasn't mounted! But how does the system know where you want to mount /dev/hda2
and /dev/hdb1
? By looking at the /etc/fstab
file of course.
< 3rd column: Filesystem type >
The third column in /etc/fstab
specifies the filesystem type of the device or partition. Many different filesystems are supported but we'll take a look at the most common ones only.
ext2 and ext3 Very likely your Linux partitions are Ext3. Ext2 used to be the standard filesystem for Linux, but these days, Ext3 and ReiserFS are usually the default filesystems for almost every new Linux distro. Ext3 is a newer filesystem type that differs from Ext2 in that it's journaled, meaning that if you turn the computer off without properly shutting down, you shouldn't lose any data and your system shouldn't spend ages doing filesystem checks the next time you boot up.
reiserfs Your Linux partitions may very well be formatted as ReiserFS. Like Ext3, ReiserFS is a journaled filesystem, but it's much more advanced than Ext3. Many Linux distros (including SuSE) have started using ReiserFS as their default filesystem for Linux partitions.
swap The filesystem name is self-explanatory. The filesystem type "swap" is used in your swap partitions.
vfat and ntfs Your USB stick is most likely formatted as Vfat (more widely known as FAT32). Your Windows partitions are probably either Vfat or NTFS. The 9x series (95, 98, ME) all use Vfat, and the NT series (NT, 2000, XP, Vista, 7) use NTFS but they may be formatted as Vfat, too.
auto No, this isn't a filesystem type :-) The option "auto" simply means that the filesystem type is detected automatically. If you take a look at the example fstab
above, you'll see that the floppy and CD-ROM both have "auto" as their filesystem type. Why? Their filesystem type may vary. One floppy might be formatted for Windows and the other for Linux's Ext2. That's why it's wise to let the system automatically detect the filesystem type of media such as floppies and cdroms.
留言列表