Wise people learn when they can; fools learn when they must - Arthur Wellesley

Friday, 25 November 2016

LINUX-4 YOUR FILE SYSTEM (XFS)




    LINUX-4 YOUR FILE SYSTEM (XFS)


XFS is a highly scalable, high-performance file system which was originally designed at Silicon Graphics, Inc. XFS is the default file system for Red Hat Enterprise Linux 7
Main Features
XFS supports metadata journaling, which facilitates quicker crash recovery. The XFS file system can also be defragmented and enlarged while mounted and active. In addition, Red Hat Enterprise Linux 7 supports backup and restore utilities specific to XFS.

  • XFS is designed for large file systems and large file handling.
  • XFS has on-line defragmentation tools
  • XFS dramatically reduces start-up time by avoiding fsck delays.
  • XFS has fast file system creation.
  • XFS formatted disk capacity is greater than Ext3/4 even after removing the reserved blocks from the Ext3/4 file system
  • ability to manage up to 500TB file systems with files up to 50TB in size,
  • best performance for most workloads (especially with high speed storage and larger number of cores),
  • less CPU intensive than most of the other file systems (better optimizations around lock contention, etc),
  • the most robust at large scale (has been run at hundred plus TB sizes for many years),
  • the most common file system in multiple key upstream communities: most common base for ceph, gluster and openstack more broadly,
  • pioneered most of the techniques now in Ext4 for performance (like delayed allocation),
  • no file system check at boot time,
  • CRC checksum on all metadata blocks.
Other XFS Features
The XFS file system support:
Extended attributes (xattr)
This allows the system to associate several additional name/value pairs per file. It is enabled by default.
Quota journaling
This avoids the need for lengthy quota consistency checks after a crash.
Project/directory quotas
This allows quota restrictions over a directory tree.
Subsecond timestamps
This allows timestamps to go to the subsecond



Common Commands for ext3/4 and XFS
Task
ext3/4
XFS
Create a file system
mkfs.ext4 or mkfs.ext3
mkfs.xfs
File system check
e2fsck
xfs_repair
Resizing a file system
resize2fs
xfs_growfs
Save an image of a file system
e2image
xfs_metadump and xfs_mdrestore
Label or tune a file system
tune2fs
xfs_admin
Backup a file system
dump and restore
xfsdump and xfsrestore



How to know that which FS we are using,

[root@rhel7-server ~]# mount | grep "^/dev"
/dev/sda5 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sdb1 on /tdir1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda3 on /home type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sdd1 on /tdir2 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sde1 on /tdir3 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

[root@rhel7-server ~]# file -sL /dev/sda1
/dev/sda1: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)

[root@rhel7-server ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda5      xfs        15G  6.7G  8.0G  46% /
devtmpfs       devtmpfs  488M     0  488M   0% /dev
tmpfs          tmpfs     496M   80K  496M   1% /dev/shm
tmpfs          tmpfs     496M  7.2M  489M   2% /run
tmpfs          tmpfs     496M     0  496M   0% /sys/fs/cgroup
/dev/sdb1      xfs      1014M   33M  982M   4% /tdir1
/dev/sda3      xfs      1014M   33M  982M   4% /home
/dev/sda1      xfs       697M  123M  575M  18% /boot
/dev/sdd1      xfs      1014M   33M  982M   4% /tdir2
/dev/sde1      xfs       497M   26M  472M   6% /tdir3


[root@rhel7-server ~]# fsck -N /dev/sdd1
fsck from util-linux 2.23.2
[/sbin/fsck.xfs (1) -- /tdir2] fsck.xfs /dev/sdd1

[root@rhel7-server ~]# cat /etc/fstab

XFS INFO:

[root@rhel7-server ~]# xfs_info /dev/sde1
meta-data=/dev/sde1              isize=256    agcount=4, agsize=32000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=128000, 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

XFS CHECKING & REPAIRING:

[root@rhel7-server ~]# xfs_repair
Usage: xfs_repair [options] device

Options:
  -f           The device is a file
  -L           Force log zeroing. Do this as a last resort.
  -l logdev    Specifies the device where the external log resides.
  -m maxmem    Maximum amount of memory to be used in megabytes.
  -n           No modify mode, just checks the filesystem for damage.
  -P           Disables prefetching.
  -r rtdev     Specifies the device where the realtime section resides.
  -v           Verbose output.
  -c subopts   Change filesystem parameters - use xfs_admin.
  -o subopts   Override default behaviour, refer to man page.
  -t interval  Reporting interval in seconds.
  -d           Repair dangerously.
  -V           Reports version and exits.

If only checking required then use “-n” flag


[root@rhel7-server ~]#
[root@rhel7-server ~]# xfs_repair /dev/sde1
xfs_repair: /dev/sde1 contains a mounted filesystem
xfs_repair: /dev/sde1 contains a mounted and writable filesystem

fatal error -- couldn't initialize XFS library
[root@rhel7-server ~]# umount /tdir3
[root@rhel7-server ~]#
[root@rhel7-server ~]# xfs_repair /dev/sde1
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
[root@rhel7-server ~]#


SUSPEND XFS:

[root@rhel7-server /]# cd tdir2

[root@rhel7-server tdir2]# touch f1

[root@rhel7-server tdir2]# ls -l
total 0
-rw-r--r--. 1 root root 0 Nov 25 12:14 f1

[root@rhel7-server tdir2]# xfs_freeze -f /tdir2

[root@rhel7-server tdir2]# touch f2
It is in hung like situation…

Ctrl+c is also not working,

[root@rhel7-server ~]# ps -elf |grep -i touch
0 D root      7119  7035  0  80   0 - 26980 sb_sta 12:14 pts/2    00:00:00 touch f2
0 R root      7359  7133  0  80   0 - 28160 -      12:28 pts/1    00:00:00 grep --color=auto -i touch
[root@rhel7-server ~]#

From another terminal…

[root@rhel7-server ~]# xfs_freeze -u /tdir2
And bingo…
[root@rhel7-server tdir2]# ls -l
total 0
-rw-r--r--. 1 root root 0 Nov 25 12:14 f1
-rw-r--r--. 1 root root 0 Nov 25 12:29 f2

TO BE CONTINUED…………………………………………….


No comments:

Post a Comment