Managing File Systems and Disk Space

File systems in Linux are organized in a hierarchy, beginning from root (/ ) and continuing downward in a structure of directories and subdirectories. As an administrator of a Fedora or RHEL system, it is your duty to make sure that all the disk drives that represent your file system are available to the users of the computer. It is also your job to make sure there is enough disk space in the right places in the file system for users to store what they need.

File systems are organized differently in Linux than they are in Microsoft Windows operating systems. Instead of drive letters (for example, A:, B:, C:) for each local disk, network file system, CD-ROM, or other type of storage medium, everything fits neatly into the directory structure. For hard drive partitions, it is up to an administrator to create a mount point in the file system and then connect the disk to that point in the file system. For removable media (such as CD, DVD, USB flash drives, or digital cameras), mount points are automatically created and connected (in the /media directory) when those items are connected or loaded.

CROSS-REFERENCE: Chapter 2 provides instructions for using Disk Setup (formerly Disk Druid) to configure disk partitions. Chapter 4 describes how the Linux file system is organized.

The organization of your file system begins when you install Linux. Part of the installation process is to divide your hard disk (or disks) into partitions. Those partitions can then be assigned to:

• Other file system types (perhaps containing other bootable operating systems)

For our purposes, I want to focus on partitions that are used for the Linux file system. To see what partitions are currently set up on your hard disk, use the fdisk command as follows:

Disk /dev/sda: 40.0 GB, 40020664320

255 heads, 63 sectors/track, 4825 cylinders

Units = cylinders of 16065 * 512 bytes = 8225280 bytes

Disk /dev/sda: 40.0 GB, 40020664320

255 heads, 63 sectors/track, 4825 cylinders

Units = cylinders of 16065 * 512 bytes = 8225280 bytes

Device Boot

Start

End

Blocks

Id

System

/dev/sdal *

1

13

104

b

Win95 FAT32

/dev/sda2

84

89

48195

83

Linux

/dev/sda3

90

522

3478072+

83

Linux

/dev/sda4

523

554

257040

5

W95 Ext'd (LBA)

/dev/sda5

523

554

257008+

82

Linux swap / Solaris

This output shows the disk partitioning for a computer able to run both Linux and Microsoft Windows. You can see that the Linux partition on /dev/sda3 has most of the space available for data. There is a Windows partition (/dev/sdal) and a Linux swap partition (/dev/sda5). There is also a small /boot partition (46MB) on /dev/sda2. In this case, the root partition for Linux has 3.3GB of disk space and resides on /dev/sda3.

Next, to see what partitions are actually being used for your Linux system, you can use the mount command (with no options). The mount command can show you which of the available disk partitions are actually mounted and where they are mounted.

# mount

/dev/sda3 on / type ext3 (rw) /dev/sda2 on /boot type ext3 (rw) /dev/sda1 on /mnt/win type vfat (rw) none on /proc type proc (rw) none on /sys type sysfs (rw)

none on /dev/pts type devpts (rw,gid=5,mode=620) none on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/scd0 on /media/cdrecorder_ type iso9660 (ro,nosuid,nodev,uhelper=hal)

NOTE: You may notice that /proc, /sys, /dev/pts, /proc/sys/fs/binfmt_misc, /dev/shm, and other entries not relating to a partition are shown as file systems. This is because they represent different file system types (proc and devpts, and so on). The word none, however, indicates that they are not associated with a separate physical partition.

The mounted Linux partitions in this case are /dev/sda2, which provides space for the /boot directory (which contains data for booting Linux), and /dev/sda3, which provides space for the rest of the Linux file system beginning from the root directory (/). This particular system also contains a Windows partition that was mounted in the /mnt/win directory.

Beginning with Fedora Core 3 and RHEL 4, mount points for removable media (CDs, DVDs, USB pen drives, and so on) moved from /mnt to the /media directory. In this example, an IDE combination CDRW/DVD-ROM drive was mounted on /media/cdrecorder. With most GUI interfaces, the CD or DVD is typically mounted automatically when you insert it. In this example, the uhelper (unprivileged unmount request helper) is assigned to the hald daemon user hal so that the hald facility can unmount the CD as an otherwise non-privileged user.

NOTE: See a description of the GNOME Volume Manager in Chapter 3 for information about how removable media are handled in the current Fedora and RHEL releases.

After the word type, you can see the type of file system contained on the device. (See the description of different file system types in the next section of this chapter.) Particularly on larger Linux systems, you may have multiple partitions for several reasons:

• Multiple hard disks — You may have several hard disks available to your users. In that case you would have to mount each disk (and possibly several partitions from each disk) in different locations in your file system.

• Protecting different parts of the file system — If you have many users on a system, and the users consume all of the file system space, the entire system can fail. For example, there may be no place for temporary files to be copied (so the programs writing to temporary files may fail), and incoming mail may fail to be written to mail boxes. With multiple mounted partitions, if one partition runs out, others can continue to work.

• Backups — There are some fast ways to back up data from your computer that involve copying the entire image of a disk or partition. If you want to restore that partition later, you can simply copy it back (bit by bit) to a hard disk. With smaller partitions, this approach can be done fairly efficiently.

• Protecting from disk failure — If one disk (or part of one disk) fails, by having multiple partitions mounted on your file system, you may be able to continue working and just fix the one disk that fails.

When a disk partition is mounted on the file system, all directories and subdirectories below that mount point are then stored on that partition. So, for example, if you were to mount one partition on / and one on /usr, everything below the /usr mount point would be stored on the second partition while everything else would be stored on the first partition. If you then mounted another partition on /usr/local, everything below that mount point would be on the third partition, while everything else below /usr would be on the second partition.

TIP: What if a remote file system is unmounted from your computer, and you go to save a file in that mount point directory? What happens is that you will write the file to that directory and it will be stored on your local hard disk. When the remote file system is remounted, however, the file you saved will seem to disappear. To get the file back, you will have to unmount the remote file system (causing the file to reappear), move the file to another location, remount the file system, and copy the file back there.

Mount points that are often mentioned as being candidates for separate partitions include /, /boot, /home, /usr, and /var. The root file system (/) is the catchall for directories that aren't in other mount points. The root file system's mount point (/) is the only one that is required. The /boot directory holds the images needed to boot the operating system. The /home file systems is where all the user accounts are typically stored. Applications and documentation are stored in /usr. Below the /var mount point is where log files, temporary files, server files (Web, FTP, and so on), and lock files are stored (that is, items that need disk space for your computer's applications to keep running).

CROSS-REFERENCE: See Chapter 2 for further information on partitioning techniques.

The fact that multiple partitions are mounted on your file system is invisible to people using your Linux system. The only times they will care will be if a partition runs out of space or if they need to save or use information from a particular device (such as a floppy disk or remote file system). Of course, any user can check this by typing the mount command.

Was this article helpful?

0 0
Digital Camera and Digital Photography

Digital Camera and Digital Photography

Compared to film cameras, digital cameras are easy to use, fun and extremely versatile. Every day there’s more features being designed. Whether you have the cheapest model or a high end model, digital cameras can do an endless number of things. Let’s look at how to get the most out of your digital camera.

Get My Free Ebook


Post a comment