What Is a Filesystem?

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 6.  The Filesystem and Its Contents


A filesystem is an area of storage medium (e.g., disk or tape) that has been made ready for holding data in file and directory format. A filesystem is given a name when it is created, and it can only be used once it has been made available. The process of making a filesystem available for use is called "mounting." When a filesystem is mounted, it has the effect of it becoming attached to one of the directories that exists on a different filesystem. When used in this way, the directory is called a "mount point." Normally, the mount point a filesystem uses will exist within a previously mounted filesystem. The root filesystem, mounted on "/," is the most fundamental because it is mounted first, when the system boots, using a low-level process. The root filesystem contains the system root directory and key system files.

A filesystem can be mounted on any existing directory and the name of the directory does not need to match the name of the filesystem. This does mean, however, that there must always be at least one filesystem mounted or there would be no directories available to mount any additional filesystems on. The directory that a filesystem is mounted on does not need to be empty, though if it isn't any files or directories contained in it will not be visible or accessible while the filesystem is mounted over it.

Solaris supports three types of filesystems: disk-based, network-based, and virtual filesystems. A disk-based filesystem is a set of structures held in disk blocks capable of supporting the UNIX tree structure and being included in it. Most of this chapter is concerned with disk-based filesystems, though we will also take a brief look at virtual filesystems. (Network-based filesystems are covered in Chapter 18, "NFS, DFS, and Autofs").

Before a filesystem can be created on a disk, the disk must be formatted and partitioned. These days, disks will normally be formatted before they are shipped so this is not a common task and a system administrator is not likely to need to perform this action very often. However, you are likely to need to partition a disk and you will definitely need to understand the process of creating partitions and how to create a filesystem on a partition.

On a Solaris system each disk always contains eight partitions, which are often called "slices." It is entirely up to you how you make use of them, and you do not have to use them all. The information about the partitions is stored on the disk in an area called the "disk label." The label is also known as the "VTOC" (volume table of contents) and is located in the first block of the disk. A label contains information about the disk's controller, geometry, and partitions. The part of the label that holds the information about the partitions is called the "partition table."

Each partition can hold one or zero filesystems, which means a disk can hold up to eight filesystems, though it is unusual to actually create eight. The practical maximum is seven filesystems since partition number two is usually reserved for a special purpose, which will become clear later on in this chapter.

The relationship between a filesystem and a partition is that a partition can hold one or zero filesystems and a filesystem may not span across more than one partition. A filesystem does not have to be as large as the partition, but space will be wasted if it is smaller.

Before going ahead and creating filesystems all over the place, a fair bit of planning should be undertaken. The number of disks you have and the size of them will play a large part in this.

Table 6.1 shows an example of how a disk could be partitioned (based on a 1.7 GB disk).

Table 6.1. Example Partitions

Part

Tag

Flag

Cylinders

Size

Blocks

 

0

root

wm

062

50.30 MB

(63/0/0)

103005

1

swap

wu

144243

79.83 MB

(100/0/0)

163500

2

backup

wm

02104

1.64 GB

(2105/0/0)

3441675

3

unassigned

wm

0

0

(0/0/0)

0

4

var

wm

63143

64.67 MB

(81/0/0)

132435

5

unassigned

wm

244294

40.72 MB

(51/0/0)

83385

6

usr

wm

2951297

800.73 MB

(1003/0/0)

1639905

7

home

wm

12982099

640.27 MB

(802/0/0)

1311270

In this example all but two of the partitions contain filesystems. You might assume that these are the partitions numbered 3 and 5, as these both have a tag of unassigned. This, however, is not the case. Although the tag names do tie in with the filesystem name in some cases, the tag unassigned does not mean the partition has no filesystem. In fact, from the table above we can infer which partitions do not have filesystems, but we cannot tell whether the others have them or not, though we can make assumptions. The more obvious of the two partitions without filesystems is partition 3. It has a size of 0 so it cannot have a filesystem on it, and one could not be created on it unless another partition is made smaller to free up some space. The other partition with no filesystem is partition 2, which actually encompasses the whole disk. This is set up automatically by Solaris and the size of partition 2 should not be changed, since this slice is used as a way of backing up or copying the whole disk.

Table 6.2 describes the attributes that are associated with a disk partition.

Table 6.2. Partition Attributes

Partition Attribute

Description

Partition Number

Each disk has eight available partitions (or slices) numbered 0 to 7.

Tag

The tag describes what type of filesystem has been placed on each partition. Tags are represented by a hex number in the range (0-a). The available tags are:

 

0x00

0x01

0x02

0x03

0x04

0x05

0x06

0x07

0x08

0x09

0x0a

unassigned

boot

root

swap

usr

backup

stand

var

home

altsctr

cache

Flag

The flag shows how the partition should be mounted. Flags are represented by a hex value, but are sometimes shown as two letters:

 

0x00

0x01

0x10

mw

uw

mr

mountable, read and write

unmountable, read and write

mountable, read-only

Cylinders

A disk is divided into a number of cylinders. This shows the range of cylinders that have been allocated to this partition.

Size

This shows the actual space taken up by the partition in an appropriate unit (e.g., megabytes or gigabytes).

Blocks

The left column shows the total number of cylinders per partition. The rightmost column shows the number of sectors per partition.

To recap: A disk is split into partitions (or slices) upon which filesystems can be createdone filesystem per partition. The terms "partition" and "slice" have exactly the same meaning in Solaris and we deliberately use both in this book. This is because some system administrators will always use one, some the other, and some will use both.

To create a filesystem on a partition, we need to have a way of referring to it. Solaris allows us to do this by providing a series of special files under the /dev directory. There is one file for each partition (or slice) on the disk. The UNIX command df is generally used to show how full a filesystem is, but it also shows the name of the special device file that goes with each partition/filesystem:

 hydrogen# df -k Filesystem        kbytes  used  avail capacity  Mounted on /proc                  0      0      0   0%   /proc /dev/dsk/c0t2d0s0  48349  16889  26626  39%   / /dev/dsk/c0t2d0s6 770543 522712 193893  73%   /usr fd                     0      0      0   0%   /dev/fd /dev/dsk/c0t2d0s1  61463   5592  49725  11%   /var /dev/dsk/c0t2d0s7 519718  82791 384956  18%   /export/home /dev/dsk/c0t2d0s5  38539   5928  28758  18%   /opt swap              130064     28 130036  1%    /tmp hydrogen# 

The name of the file tells us some information about the part of the physical disk that it refers to. If we look at the device file for the root filesystem (shown in the first column), we see that the root filesystem is located on disk controller 0, target 2, drive 0, and slice 0. If your system only has one disk controller, then all disks will start "c0." The "t" represents the physical bus target number; this can usually be set on the disk itself using jumpers. The "d" represents the drive number, which is the disk's Logical Unit Number (LUN). If the disk has an embedded controller, then the drive value will usually be 0. Most disks have embedded controllers these days.

We have already seen that each disk can hold up to eight slices (or partitions) numbered 0 to 7 and partition 2 is usually used to represent the whole disk. The disk in our system has a target of 2, so if we were to add any more disks onto controller 0 we would need to make sure the target was set to a different number. Consequently, if the system had a second disk, it might be referred to as c0t3d0s2, depending on what we set the target to.

The df command will only show the slices that contain filesystems and have been mounted. If we want to see all the partitions on a disk, we can use the prtvtoc command:

 hydrogen# prtvtoc /dev/rdsk/c0t2d0s2 * /dev/rdsk/c0t2d0s2 partition map * * Dimensions: *     512 bytes/sector *     109 sectors/track *      15 tracks/cylinder *    1635 sectors/cylinder *    2372 cylinders *    2105 accessible cylinders * *    1635 sectors/cylinder *    2372 cylinders *    2105 accessible cylinders * * Flags: *   1: unmountable *  10: read-only * * Unallocated space: *       First     Sector    Last *       Sector     Count    Sector *     3435135      6540   3441674 * *                       First Sector  Last * Partition Tag Flags  Sector Count Sector Mount Directory     0        2   00       0   103005   103004  /     1        7   00  103005   132435   235439  /var     2        5   00       0  3441675  3441674     3        3   01  235440   163500   398939     4        9   00 3229125   206010  3435134     5        0   00  398940    83385   482324  /opt     6        4   00  482325  1639905  2122229  /usr     7        8   00 2122230  1106895  3229124  /export/home hydrogen# 

The tag and flag columns are displayed in hex notation, but these can be translated to their text equivalent using Table 6.2 shown earlier. The rightmost column, headed Mount Directory, will show the directory on which the partition's filesystem is currently mounted. If a directory is not shown, it does not mean that the partition has no filesystem on it, but just that it is not currently mounted.


    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net