Filesystems and Swapping

Devices

Devices in Linux are represented as special files.  These files are either character special files or block special files.  Character special files are used for devices that can work with one byte at a time.  Examples include There are also lots of block special files.  Examples include You may create a filesystem on almost any block special file.  Making a filesystem on a tape drive or a writeable cdrom is a known-bad-idea.

What matters for devices are the major number, which describes the type of device, and minor number, which describes the instance of the device.  Devices also have a standard name, which is the name they are most often called.  For example, the first ide drive is normally /dev/hda, major =3, minor =0.  The second ide drive is normally /dev/hdb, major=3, minor=64.

To make a device file, use the mknod command.  For example, mknod /dev/mydisk b 3 64 would make a file called /dev/mydisk which would access the second ide harddrive.

To make many device files, use the MAKEDEV command.

To find out the major and minor numbers for a device, look in the kernel source or (much better) the MAKEDEV command, which can be found in /dev of all places.

Stupidly, there are no device files for network cards.

There are also lots of psuedo-device files.  Examples include

Hard Drives

Hard drive get a device file for entire hard drive.  You also get a device file for every partition on the drive.

/dev/hda is the entire first hard drive
/dev/hda3 is the third partition of the first hard drive

Filesystems

Filesystems are stored on either partitions or disks.

Filesystem Types

There are many different kinds of filesystem

Making a Filesystem

The basic command is
mkfs -t type place.

For example,
mkfs -t ext2 /dev/ram0

For ext2 filesystem, you can also type mke2fs /dev/ram0.  To see the *many* options, read man mke2fs.

Mounting a Filesystem

You cannot access the contents of a filesystem until it is mounted.  The place where it is mounted is called mount point.
To temporaritly mount a filesystem, type
mount /dev/ram0 /mount-point

To set things up so that the filesystem is permenantly mounted, edit the file /etc/fstab.

Unmounting a Filesystem

To remove a filesystem temporarily, type
umount /mount-point
This will fail if any process is using the filesystem, or even has it as