RHEL7: Create, mount, unmount, and use vfat, ext4 and xfs file systems.

Share this link

Note: This is an RHCSA 7 exam objective.

Prerequisite

To create a new partition called lv_vol with a size of 100MB, type:

# lvcreate --size 100M --name lv_vol /dev/vg

Ext4 File System

To create an ext4 file system (here called /dev/vg/lv_vol), type:

# mkfs.ext4 /dev/vg/lv_vol
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done 

To mount this file system, type:

# mount /dev/vg/lv_vol /mnt

To mount it permanently, edit the /etc/fstab file and add the following line:

/dev/mapper/vg-lv_vol /mnt ext4 defaults 1 2

Note1: The last number (here 2) is related to the fsck command: ‘0‘ means no fsck run at boot (very dangerous), ‘1fsck is run first (root filesystem), ‘2fsck is run just after the root filesystem. The second to last argument is in relation with the dump command (normally set at ‘1‘ for real filesystems, ‘0‘ for swap and NFS mounted filesystems).
Note2: A best practice is to execute the mount -a command, each time you change something in the /etc/fstab file to detect any boot problem before it occurs.

To check an unmounted file system consistency, type:

# fsck /dev/vg/lv_vol
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/mapper/vg-lv_vol: clean, 11/25688 files, 8896/102400 block

To get details about a file system, type:

# dumpe2fs /dev/vg/lv_vol
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:   
Last mounted on:          
Filesystem UUID:          de13176f-6816-47e8-8742-2d543003d382
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              25688
Block count:              102400
Reserved block count:     5120
Free blocks:              93504
Free inodes:              25677
First block:              1
Block size:               1024
Fragment size:            1024
Group descriptor size:    64
Reserved GDT blocks:      256
Blocks per group:         8192
Fragments per group:      8192
Inodes per group:         1976
Inode blocks per group:   247
Flex block group size:    16
Filesystem created:       Tue Jul 29 17:47:36 2014
Last mount time:          Tue Jul 29 17:48:56 2014
Last write time:          Tue Jul 29 17:48:56 2014
Mount count:              1
Maximum mount count:      -1
Last checked:             Tue Jul 29 17:47:36 2014
Check interval:           0 ()
Lifetime writes:          4447 kB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:	          128
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      1780d5a3-72df-4cc4-ba19-4a6915c064e3
Journal backup:           inode blocks
Journal features:         journal_64bit
Journal size:             4096k
Journal length:           4096
Journal sequence:         0x00000002
Journal start:            1
...

Xfs File System

To create an xfs file system (here called /dev/vg/lv_vol), type:

# mkfs.xfs /dev/vg/lv_vol
meta-data=/dev/vg/lv_vol         isize=256    agcount=4, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=25600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

To mount this file system, type:

# mount /dev/vg/lv_vol /mnt

To mount it permanently, edit the /etc/fstab file and add the following line:

/dev/mapper/vg-lv_vol /mnt xfs defaults 1 2

Note: The last number (here 2) is related to the fsck command: ‘0‘ means no fsck run at boot (very dangerous), ‘1fsck is run first (root filesystem), ‘2fsck is run just after the root filesystem. The second to last argument is in relation with the dump command (normally set at ‘1‘ for real filesystems, ‘0‘ for swap and NFS mounted filesystems).
Note2: A best practice is to execute the mount -a command, each time you change something in the /etc/fstab file to detect any boot problem before it occurs.

To repair an unmounted file system consistency, type:

# xfs_repair /dev/vg/lv_vol
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
Phase 5 - rebuild AG headers and trees...
        - reset superblock...
Phase 6 - check inode connectivity...
        - resetting contents of realtime bitmap and summary inodes
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done

To get details about a mounted file system, type:

# xfs_info /dev/vg/lv_vol
meta-data=/dev/mapper/vg-lv_vol isize=256    agcount=4, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=25600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Vfat File System

To create an vfat file system (here called /dev/vg/lv_vol), type:

# mkfs.vfat /dev/vg/lv_vol
mkfs.fat 3.0.20 (12 Jun 2013)
unable to get drive geometry, using default 255/63

To mount this file system, type:

# mount /dev/vg/lv_vol /mnt

To mount it permanently, edit the /etc/fstab file and add the following line:

/dev/mapper/vg-lv_vol /mnt vfat defaults 1 2

To repair an unmounted file system consistency, type:

# fsck.vfat /dev/vg/lv_vol
fsck.fat 3.0.20 (12 Jun 2013)
/dev/vg/lv_vol: 0 files, 0/51091 clusters

Useful Tip

The time to create a filesystem has been dramatically reduced between Ext3 and Ext4 (by a factor of 100). However, although the creation time is now very quick, a process in the background continues to work for several minutes (according to the size of the filesystem)!

This process called ext4lazyinit creates the remaining index nodes which are used to reference leaf nodes, kind of pointers to data on the filesystem.

Although definitively not required for the RHCSA exam, you can create an ext4 filesystem without this behavior by typing:

# mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/vg/lv_vol

Source: Red Hat.

Additional Resources

You can also watch Ralph Nyberg‘s video about Creating file systems and making them accessible (19min/2015).
Beyond the exam objective, you can read a page about dealing with XFS filesystem corruption or converting an existing root filesystem to a LVM partition.
Daniel Aleksandersen wrote an article discussing What to do when a Linux system is running out of available inodes.

(2 votes, average: 4.00 out of 5)
Loading...
7 comments on “RHEL7: Create, mount, unmount, and use vfat, ext4 and xfs file systems.
  1. pawel says:

    There is no mkfs.vfat command on minimal CentOS7 installation.
    You can run:

    # yum provides mkfs.vfat

    to get the package name you need to install before using this tool

  2. redhat0329 says:

    Hi CertDepot,

    I’m creating a file system mkfs.xfs type and I encounter this error

    mkfs.xfs: cannot open /dev/sdb1 :Device or resource busy

    Any tips? I’ve run partprobe command and reboot but still no avail.

    Thanks in advance.. 🙂

    • CertDepot says:

      Sorry, I don’t know.

      • redhat0329 says:

        Hi CertDepot,

        Sorry for the late response.
        I already fixed this btw, my bad, I’ve created a virtual disk /dev/sdb device and made it as a xfs file system and mounted it persistently at boot. That’s why after creating disk partition /dev/sdb1 and create a xfs file system onto it I’ve got the error ‘Device or resource busy’. I must not done this kind of config anyway.

  3. Ahmad says:

    Hi

    when I tried mkfs.vfat , I faced the below error:

    unable to get drive geometry, using default 255/63

    I see that you are facing the same issue above in the article.
    Any idea, is this normal?

    Also, I am not able to get UUID using blkid.
    How to get UUID using blkid for vfat?

    Thanks

    • CertDepot says:

      Concerning the error message, I think it is completely normal. However, I don’t know the exact reason.
      According to this thread, Linux would ignore disk geometry since kernel 3.0.
      Concerning your question about getting UUID using the blkid command, when creating a vfat volume called lv_test of 100MB, I get the following display:
      # blkid | grep lv_test
      /dev/mapper/centos-lv_test: SEC_TYPE=”msdos” UUID=”E719-28CA” TYPE=”vfat”

Leave a Reply

Upcoming Events (Local Time)

There are no events.

Follow me on Twitter

Archives

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |