0% found this document useful (0 votes)
26 views

XFS File System

Uploaded by

fast2win2029
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

XFS File System

Uploaded by

fast2win2029
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Just wanted to share and spread a word about a new FS introduced in Redhat ES 7 and

also the intention to take on some knowledge sharing.

Curious about XFS (Extent File system) ??

XFS(Extent File system) is a default root filesystem in Redhat Linux ES 7 onwards (Linux
Kernel with version 2.4). This might indicates Redhat shifting their “ext” FS paradigm to
XFS going forward.

XFS filesystem is originally developed by Silicon Graphics. XFS is a highly scalable,


high-performance file system compare to ext4 and it supports up to 16 exabytes
filesystem and 8 exabytes files. XFS supports metadata journaling, which facilitates
quicker crash recovery on the power failures and system crash. It can also be
defragmented and extended while mounted and active. It also supports quota.

BTW, It’s a default filesystem in IRIX too.

Some of the XFS features –

Some major advantages of XFS –

1. Handles large files much better and more efficiently than ext3.
2. Minimizes both storage access time (read/write) and processing power (very low CPU
usage).
3. Allows users to defrag files to further minimize read/write times.
4. Has been around for a long time, stable (ext4 is comparatively new)
Let’s take a deep dive into some of the practice examples –

Create a logical volume to format as XFS filesystem & mount it.

# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created

# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created

# vgcreate test /dev/sdb /dev/sdc


Volume group "test" successfully created

# vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 2 0 wz--n- 9.51g 0
test 2 0 0 wz--n- 3.99g 3.99g
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a-- 9.51g 0
/dev/sdb test lvm2 a-- 2.00g 2.00g
/dev/sdc test lvm2 a-- 2.00g 2.00g

# lvcreate -L 100 test


Logical volume "lvol0" created

# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy
%Sync Convert
root rhel -wi-ao---- 8.51g
swap rhel -wi-ao---- 1.00g
lvol0 test -wi-a----- 100.00m

Now that we have logical volume "lvol0" in place. Let us create a XFS filesystem using
mkfs.xfs command.

# mkfs.xfs /dev/test/lvol0
meta-data=/dev/test/lvol0 isize=256 agcount=32,
agsize=8473312 blks
= sectsz=512 attr=2,
projid32bit=0
data = bsize=4096
blocks=271145984, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=32768,
version=2
= sectsz=512 sunit=0 blks,
lazy-count=1
realtime =none extsz=4096 blocks=0,
rtextents=0

To create an XFS file system with a stripe-unit size of 32 KB and 6 units per stripe, you
would specify the su and sw arguments to the -d option, for example:

Page 2 of 5
# mkfs.xfs -d su=32k,sw=6 /dev/test/lvol1

Mounting XFS is quite the normal as we do –

# mkdir -p /first_xfs

# mount -t xfs /dev/test/lvol0 /first_xfs

# df -h /first_xfs
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/test-lvol0 84M 5.2M 79M 7% /first_xfs

Increase XFS filesystem

BTW, XFS can increase on the fly. You need to use xfs_grow command to do that. Let’s
try it –

# lvresize -L +100M /dev/test/lvol0


Extending logical volume lvol0 to 200.00 MiBs
Logical volume lvol0 successfully resized

# df -h /new_xfs/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/test-lvol0 84M 5.2M 79M 7% /first_xfs

# xfs_growfs /first_xfs
meta-data=/dev/mapper/test-lvol0 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
log =internal bsize=4096 blocks=4265,
version=2
= sectsz=512 sunit=0 blks, lazy-
count=1
realtime =none extsz=4096 blocks=0,
rtextents=0

data blocks changed from 25600 to 51200

# df -h /new_xfs/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/test-lvol0 184M 5.3M 179M 3% /first_xfs

One important note – you can’t shrink the XFS filesystem, The only way is to
destroy and recreate it then restore the data from backup.

How do I check the filesystem integrity? Is it same as fsck for XFS as well ?

No. There is no fsck for XFS but you have to use xfs_repair to do that. Before running
xfs_repair make sure you un-mount the filesystem.

Page 3 of 5
Warning: Do NOT run xfs_repair on a mounted filesystem! Serious data corruption can
occur if you dare try it!

Unless you are experiencing strange filesystem-related errors or crashes, you may never
need to run xfs_repair.

First umount your partition:

# umount /dev/sda3

Now that the partition is unmounted, issue the command to check/repair:

# xfs_repair /dev/sda3
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

When the check/repair is finished, remount your partition:

# mount /dev/sda3

XFS has several advance facilities/features so IO freeze is one of them.

# xfs_freeze -f /first_xfs

# df -h /first_xfs/
Filesystem Size Used Avail Use% Mounted on

Page 4 of 5
/dev/mapper/uavg-lvol0 184M 288K 184M 1% /first_xfs

Now we will do the test.

# cd /first_xfs
# touch foo
^C^C^C^C^C^C^C^X^C^C^C^C^C^C^C^C^C

Lastly I got the prompt after unfreeze the FS.

# xfs_freeze -u /first_xfs
#

This is a baby step towards understanding XFS filesystem & I’m sure our sysadmin
curious minds will explore this topic !!!

Page 5 of 5

You might also like