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

Virtual Memory Directory Caching

When you examine a directory (such as when you run ls), the system needs to build a list of files in the directory–a fairly performance−intensive operation. If you're doing this a lot, you can improve performance by caching the contents of the directory with the sysctl vfs.vmiodirenable.

This option may be on by default in later versions of FreeBSD, but if not, you can set it automatically at boot in /etc/sysctl.conf:

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

vfs.vmiodirenable=1

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

Mounting Foreign Filesystems

For our purposes, any disk that isn't an FFS partition is a foreign filesystem. Fortunately, FreeBSD includes extensive support for these foreign filesystems, with the caveat that only those functions supported by the filesystem will work. (FAT doesn't support filesystem permissions, for example. You can set filesystemlevel security flags on a FAT filesystem all you want, and they won't do a thing.)

Each filesystem has its own unique mount program that handles the vagaries of that filesystem, and each filesystem needs support in the kernel. To make your life a little easier, the mount programs automatically load the appropriate kernel modules as needed.

Using Foreign Mounts

To mount any foreign filesystems, you need the same information you would need when mounting an FFS filesystem: a device name and a mount point. You also need the name of the command to mount that type of filesystem. (We'll consider the various foreign filesystems and the commands to mount them in the next section.)

For example, to mount a CD−ROM, include a /cdrom mount point and the device name. We'll use the default for the first IDE CD−ROM here, /dev/acd0c.

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

# mount_cd9660 /dev/acd0c /cdrom

#

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

Once the CD−ROM is mounted, you can read what's on it. Simple enough, eh?

If you try to mount a disk using the wrong mount for its filesystem, you'll get an error. I'm quite used to seeing this when mounting unfamiliar floppies:

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

# mount/dev/fd0 /mnt

mount: /dev/fd0 on /mnt: incorrect super block

378

#

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

This floppy is MS−DOS−formatted. It works just fine if I use mount_msdos though.

No matter what sort of filesystem you are mounting, you can unmount it with umount(8):

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

# umount /cdrom

#

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

Foreign Filesystem Types

Here are some of the most commonly used foreign filesystems, along with a brief description of each and the appropriate mount command.

MS−DOS

FreeBSD includes extensive support for FAT filesystems, the DOS/Windows 9x File Allocation Table filesystem, commonly used in dual−boot systems and on floppy disks. You can format a floppy disk in FFS, however, so you cannot assume that all floppy disks are MS−DOS formatted. If you try to mount a floppy disk and it won't work as an MS−DOS disk, try to mount it as an FFS disk. (Personally, my only use for floppy disks is to transfer files to and from a Windows machine that I don't control—for example, for taking files to the print shop. I make it my personal standard to always format floppy disks as MS−DOS format.)

The mount command is mount_msdos(8).

If you mount a lot of MS−DOS devices, investigate /usr/ports/tools/mtools, a collection of programs for working with MS−DOS that offers better performance than the default FreeBSD tools.

NTFS

The Windows NT/2000/XP standard filesystem, NTFS, is tightly integrated with Microsoft's kernel. To write to an NTFS partition, you must have extensive knowledge of how the filesystem works. Unfortunately, since that information is not available from Microsoft, you can read NTFS partitions but writing may corrupt the partition. The mount command is mount_ntfs(8).

Note Since Microsoft holds its filesystem interface so dear, and changes it regularly, don't count on this for frequent use. Using mount/ntfs can damage the filesystem.

ISO−9660

ISO−9660 is the standard data CD−ROM filesystem. FreeBSD allows you to read CD−ROMs and to write them if you have a CD−ROM burner. Just about every CD−ROM you will encounter has the ISO−9660 format. The mount command is mount_cd9660(8).

379