One of the first things you will notice when moving from a Windows machine to a Unix machine is that the data is laid out differently. You will notice that the directory separator is leaning the opposite direction. Windows uses the back slash and Unix uses the forward slash. Also, Windows assigns each disk and partition a letter. The floppy disk is the "A:" drive, the hard disk is the "C:" drive, and other letters are assigned as you partition or add storage devices.
Unix looks at all disks and storage devices as part of one filesystem. Storage devices are linked to the directory structure. The top of the filesystem is called the "root" directory and is represented by the forward slash
/. Each directory, starting with the root directory needs to have a storage device associated with it. A whole disk, or just a partition of the disk can be assigned to the directory. For example, the root directory is usually assigned between 30 to 50 megabytes of disk space.
Any subdirectories that are created will use the storage space assigned to their parent directory, unless they are assigned their own storage space.
So, the 30 megabytes assigned to the root directory will be used up extremely quickly, unless we assign some storage space to large directories such as
/home. It is possible to assign storage space to a subdirectory that is more than one level deep -- actually, you can assign storage space to any directory anywhere in the structure.
/ has 30 MB,
/usr has 1 GB, and you can assign
/usr/local 1 GB as well. That way, files such as
/usr/local wouldn't use storage space from
/usr. If you were running a cache server, you might assign a large amount of storage space to
/usr/local/squid/cache. In the current example, the directory
/usr/local/squid would use space assigned to
/usr/local because it hasn't been assigned its own, while
/usr/local/squid/cache would use the space that you assigned to it directly.
Before you can assign the disk space, you must first partition your disks. Dru Lavigne has an informative series on setting up your disks.
There are several things to consider when assigning storage space to a directory, and by now you should have an idea of how the Unix filesystem works. Luke A. Kanies gives a few suggestions on how to lay it out properly.
Even if you think you have your filesystem laid out properly, bits can pile up and partitions can start filling up. Michael Lucas shows us how to deal with things when your Unix filesystems start getting full.
There are a few directories that have special purposes. Among these are the
/dev directories. On Linux, in particular, the
/proc directory has some interesting features.
Unix is also capable of reading most other filesystems and if you are transferring from a Windows- or DOS-based environment, you will enjoy this article by Dru Lavigne about working with MS-DOS filesystems.
Good luck with your filesystem setup.
Chris Coleman is the Open Source Editor for the O'Reilly Network and is actively involved with community projects such as OpenPackages.org and Daemon News.
Return to ONLamp.com.
Copyright © 2009 O'Reilly Media, Inc.