Hacks of xfs file system Part — 1

In this series I am going to show the usage of xfs powerful commands to do various operations on file system.

Case 1 : Creating file system with default parameters.

[root@dhcp234-186 ~]# mkfs.xfs /dev/vdb1

meta-data=/dev/vdb1 isize=256 agcount=4, agsize=32768 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=131072, 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

Mounting this file system on /xfs1.

[root@dhcp234-186 ~]# df -h /xfs1/

Filesystem Size Used Avail Use% Mounted on

/dev/vdb1 509M 26M 483M 6% /xfs1

Performing check by creating small files on it.

[root@dhcp234-186 ~]# cd /xfs1/

[root@dhcp234-186 xfs1]# for file in `seq 0 1000`; do echo $file > $file; done

[root@dhcp234-186 xfs1]# du -sk .

4040 .

Creating file system with modified parameters. We have changed the filesystem block size to 512 bytes and directory block size kept same 4096 bytes.

[root@dhcp234-186 ~]# mkfs -t xfs -f -b size=512 -n size=4096 /dev/vdb2

meta-data=/dev/vdb2 isize=256 agcount=4, agsize=256000 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=512 blocks=1024000, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=0

log =internal log bsize=512 blocks=4800, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

Mounting this file system on /xfs2.

[root@dhcp234-186 ~]# df -h /xfs2/

Filesystem Size Used Avail Use% Mounted on

/dev/vdb2 498M 4.8M 493M 1% /xfs2

[root@dhcp234-186 ~]# cd /xfs2/

[root@dhcp234-186 xfs2]# for file in `seq 0 1000`; do echo $file > $file; done

[root@dhcp234-186 xfs2]# du -sk .

537 .

You will see that in case of huge number of small files we can save the space by creating small filesystem block size.

Case 2 : Changing the stripe width and stripe unit size of file system.

[root@dhcp234-186 ~]# mkfs -t xfs -f -d sunit=256,swidth=2048 /dev/vdb1

meta-data=/dev/vdb1 isize=256 agcount=8, agsize=16352 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=130816, imaxpct=25

= sunit=32 swidth=256 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=0

log =internal log bsize=4096 blocks=1056, version=2

= sectsz=512 sunit=32 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

Case 3 : If we want to create file system using external logging device.

[root@dhcp234-186 ~]# mkfs -t xfs -f -l logdev=/dev/vdc1,size=128m /dev/vdb2

meta-data=/dev/vdb2 isize=256 agcount=4, agsize=32000 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=128000, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=0

log =/dev/vdc1 bsize=4096 blocks=32768, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

I tried to mount the file system but it was throwing the error.

[root@dhcp234-186 ~]# mount /dev/vdb2 /xfs2

mount: wrong fs type, bad option, bad superblock on /dev/vdb2,

missing codepage or helper program, or other error

In some cases useful info is found in syslog – try

dmesg | tail or so.

I was able to mount the file system by specifying the log device while mounting it.

[root@dhcp234-186 ~]# mount -o logdev=/dev/vdc1 /dev/vdb2 /xfs2

[root@dhcp234-186 ~]# df -h /xfs2/

Filesystem Size Used Avail Use% Mounted on

/dev/vdb2 500M 26M 475M 6% /xfs2

Note it will not show the logged device space in size of file system.

Case 4 : We know that when we are creating xfs file system the whole device space is getting divided into allocation groups just like in case of ext* file system it was getting divided into block groups.

We can control the number of allocation groups or the size of each allocation group.

Controlling number of allocation groups. Here I am controlling them to 32. Partition size is 512M.

Each AG size is 4096 blocks.

[root@dhcp234-186 ~]# mkfs.xfs -f -d agcount=32 /dev/vdb1

meta-data=/dev/vdb1 isize=256 agcount=32, agsize=4096 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=131072, 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

Controlling the size of allocation group. Keeping it as 8096 blocks will keep the AG Count to 16.

[root@dhcp234-186 ~]# mkfs -t xfs -f -d agsize=$((8096*4096)) /dev/vdb1

meta-data=/dev/vdb1 isize=256 agcount=16, agsize=8096 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=129536, 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

Case 5 : My partition size is of 512MB. I am creating 100MB xfs file system on it.

[root@dhcp234-186 ~]# mkfs -t xfs -f -d size=100m /dev/vdb1

meta-data=/dev/vdb1 isize=256 agcount=4, agsize=6400 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=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

I am expanding the file system size twice.

[root@dhcp234-186 ~]# xfs_growfs -D 51200 /xfs1/

meta-data=/dev/vdb1 isize=256 agcount=4, agsize=6400 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=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

data blocks changed from 25600 to 51200

[root@dhcp234-186 ~]# xfs_info /xfs1

meta-data=/dev/vdb1 isize=256 agcount=8, agsize=6400 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=51200, 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

Notice the difference between this output and output taken at starting of this case.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s