Creating and Managing Storage, Part III
Creating File Systems:
· Once you have created one or more partitions or logical volumes (covered in the next section), most likely you'll put a file system on them next
· In this section, you'll learn:
o which file systems are available
o how to format your partitions with these file systems
o how to set properties for the Ext4 file system
File Systems Overview:
· Several file systems are available on RHEL, but "Ext4" is used as the default file system
· See table of File Systems:
· As you can see, several file systems are offered so you can use the one most appropriate for your environment
· However, Ext4 is a good choice for almost any situation. .
· BEFORE starting to format partitions and putting file systems on them, there is one file system feature of which you need to be aware. .the file journal
· Modern Linux file systems offer journaling as a standard feature
· The Journal works as a transaction log in which the file system keeps records of files that are open for modification at any given time
· The benefit of using a file system journal is that, if the server crashes, it can check to see what files were open at the time of the crash and immediately indicate which files are potentially damaged
· Because using a journal helps protect your server, you would normally want to use it by default
· There is one drawback to using a journal:
o a file system journal takes up disk space. . an average of 50MB normally on Ext4
o That means it's not a good idea to create a journal on very small file systems because it might leave insufficient space to hold your files
o If this situation applies to some of your partitions, use the Ext2 file system
Creating File Systems:
· To create a file system, you can use the "mkfs" utility
· There are different versions of this utility. .one for every file system type that is supported on your server
· To create an ext4 file system, you use the "mkfs.ext4" command OR alternatively, the command "mkfs -t ext4"
o It doesn't matter which of these you use, they both do the same thing
In this next exercise, you will learn how to make an Ext4 file system on one of the partitions you created earlier:
Changing File System Properties:
· In most cases, you won't need to change any of the properties of your file systems
· In some cases, however, it can be useful to change them anyway
· The "tune2fs" command allows you to change properties
· The "dumpe2fs" command allows you to check the properties that are currently in use
· See "Ext file system properties" table below:
· Before setting file system properties, it's a good idea to check the properties that are currently in use.
· find this out with the "dumpe2fs" command. .
o See example below
o Also go to CentOS and see example
· To change current file system properties, you can use the "tune2fs" command
· Exercise: use "tune2fs" command to set a label for the file system you just created
-- do exercise,
Checking the File System Integrity:
· The integrity of your file system will be thoroughly checked every so many boots (depending on the file system options settings) using the "fsck" command
· A quick check is performed on every boot:
o That will indicate whether your file system is in a healthy state
· You may encounter a situation where, when you reboot your server, it prompts you to enter the password of the user root because something has gone wrong during the automatic file system check
o In such cases, it may be necessary to perform a manual file system check
· The "fsck" command has a few useful options
o try the -p option, which attempts to performa an automatic repair, without further prompting
o try the -y option, which assumes yes as the answer to all prompts
Mounting File Systems Automatically through fstab:
· You have learned how to create partitions and how to format them using the Ext4 file system
· You can also mount them manually. .but what about mounting automatically after reboot
o To make sure that the file system is mounted automatically across reboots, you should put it in the "/etc/fstab" file
o Example: take a look at file on Centos Server Also:
o The /etc/fstab file is used to mount two different kinds of devices:
§ file systems
§ system devices
o The 1st four lines on example above are used to mount file systems
o The last 4 lines on example above are used to mount specific system devices
o To specify how the mounts should be performed, six different columns are used:
· To avoid issues with device names, RHEL partitions are normally mounted by using the UUID that is assigned to every partition
· To find out the UUIDs of the devices on your server, you can use the "blkid" command
o see example of "blkid" command:
o Also see example on CentOS server:
· In listing 5.9 above, you can see the UUIDs of the partitions on this server as well as the LVM logical volumes (discussed in next session)
· For mounting partitions, it is essential that you use the UUIDs, because the device names of partitions may change
· For LVM logical volumes, it's not important because the LVM names are detected automatically when your server boots
· Another method for addressing devices with a name that doesn't change is to use the names in the "/dev/disk" directory
o In this directory, you'll find different subdirectories where the Linux kernel creates persistent names for devices
Exercise: Mounting Devices through /etc/fstab:
· See attached sheet
· After completing the exercise, you are now able to add lines to /etc/fstab, and you've added a line that automatically tries to mount your USB flash drive when your server reboots
Troubleshooting technique:
· You've added a line that automatically tries to mount your USB flash drive when your server reboots
o This might not be a very good idea because you will run into problems at reboot if the USB flash drive isn't present
o it's always good to be prepared:
o In short, because the boot procedure checks the integrity of the USB flash drive file system, this will not work because the USB flash drive isn't available
o This further means that "fsck" fails, which is considered a fatal condition in the boot procedure. . .for that reason, you'll drop into an emergency repair shell where you can fix the problem manually
§ In this case, the best solution is to remove the line that tries to mount "/etc/fstab" completely
§ You will encounter another problem, however, As you dropped into the emergency repair shell, the root file system is not yet mounted in a read-write mode, and you cannot apply changes to "/etc/fstab".
§ To apply changes anyway, you'll first remount the root file system in read-write mode using "mount -o remount,rw /." This allows you to make all of the required changes to the configuration file
Exercise: Fixing "/etc/fstab" Problems:
· see attached sheet