1. 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
2. It can check drivers faster during the system boot process.
Ext2 | Ext3 | Ext4 |
Stands for the second extended file system. | Third, extend the file system | Third extended file system |
Introduced in 1993 | Introduced in 2001 | Introduced in 2008 |
Does not have journaling | support journaling | Support journaling |
Maximum file size can be from 16 GB to 2 TB | 16GB to 2TB | 16GB to 16 TB |
The maximum ext2 file system size can be from 2 TB to 32 TB. | 2TB to 32 TB | Maximum ext4 file system size is 1EB (Exabyte). 1EB =1024 PB(petabyte) 1PB = 1024 TB (Terabyte) |
-> There are many types of file systems
Swap: The Linux swap file systems is associated with dedicated swap partitions. You’ve probably created at least one swap partition when you installed RHEL.
MS-Dos & VFAT: These file systems allow you to read MS-DOS formatted file systems. MS-DOS lets you read pre – windows 95 partitions, or regular window partitions within the limits of short file names. VFAT lets you read windows 9x/NT/2000/vista/7 partitions formatted to the FAT 16 or FAT 32 file systems.
ISO 9660: The standard file system for CD-ROMs. It is also known as the high sierra file system, or HSFS, on the Unix systems.
/proc: A Linux virtual file system. Virtual means that it doesn’t occupy real disk space. Instead, files are created as needed. Used to provide information on kernel configuration and device status.
/dev/pts: The Linux implementation of the open group’s Unix 98 PTY support.
JFS: IBM’s journaled file system, commonly used on IBM enterprise servers.
ReiserFS: The ReiserFS file system is resizable and supports fast journaling It’s more efficient when most of the files are very small and very large. It’s based on the concept of “balanced trees”. It is no longer supported by RHEL, or even by its format main proponent, SUSE.
Xfs: Developed by silicon Graphics as a journaling file system, it supports very large files: as of this writing, xfs files are limited to 9x1018 bytes. Do not confuse this file system with the x font server, both use the same acronym.
NTFS: The current Microsoft windows file system.
Syn: mkfs [options] [device]
j ---> creates a journal option
m --> specifies a reserved percentage of blocks on a file system.
#mkfs – ext4 /dev/sda5
#mke2fs – t ext 4 /dev/sda5
#mkfs.ext4 /dev/sda5.
-Backup any existing data on the partition
-unmount the partition.
- mkfs.cramfs creates a compressed ROM file system.
mkfs.ext2 Formats a volume to the ext2 file system.
mkfs.ext3 Formats a volume to the ext3 file system.
mkfs.Ext4 formats a volume to the Ext4 file system.
Mkfs.msdos (or) mkfs.vfat (or) mkdosfs ----> Formats a partition to the Microsoft compatible VFAT file system: it does not create bootable file systems.
mkfs.xfs Formats a volume to the xfs file system developed by the former silicon graphics.
mkswap Formats a volume to the Linux swap file system
Creating a swap:-
Step 1): ---> Create a partition
#f disk / dev/ sda
Step 2): ---> Update to kerne;
#Partprobe /dev/sda
Step 3): ---> Use the mkswap command to create a swap space
Syn: mkswap [options] [Device]
-c Checks the device for bad blocks before creating the swap area.
#mkswap /dev/sda8
Step4: ---> Enable the swap partition
#swapon /dev/sda8
Step 5): ---> Verify the swap is running correctly
#swapon -s
Step 6): ---> If you want to turn off the swap, you can use the swapoff command.
Syn: swapoff [options] [device]
a ----> Enables all swap devices
e ----> silently skips devices that don’t exist
s ----> verifies that the swap is running
You can use the dd command to reserve space for another swap on the /dev/sda9 partition.
---->The dd command can be used for many different purposes and has a huge syntax
Step 1: ---->Reserve 1GB of space for the swap
#dd if =/dev/zero of=/mnt/file_swap bs=1024 count =1000000
Step 2: àJust as with partition swaps, you can now create a swap space specifying the device file just created
#mkswap /mnt/file_swap
Step 3: ---->Enable the swap
#swapon / mnt/file_swap
Step 4: à Again you can verify that the swap is enabled
#swapon –s
Note: The big difference between the two swap types is that file swap is easier to manage because you can just move the swap file to another disk if you want. The swap partition would need to be removed re-created, and so on. Although Red Hat recommends using a partition swap, file swaps are fast enough these days with less administrative overhead to not use them instead. One word of caution, though, is that you can use only one swap (of either type) per physical disk.
mount mounts a file system umount
unmounts a file system
Step 1): ---->start by going to the /opt directory, where you can make some directories to serve as a mount point.
#cd /opt
#mkdir company_data
#mkdir backup
Syn: mount [options] [device] [mount_point]
r ----> mounts as read – only
W ----> mounts as read/write (the default)
L ----> LABEL MOUNTS the file system with the name LABEL
V ----> Provides verbose output
Step 2: Mount the two file systems
#mount /dev/sda 6 /opt/company_data
#mount/dev/sda7 /opt/backup
Step 3: à to unmount a file system:
Syn: umount [options] [mount_point]
f ----> force unmount.
v ----> provides verbose output
Step 4): àYou can use the “Fuser and lsof” commands to check for open files and users that are currently using files on a file system
Syn: Fuser [options] [Mount_point/file system]
c ----> checks the mounted file system
k ----> Kills processes using the file system
m ----> shows all processes using the file system.
u ----> Displays user IDs
v ----> Verbose output
#fuser –cu/dev/sda6 (or) #lsof /dev/sda6
#fuser –ck /opt/backup
# umount /opt/backup
Now you know how to mount and unmount file systems, but there is something else you need to look at. If you reboot your system right now, all the file systems that you just mounted will no longer be available when the system comes back up. Why? The mount command is not persistent, so anything that is mounted with it will no longer be available across system reboots. I suppose you want to know how to fix that, right the system looks at two config files
#cat /etc/mtab
Every time you mount or unmount a file system, this file is updated to always reflect what is currently mounted on the system
#cat /etc/mtab/grep backup
#mount
#cat/etc/fstab
#vim/etc/fstab
:Wq!
#mount – a
Label: Labels enable you to determine a specific file system more easily with a common name, instead of /dev/sda6. An added benefit is the system’s being able to keep its label even if the underlying disk is switched with a new one.
Step 1: ----> Take your file system offline
#umount /dev/sda6
Step 2: ----> Let’s label the file system data to denote that it’s the company_data file system.
#e2label /dev/sda6 CData
Step 3: ----> You can use the same command to also verify:
#e2label /dev/sda6
Step 4: ---->Find the file system you just labeled
Syn: findfs LABEL=<label>/UUID=<uuid>
#findfs LABEL = cdata
àYou can also query more information about the device using the blkid command.
Syn: blkid [options]
-s ----> Shows specified tag (s)
Dev ----> specifies the device to probe.
Step 5: ----> Combine the blkid cmd with grep for specific results
#blkid / grep CData
Step 6: ----> When you finish your maintenance, you can remount the file system with the new Label instead of the device path:
#mount LABEL = Cdata /opt/company_data
---->You could even update the /etc/fstab file to use the label information instead of the device path.
#vim/etc/fstab
LABEL = CData /opt/company-data Ext3 defaults ʘ ʘ
: Wq!
---->you can use the mount command to verify the label names
#mount – l
---->you also can use the df command to view the usage information for your file systems,
Syn: df [options]
Step 1: To install the quota package
#yum install – y quota
Step 2: Verify that the package was installed successfully
Step 3: you can query quota support from the kernel with the following command
#grep – I config_quota /boot /config – ‘uname –r’
Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training
Step 1: open the /etc/fstab file, edit the following line
/dev/sda6 /opt/company_data Ext3 defaults, useruota, grpquota
:wq!
Step 2: you can accomplish this by using the mount command:
#mount -o remount /opt/company_data
Step 3: You can verify that the mount and quota options took correctly
#mount/grep company-data
There are two files that maintain quotas for users and groups.
1. Aquota.users users quota file.
2. Aquota.group group quota file.
Step 4: to start the quota system, you use the quotacheck cmd.
Syn: quotacheck [options][Partition]
-c ----> Don’t read existing quota files
-u ----> checks only user quotas
-g ----> checks only group quotas
-m ----> doesn’t remount the file system as read-only.
-v ----> provides verbose output.
#quotacheck -ugm /opt/company-data
#ls /opt/company-data
Step 5: Run the cmd manually the first time just to make sure that quotas turned on:
Soft limit: Has a grace period that acts as an alarm, signaling when you are reaching your limit. If your grace period expires, you are required to delete files until you are once again under your limit.
Hard limit: Required only when a grace period exists for soft limits. If the hard limit does exist, it is the maximum limit that you can hit before your grace period expires on the soft limit.
Step 6: Set the limits for user 1 by using the edquota cmd.
Syn: edquota [-u/-g] [username/groupname] #edquota -u user 1 File system blocks soft hard inodes soft hard /dev/sda6 o 20000 25000 0 0 0
Step 7: Again, you use the eduquota cmd, but with a different option:
#edquota –t
Tip: The edquota cmd offers a pretty cool feature. After you configure a quota and your limits for a single user, you can actually copy this over to other users as if it were a template. To do this, specify the user you want to use as a template first and call the eduquota cmd with the –p option. # edquota –up user1 user2 user3
Step 8: quota usage Reports:
Syn: repquota [options] [partitions]
-a ----> Reports on all non-NFS file systems with quotas turned on
-u ----> Reports on user quotas
-g ----> Reports on group quotas.
-v ----> verbose output. #repquota
-uv /opt/company-data
Step 1: Installing the required package
#yum install – y acl
Step2: Verify the package installation:
#rpm -qa/grep acl
Step3: Before you can even use ACL’s however, you need to make sure that the file system has been mounted with ACL parameter:
#mont/grep acl
Step4: You can accomplish this using the following
#mount – t ext3 – 0 acl, remount /dev/sda 7 /opt/Bacup
Step5: If your file system isn’t already mounted, you could also use the following.
#mount –t ext3 –o acl /dev/sda7 /opt/backup
Step6: To verify, you can use the previous cmd:
#mount /grep acl
Step7:adjust the following line in your /etc/fs tab file /dev/sda7 /opt/backup ext3 defaults, acl 1 :wq!2
Step 8: To make the changes take effect, you need to remount the file system
# mont -o remount /opt/backup
Now verify that your file system has the ACL options:
# mount/grep -I acl
Getfacl obtains the ACL from a file or directory
Setfacl sets or modifies an ACL
#cd /opt/backup
#touch file1
Syn: getfacl [options] file
d ----> Displays the default ACL
R ----> Recurses into subdirectories.
#getfacl file1
Syn: setfacl [options] file
m ----> Modifies on ACL
x ----> Removes an ACL
n ----> Doesn’t recalculate the mask
R ----> Recurses into subdirectories
Step 2:
Set the test file so that user 1 also has access to this file
# set facl -m u: suer 1: rwx /opt/backup/file1
To check the ACL permissions again:
# getfacl file1
Step 3: To remove the ACL for user1:
#Setfacl -x u:user1 /opt/backup/file1
Verify the ACL has been removed:
#getfacl file1
File permissions and ACL’s can get really complex if they aren’t throught out ahead of time.
Step4: If you have multiple ACL set up on a single file, you can remove them all with the - -b option instead of removing them one by one:
#Setfacl -b ----> test file
Step 1: Install the required packages:
#yum install –y lvm*
Step 2: Verify that it is installed
#rpm –qa / grep lvm
Step 3: Creating an Lvm partition; (four partitions)
#fdisk /dev/sda
----> To update to kernel for rereading #partprobe /dev/sad
Step4: To create physical volumes:
#pvcreate /dev/sda{10,11,12,13} ----> verify that the physical volume was created successfully; #pvdiselay /dev/sda10
Step5: To create a volume group:
#Vgcreate india /dev/sda{10,11,12}
----> Verify that the volume group was created successfully:
#vgdisplay –v India
----> when volume groups are created and initialized, the physical volumes are broken down into physical extends (the unit of measurement for LVM). This is significant because you can adjust the size of how data is stored based on the size of each physical extend, defined when the volume group is created (the default is 4MB).
Step 6: Create logical volumes:
----> To create a logical volume, use the lucrative cmd and specify the size of the partition that you’d like to create. The size can be specified in kilobytes, megabytes, gigabytes, or logical extents (LE). Like physical extents, logical extents are a unit of measure when dealing with logical volumes.
----> Create a partition 2GB in size
#lvcreate -L 2000 India -nap ----> New
----> To verify logical volume info
#lvdisplay ----> (or) #lvs
---->To create one more logical volume
#lvcreate -L 3000 -n India mp
---->Using the Lvrename cmd you can change the name of a logical partition
#lvrename /dev/india/mp /dev/india/up
---->Verify with the following cmd
#lvdisplay
The single best feature of LVM is that you can reduce or expand your logical volumes and volume groups. If you are running out of room on a particular logical volume (or) volume group, you can add another physical volume to the volume group and then expand & logical volume to give you more room.
Step 1: Add 2GB more to the ap logical volume
#lvextend -L +2000 /dev/india/ap
(or)
#lvextend -L 2000 /dev/india/ap
---->verify the change with the following cmd:
#lvdisplay India
Step 2: To decrease a logical volume
#lvresize -L 2000 /dev/india/ap
(or)
#lvreduce -L -2000 /dev/india/ap
Step 3: ---->Suppose, though, that you want to add a new physical volume so that you can extend your volume group.
---->Create a new physical volume somewhere
#pvcreate /dev/sda 15
---->Now extend your volume group to incorporate that new physical volume
#vgextend India /dev/sda 15
---->Now verify the details of the newly increase vg:
#vgdisplay -v india
Step 4: To reduce the volume group to no longer include the physical volume /dev/ sda15, you can use the vgreduce cmd:
#vgreduce India /dev/sda 15
---->Now verify expansion or reduction of volume groups
#vgdisplay India
Suppose you have a drive that is old or dying and you’d like to remove it from the system. On a system with normal partitions, you would have to copy all the data from one disk to another while the disk is offline (because of file locks). Having LVM makes this easier because you can migrate your data from one disk to another, even while the disk is online! This capability is very useful when you need to replace a disk
àIf you want to replace /dev/sda14 (dev/sda) because it’s failing, you can use the pvmove cmd to migrate the physical extents (which is really your data to another physical volume (/dev/sda 14) (/dev/sdb)
Step 1: To create the physical volume
#pucreate /dev/sda 15
Step 2: You need to add back /dev/sda15 to the vg:
#vgextend India /dev/sda 15
Step 3: Also create a logical volume to hold the migrate data:
#lvcreate -l 3000 India -n ban
Step 4: Verify all logical volumes are in place
#lvdisplay india
Step 5: Migrate the data from the “dying” drive
#pvmove /dev/sda14 /dev/sda15
(/dev/sda) (dev/sdb)
Note: Make sure that you have more than one physical volume; otherwise there will be nowhere for the data to move.
Step 6: Verify that physical volume is empty #pvdisplay /dev/sda 14 (/dev/sda)
It was just as important to understand how to delete LVM partitions as it to create them. This is a common task when you are upgrading or redesigning a file system layout.
Step 1: To remove a logical volume
#lvremove /dev/india/ap
---->Although this advice should common sense, make sure you back up any data before deleting anything within the LVM structure.
Step 2: ---->To remove the volume group
#vgremove India
àYou can also do both steps in one cmd by using the –f option
#vgremove –f India
Step 3: Wipe all the current physical volumes:
#pvremove /dev/sda10
#pvremove /dev/sda 11
Note: use the resize 2fs cmd to extend the file system. Before extending the file system, however, you should always ensure the integrity of the file system first with the e2fsck
Step 1: Syn: e2fsck [options] [device]
p ----> automatically repairs (no questions)
n ----> Makes no changes to the file system
y ----> Assumes “yes” to all questions
f ----> Force checking of the file system
v ----> provides verbose output
àcheck the file system
#e2fsck -f /dev/india/ap
Step 2: Syn: resize2fs [options] [device]
p ----> prints percentage as task complete
f ----> Force the cmd to proceed
àExtend the underlying logical volume:
#lvextend -l 3000 /dev/India/ap
àNow you can extend the file system
#resize2fs -p /dev/India/ap
Step 3: àNow that your maintenance is complete, remount the file system;
#mount /dev/india/ap/mnt
àyou can use the mount cmd to verify it mounted successfully:
#mount
àNow you can use the df cmd to view the usage information for your file systems. This should also reflect the additional space that you just added to the /mnt file system.
Syn: df ----> [options]
h ----> specifies human-readable format
T ----> prints the file system type
#df ----> -h
RAID: Now let’s move on to the final type of advanced partitioning: RAID
---->RAID means redundant Array of Independent Disk
---->RAID partitions allow for more advanced features such as redundancy and better performance.
---->Mainly we implement the Raid in order to increase the storage capacity along with data security.
---->There are two types of RAID’s
---->While RAID can be implemented at the hardware level, the Red Hat exams are not hardware-based and therefore focus on the software implementation of RAID through the MD driver.
---->Before we describe how to implement RAID, let’s look at the different types of RAID.
RAID 0: (Striping) Disks are grouped together to form one large drive. This offers better performance at the cost of availability. Should any single disk in the RAID fail, the entire set of disks becomes unusable.
RAID 1: (Mirroring) Disks are copied from one to another, allowing for redundancy. Should one disk fail, the other disk takes over, having an exact copy of data from the original disk
RAID5: (Striping with parity) Disks are similar to RAID 0 and are joined together to form one large drive. The difference here is that 25% of the disk is used for a parity bit, which allows the disks to be recovered should a single disk failure.
Step 1: Install the following package
#Yum install –y mdadm
Step 2: Verify the install
#rpm –qa/grep madadm
---->To start, you first need to create partitions on the disk you want to use. You start with a RAID 5 setup, so you need to make partitions on at least three different disks.
---->Create three partitions 3fdsk /dev/sda
---->To verify when you’re done #fdisk -l
---->Now you can begin to set up the RAID 5 array with the three partitions
Step 1: Syn: mdadm [options]
a ----> Add a disk into a current array
c ----> create a new RAID array
D ----> prints the details of the array
f ----> fails a disk in the array
l ----> specifies the level of Raid array to create
n ----> specifies the devices in the RAID array.
S ----> stops an array
A ----> Activate an array
V ----> provides verbose output.
#mdadm -cv /dev/mdo –n3 /dev/sda1 /dev/sdb1 /dev/sdc1 -l5
Step 2: Again to verify that the RAID array has been created successfully
#mdadm -D /dev/mdo
Step 3: View the status of the newly created RAID array:
#cat /proc/mdstat
This output shows that you have an active RAID 5 array with three disks. The last few lines here show the state of each disk and partition in the RAID array. You can also see that the RAID is in “Recovery” mode, or creating itself.
Step 4: If you wait the estimated 2.9 minutes and then query again, you see the following
#cat /proc/mdstat
You now see that the RAID is good to go as it has finished building itself
Suppose that a disk in the array failed. In that case, you need to remove that disk from the array and replace it with a working one.
Step 1: manually fail a disk in the array,
#mdadm /dev/mdo -f /dev/sdc1
Step 2: verify that the disk in the array has failed
#mdadm -D /dev/mdo
Step 3: To remove a disk from the array
#mdadm /dev/mdo -r /dev/sdc 1
Step 4: Look at the last few lines of the RAID details again
#mdadm -D /dev/mdo
---->If you want, you could combine the previous two commands
#mdadm -v /dev/mdo -f /dev/sdc 1 -r /dev/sdc 1
Step 5: When the disk is partitioned, you can add it back to the array
#mdadm /dev/mdo -a /dev/sdd 1
---->Verify that it has been added properly #mdadm –D /dev/mdo
Step 6: query the kernel #cat / proc /mdstat
Step 7: Should something go seriously wrong and you need to take the RAID array offline completely
#mdadm -vs /dev/mdo
Step1: To delete an array, first stop it
#mdadm -vs /dev/mdo
Step2: Then remove the RAID array device
#mdadm -r /dev/mdo
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.