[Home]  [Links]  [grouch] 

Filesystem tips

The Linux ext2 filesystem is alien to many new users. Coming from Windows, it's hard to get used to things like no drive letters and a logical separation of system, application, and user files. It's also hard to get used to the ability to upgrade at will with little or no cost and the available multitude of distributions to try out. You can make it easier on yourself if you are armed with a little information.

For background on the current filesystem standard (FSSTND), see http://metalab.unc.edu/pub/Linux/docs/fsstnd As of now, the file is fhs-2.0.tar.gz

Since the Filesystem Hierarchy Standard was worked out with the cooperation of developers, system administrators and distributors, your chosen distribution most likely adheres to it. The standard has flexibility built in, so there may be some variance. The main directories are very unlikely to be different.

The first thing you should be concerned about is where your stuff resides. It begins under /home and you should keep it there. Having /home on a separate partition makes it very easy to keep your files (and your users' files, if you run a multiuser system) backed up and untouched if you decide to install a different distribution or other radical change in the system. There should be a directory under /home with your user name on it. If you're the root user of the system, you will also own the directory /root. Insist that your programs such as word processors store your files in your directory. One way to get most to use this as the default is to operate from your home directory. Just cd ~ to go home.

Binaries (executable programs) will typically be found in /bin, /sbin, /usr/bin, /usr/sbin/, /usr/X11/bin (or /usr/X11R6/bin), or in similar directories under /usr/local. This may at first seem to deny the existence of a standard, but you will soon get the feel for it.

If you're coming from Windows, you most likely have some documents or other files you want to access while in Linux. This is the time to learn about the mount command. You start with your / directory and mount filesystems at some mountpoint (directory) on this. The general form of mount most used is

mount -t <filesystem type> <device name> <mountpoint>

An example:

mount -t vfat /dev/hda1 /mnt/win95/drive_C

In this case, the type is vfat (FAT32), the device is the first partition on the first hard drive, and the mountpoint is a directory under /mnt. The mountpoint must exist before mount will succeed. The mkdir command is your friend. Try to keep things logical.

From FHS 2.0:

/ -- the root directory
+-bin    essential command binaries
+-boot   Static files of the boot loader
+-dev    device files
+-etc    Host-specific system configuration
+-home   User home directories
+-lib    Essential shared libraries and kernel modules
+-mnt    Mount point of temporary partitions
+-opt    Add-on application software packages
+-root   Home directory of the root user
+-sbin   Essential system binaries
+-tmp    Temporary files
+-usr    Secondary hierarchy
+-var    Variable data

You can see from this that the / directory is and should be a list of subdirectories. Don't fill it up with files you download from the Internet. Put such things in a reasonable place, such as /home/ftp/pub/ or your home directory.

Keep your directory structure logical. This is especially important in a networked environment where directories may be shared among hosts. Even in a stand-alone system you can soon lose control or track of files unless you establish the habit of keeping things logical and as nearly FSSTND compliant as you can.