Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

slices. The drive referenced there has one slice, with further subdivisions marked by letters.

In FreeBSD, a partition is a further subdivision inside a slice, and as part of the install, you created partitions inside the slice. Each partition has a unique device node created by adding a unique letter to the slice device node. For example, partitions inside the slice /dev/ad0s1 show up as /dev/ad0s1a, /dev/ad0s1b, /dev/ad0s1e, and so on. Each of the partitions you created during the install–/usr, /var, and so on–is assigned to one of these partition device nodes.

Partition device nodes can be assigned almost arbitrarily, with some exceptions. Traditionally the node ending in "a" (in our example, /dev/ad0s1a) is the root partition, and the node ending in "b" (/dev/ad0s1b) is the swap space. The "c" label indicates the entire slice, from beginning to end, though you can assign "d" through "h" to any partition you like. You can only have eight partitions in one slice, and you can have up to four slices per drive.

For example, the device node /dev/ad0s1a is disk number 0, slice 1, partition 1, and is probably the root filesystem. The device node /dev/ad1s2b is on disk 2, and is probably a swap slice.

SCSI drives have slices and partitions just like IDE drives, but their device nodes are slightly different. Instead of beginning with /dev/ad, SCSI hard drives have names beginning with /dev/sd. For example, the second slice on your third SCSI hard drive is /dev/sd2s2.

Note Here and there you'll see the word traditional. This means that it's the way things are usually done. Whenever possible, it's a good idea to stick with the tradition. You don't want some junior systems administrator tripping over your nontraditional disk layout and telling the system to swap on your data partition, now do you?

[1]As is very common in computers, the first disk is device number 0, the second disk is device number 1, and so on.

The /etc/fstab File

The filesystem table lists every filesystem on your computer's hard drives, showing where each filesystem is mounted and any special options that mount(8) uses. Each filesystem appears on a separate line in /etc/fstab, as shown in the following sample:

...............................................................................................

#more /etc/fstab

 

 

 

 

 

# Device

Mountpoint

FStype

Options

Dump

Pass#

/dev/ad0s1b

none

swap

sw

0

0

/dev/ad0s1a

/

ufs

rw

1

1

/dev/ad0s1f

/test1

ufs

rw

2

2

/dev/ad0s1g

/test2

ufs

rw

2

2

/dev/ad0s1h

/usr

ufs

rw

2

2

/dev/ad0s1e

/var

ufs

rw

2

2

/dev/acd0c

/cdrw

cd9660

ro,noauto

0

0

/dev/acd1c

/cdrom

cd9660

ro,noauto

0

0

proc

/proc

procfs

rw

0

0

#

...............................................................................................

The first field in the preceding listing gives the device name, which was discussed earlier.

368

The second field lists the mount point (the directory where this filesystem is found). This is usually something like /usr, /var, and so on, though some special partitions, such as swap spaces, have a mount point of none.

Next is the filesystem type. The standard FreeBSD partition uses type FFS, the UNIX Fast File System. Other options include, but aren't limited to, msdos (FAT partitions), mfs (Memory File System), and cd9660 (CD−ROM). Before you can mount a filesystem, you must know how it's formatted. (As you might guess, trying to mount a DOS floppy as a UNIX filesystem will not give satisfactory results.)

The fourth field shows the mount options used on this filesystem. The mount options describe special ways you want the kernel to treat the filesystem. We'll discuss mount options in more detail later in this chapter, but here are a few special mount options used only by /etc/fstab:

ro

The filesystem is mounted as read−only. Not even root can write to it.

rw

The filesystem is mounted as read−write. This is the standard noasync mount. (Noasync is explained shortly, in the "FFS Mount Types" section.)

The boot process will not automatically mount the partition at boot, or when mount noauto −a is run. This option is used for CD−ROM and floppy−disk drives, which might not

have media in them.

The dumpfield tells the dump(8) program whether or not this filesystem needs dumping. If this field equals 0, dump won't back up the filesystem. Otherwise, the number given is the minimum dump level needed to back up the filesystem. (See Chapter 3 for details.)

The last field, Pass#, tells the system when to mount the filesystem during the boot process. Filesystems with a Pass# of 0 will not be mounted automatically at boot. Only the root filesystem has a Pass# of 1, and it is mounted first; all other filesystems have a Pass# of 2, which means that they should be mounted after the root filesystem is mounted.

In the previous example, /dev/ad0s1b is a swap partition, and /dev/ad0s1e is mounted as /var. You might notice that there are two CD−ROM drives: /dev/acd0c and /dev/acd1c (one is actually a CD−ROM burner). You will need to know which partition is on which device node to manipulate disk partitions.

Disk Basics

All filesystems have certain things in common, not least of which is the disk drive, that rectangular thing with connectors at one end.

The disk drive is basically a little magic box. If you treat it badly, you can hear the magic screech and grind. When you mistreat it enough, you might even let the magic smoke out, and the drive will never run again. To really understand filesystems, you need to know a little bit about the incantations going on inside that magic box, so let's have a look. (If you have a dusty old disk drive that you no longer have respect for, feel free to crack the case and follow along.)

Note The following is a generalization, of course, and many of you probably already know far more than this.

369