< Day Day Up > |
/etc/fstab, e2label, and mount/etc/fstabThe /etc/fstab file mentioned earlier is used by e2fsck to determine the sequence of the file system check if it is required at the time of boot. The sequence of entries in /etc/fstab is important if a "pass number" for any of the entries does not exist. Here is an example of the /etc/fstab file from the Integrity server with SCSI:
As you can see, in the /etc/fstab example, the cdrom has several options, including ro for read only. Swap, or virtual memory, is on /dev/sda2. /proc has a none associated with it because it is an interface to kernel parameters and not a file system like the others. /dev/pts also has a none associated with it because it is a way for remote system access with programs, such as telnet and rlogin, to get access to your system. You could easily add entries to /etc/fstab so that the system will mount /backup when it boots. Because you want to mount /dev/sdb1 using its label (/backupB), first use the command e2label to create a label. After you do that, run the e2label command again to display the results: [root@localhost root]# /sbin/e2label /dev/sdb1 /backup [root@localhost root]# /sbin/e2label /dev/sdb1 /backup [root@localhost root]# As you can see, we performed the desired labeling. Now, in order to automatically mount the new partition at boot time, add the following line to the /etc/fstab file: LABEL=/backup /backup ext3 defaults 1 2 Then, save the file. If you want to check if the partition will be mounted in the correct place at boot time, reboot and log on again, or issue the following commands. [root@localhost root]# mount -a [root@localhost root]# df Filesystem 1k-blocks Used Available Use% Mounted on /dev/sda3 68450624 1419368 63554124 3% / /dev/sda1 104184 6120 98064 6% /boot/efi none 1024560 0 1024560 0% /dev/shm /dev/sdb1 35001508 32828 33190688 1% /backup [root@localhost root]# mount -a reads /etc/fstab and mounts all unmounted file systems listed in the file. df asks the system to report on all the free disk on the system. It reports that /dev/sbd1 is mounted on /backup, and that it is only 1% full. The mount command has been used a lot in this chapter and hasn't really been covered yet. That's because most of the work you do with mount is basic. Still, there are a lot of options to the command that you can see on the man page. However, the basic form of the mount command is as follows: mount [options] device dir You've already used some of the mount options in the examples. The following lists of some of the more commonly used options:
Now that you can mount a file system, you should know how to unmount it. Linux uses the umount (note that its umount, not unmount) command to unmount a file system: umount [-f] directory Provided that the file system is not in use, it will be unmounted immediately. Being in use includes simply being in the directory or a process of having a file open that resides on the mounted file system. Consequently, you may have to change directories if you are in a directory on the file system to be unmounted, or you may have to use kill to stop the process attached to the file system. Similarly, if you have a file open on the file system you want to unmount, you'll have to close it. You may have to use umount -f to force the filesystem to be unmounted, or go into what Linux calls "single user mode." |
< Day Day Up > |