After setting up the layout of the different disks for the system. Now to be able to use these disks, we need to create a file system for each one, mount it somewhere on the file hierarchy, and set it so that it will always be available when the system boots up.
The default file system for RHEL5 is ext3 and has been changed to ext4 for RHEL. Both of these systems offer a journaling option, which has two main advantages. First, it can help speed up recovery if there is a disk failure because journaling file systems keep a “journal” of the file system’s metadata. Second, it can check drives faster during the system boot process. The journaling feature isn’t available on older systems such as ext2.
1- Creating a File System
Following are the commands you can use to create and mange file systems:
mkfs Creates an ext[2|3|4] partition
mkfs.ext2 Creates an ext2 partition
mkfs.ext3 Creates an ext3 partition
mkfs.ext4 Creates an ext4 partition
Some examples for you to understand:
You could also do the following:
# mkfs -t ext4 /dev/sdb1
You could also create a file system on an LVM partition in the same manner
# mkfs.ext4 /dev/vg_group01/lvol10
One of the great things about the ext family file system is that you can upgrade from one file system type to another. For example, some older system may be running ext2 file systems, which have no journal option. You could upgrade these to ext3 and get the added benefits from journaling.
First, I create an ext2 file system on sdc1 partition.
Then upgrade it to ext3 using the tune2fs command:
2- Mounting a File System
Before you can use your new file systems, though, you need to connect them to the directory hierarchy through the use of the mount command. They can be mount to any directory, which referred to as a mount point. There are only two commands for mounting file systems:
mount Mounts a file system
umount Unmounts a file system
So far, you have created a few file systems. Let’s get these file systems mounted on the system.
Notice that you don’t specify a file system type or any mount options. The reason is that the mount command automatically detects the file system type and mounts it for you. With the file systems now mounted, you can use them as if they were a regular directory. Removing or unmounting a file system is a little more complex because users might be actively using that file system. You can use the fuser and lsof commands to check for open files and users that are currently using files on file system that you are trying to unmount.
After checking, now you should be able to unmount the file system:
# umount /dev/sdc1
3- Create a persistent mount point
Now you know how to mount and unmount file systems, but there is something else you need to look at. The mount command is not persistent, so anything that is mounted with it will no longer be available across system reboots. Here is how to fix that. The system looks at two config files. One deals with the mounting system during the boot process, and the other keeps track of currently mounted file systems:
/etc/mtab Contains a list of all currently mounted file systems
/ect/fstab Mounts all listed file systems with given options at boot time
Let’s look at the /etc/mtab file first. Every time you mount or unmount a file system, this file is updated to always reflect what is currently mounted on the system.
Go through the /etc/fstab file. If you want the mount points still persistent after reboot, follow the following example:
You can use “mount -a” command to remap all file systems defined in the /etc/fstab file. Now all your file systems should be mounted and available for use.
Have fun!