Linux for Programmers and Users

[Page 149 (continued)]

4.14. Mounting File Systems: mount and umount

A super-user may extend the file system by using the mount utility (Figure 4-30).


[Page 150]

Figure 4-30. Description of the mount and umount commands.

Utility: mount -ooptions -t type [ deviceName directory ]

umount deviceName

mount is a utility that allows you to "splice" a device's file system into the root hierarchy. When used without any arguments, mount displays a list of the currently mounted devices. To specify special options, follow -o by a list of valid codes. These codes include rw, which mounts a file system for read/write, and ro, which mounts a file system for read-only. Use type to specify the file system type (e.g., ext2, ext3, etc.). The umount utility unmounts a previously mounted file system.

In the following example, I spliced the file system contained on the "/dev/dsk2" device onto the "/usr" directory. Notice that before I performed the mount, the "/usr" directory was empty; after the mount, the files stored on the "/dev/dsk2" device appeared inside this directory.

$ mount ...list the currently mounted devices. /dev/dsk1 on / type ext2 (rw) $ ls /usr .../usr is currently empty. $ mount /dev/dsk2 /usr ...mount the /dev/dsk2 device. $ mount ...list the currently mounted devices. /dev/dsk1 on / type ext2 (rw) /dev/dsk2 on /usr type ext2 (rw) $ ls /usr ...list the contents of the mounted device. bin/ etc/ include/ lost+found/ src/ ucb/ demo/ games/ lib/ pub/ sys/ ucblib/ dict/ hosts/ local/ spool/ tmp/ $ _

To unmount a device, use the umount utility. In the following example, I unmounted the "/dev/dsk2" device and then listed the "/usr" directory. The files were no longer accessible.

$ umount /dev/dsk2 ...unmount the device. $ mount ...list the currently mounted devices. /dev/dsk1 on / type ext2 (rw) $ ls /usr ...note that /usr is empty again. $ _

Категории