Filesystem Management

Mounting Filesystems

Before a filesystem becomes accessible to the operating system, it must be mounted into a certain directory. For instance, if a filesystem exists on a floppy disk, then, in order to gain access to its files, it must be mounted, for example, into the /mnt/floppy directory. This directory from now on is called a mount point. After this, the filesystem is mounted, all its files can be found in the corresponding directory. After unmounting of the filesystem, the directory becomes empty.[6]

The same is true of the filesystems located on a hard drive. The so-called root filesystem is mounted into the / directory. If a separate filesystem /home is present, then it is mounted into the /home directory. If only the root filesystem is present, then all files (including those in the /home directory) are located in it. The operating system automatically mounts filesystems located on hard drives during startup. Filesystems on removable media (such as floppy disks, CD-ROM's, etc.) are also in most cases mounted automatically by the automount program.

The mount and umount (not unmount) programs are used for mounting and unmounting of filesystems. The command mount -av is executed automatically during system startup. Information about filesystems and mount points is stored in the /etc/fstab file. An example of /etc/fstab is given below:

# device         directory      type     options
#
/dev/hda1         /             ext3     defaults
/dev/hda2         /home         ext3     defaults
/dev/cdrom        /mnt/cdrom    auto     user,noauto,ro
/dev/hda4         none          swap     swap
/proc             /proc         proc     none

The first field (device) stores the name of the partition that needs to be mounted. The second field is the mount point. The third field is the filesystem type, auto in this case means that the type of the filesystem is to be determined automatically. The last field contains mounting options. These are often set to their default values. In the example given, the option user means that the filesystem may be mounted by a regular user (by default this is a privilege of the superuser), noauto means that the filesystem will not be mounted automatically during system startup. More details about these options may be found in the manpage of the mount command. Types of filesystems supported in ALT Linux 2.3 Compact are listed below:

Ext2

This is the most traditional for Linux and most stable of all the available filesystems, but it is not journalized, i.e. in case of a power failure all the data not written to the disk will be lost and errors in the filesystem may appear. That is why after a power failure a filesystem check needs to be done with fsck.

Ext3

A journalized extension of Ext2, well-compatible with Ext2. Ext2 can be easily transformed into Ext3 using tune2fs -j /dev/hdXN command. For a reverse transformation, it is sufficient to mount this partition as Ext2.

ReiserFS

A journalized filesystem, optimized for directories containing large numbers of files, as well as for small files. It is recommended to use version 3.6 for 2.4.x kernels at the present moment.

ISOFS

Used for CD-ROM media.

UDF

Used for DVD-ROM media.

VFAT

Used in Microsoft Windows 9x and Microsoft Windows Me operating systems.

NTFS

Used in Microsoft WindowsšNT and Microsoft Windows XP operating systems. At the present time, only read-only support of this filesystem is available.

ISOFS and UDF filesystems are used for CD/DVD-ROM devices; VFAT and NTFS are used by the Microsoft OS family.

The file /etc/fstab also includes data about swap sections. Their mount point is none (i.e. they are not mounted), their type is swap.

The file /etc/fstab contains one special record for the /proc filesystem. This filesystem contains data about processes running in the system, about available memory etc. If the /proc section is not mounted, then such commands as ps will not work.

Filesystem Checkup

In Compact the filesystems are automatically checked up for corrupted files during startup if necessary. It is also done on schedule for preventive purposes. But in some cases it is necessary to run a filesystem check manually: to do this, the command fsck /dev/hdXN needs to be entered. It will then automatically determine the type of the filesystem being checked and execute the required command.

Before running a check, it is useful to unmount the filesystem. It is absolutely necessary to do this if the fsck program is going to perform any kind of repairs in the filesystem.



[6] In ALT Linux distributions, floppy drive mounting is by default done by the automount service, which automatically does the mounting routine when you try to access a removable media drive.