OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Mounting And Unmounting Storage Devices

Recent advances in the Linux desktop have made storage device management extremely


easy for desktop users. For the most part, we attach a device to our system and it “just works.” Back in the old days (say, 2004), this stuff had to be done manually. On non- desktop systems (i.e., servers) this is still a largely manual procedure since servers often have extreme storage needs and complex configuration requirements.

The first step in managing a storage device is attaching the device to the file system tree. This process, called mounting, allows the device to participate with the operating system. As we recall from Chapter 2, Unix-like operating systems, like Linux, maintain a single file system tree with devices attached at various points. This contrasts with other operat- ing systems such as MS-DOS and Windows that maintain separate file system trees for each device (for example C:\, D:\, etc.).

A file named /etc/fstab (short for “file system table”) lists the devices (typically hard disk partitions) that are to be mounted at boot time. Here is an example

/etc/fstab file from an early Fedora system:


LABEL=/12

/

ext4

defaults

1

1

LABEL=/home

/home

ext4

defaults

1

2

LABEL=/boot

/boot

ext4

defaults

1

2

tmpfs

/dev/shm

tmpfs

defaults

0

0

devpts

/dev/pts

devpts

gid=5,mode=620

0

0

sysfs

/sys

sysfs

defaults

0

0

proc

/proc

proc

defaults

0

0

LABEL=SWAP-sda3

swap

swap

defaults

0

0


Most of the file systems listed in this example file are virtual and are not applicable to our discussion. For our purposes, the interesting ones are the first three:



LABEL=/12

/

ext4

defaults

1

1

LABEL=/home

/home

ext4

defaults

1

2

LABEL=/boot

/boot

ext4

defaults

1

2


These are the hard disk partitions. Each line of the file consists of six fields, as follows:


Table 15-1: /etc/fstab Fields


Field

Contents

Description

1

Device

Traditionally, this field contains the actual name of a

device file associated with the physical device, such as

/dev/sda1 (the first partition of the first detected

hard disk). But with today's computers, which have

many devices that are hot pluggable (like USB drives),


many modern Linux distributions associate a device with a text label instead. This label (which is added to the storage media when it is formatted) can be either a simple text label, or a randomly generated UUID (Universally Unique Identifier). This label is read by the operating system when the device is attached to the system. That way, no matter which device file is assigned to the actual physical device, it can still be correctly identified.

2

Mount Point

The directory where the device is attached to the file

system tree.

3

File System Type

Linux allows many file system types to be mounted.

Most native Linux file systems are Fourth Extended

File System (ext4), but many others are supported,

such as FAT16 (msdos), FAT32 (vfat), NTFS

(ntfs), CD-ROM (iso9660), etc.

4

Options

File systems can be mounted with various options. It is

possible, for example, to mount file systems as read-

only, or to prevent any programs from being executed

from them (a useful security feature for removable

media).

5

Frequency

A single number that specifies if and when a file

system is to be backed up with the dump command.

6

Order

A single number that specifies in what order file

systems should be checked with the fsck command.


 

Top OS Cloud Computing at OnWorks: