Glimpse of btrfs File System Part — 1

In this article I am going to show you the basic usage of btrfs file system. It is present in RHEL 7 but its not recommended to be used in production.

Major feature of this file system it is having in built RAID facility like zfs file system which commonly is in use on Solaris 10,11

I will create RAID 1 configuration here and will perform all the subsequent actions on it.

Case 1 : Created RAID 1 file system using two disks each having partition of 512Mb.

[root@localhost ~]# mkfs.btrfs -m raid1 -d raid1 /dev/sdf1 /dev/sdg1

WARNING! – Btrfs v0.20-rc1 IS EXPERIMENTAL
WARNING! – see http://btrfs.wiki.kernel.org before using

SMALL VOLUME: forcing mixed metadata/data groups
Created a data/metadata chunk of size 8388608
adding device /dev/sdg1 id 2
fs created label (null) on /dev/sdf1
nodesize 4096 leafsize 4096 sectorsize 4096 size 1.00GB
Btrfs v0.20-rc1

Checking the detail of created file system.

[root@localhost ~]# btrfs fi show
Label: none  uuid: cf73a753-f541-4abb-a519-989d011671fd
Total devices 2 FS bytes used 28.00KB
devid    2 size 512.00MB used 72.00MB path /dev/sdg1
devid    1 size 512.00MB used 84.00MB path /dev/sdf1

Btrfs v0.20-rc1

Case 2 : We can mount the btrfs file system using any of the disk which is part of the filesystem. As in our case sdg1 and sdf1 are part of file system hence I can mount file system using any of them and even both of them simultaneously.

[root@localhost ~]# mount /dev/sdg1 /btrfs1/
[root@localhost ~]# mount /dev/sdf1 /btrfs2
[root@localhost ~]# df -h /btrfs*
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdf1       1.0G   64K  984M   1% /btrfs1
/dev/sdf1       1.0G   64K  984M   1% /btrfs2

If I am creating any file in one of them it will be visible in second as well.

[root@localhost ~]# cd /btrfs1/
[root@localhost btrfs1]# touch file1 file2
[root@localhost btrfs1]# ll
total 0
-rw-r–r–. 1 root root 0 Nov 22 08:07 file1
-rw-r–r–. 1 root root 0 Nov 22 08:07 file2
[root@localhost btrfs1]# cd /btrfs2/
[root@localhost btrfs2]# ll
total 0
-rw-r–r–. 1 root root 0 Nov 22 08:07 file1
-rw-r–r–. 1 root root 0 Nov 22 08:07 file2

Case 3 : Checking the statistics of disks which are part of btrfs FS.

[root@localhost btrfs2]# btrfs device stats /dev/sdg1
[/dev/sdg1].write_io_errs   0
[/dev/sdg1].read_io_errs    0
[/dev/sdg1].flush_io_errs   0
[/dev/sdg1].corruption_errs 0
[/dev/sdg1].generation_errs 0

Case 4 : Adding new disk to existing setup.

[root@localhost ~]# btrfs device add /dev/sdh1 /btrfs1/

[root@localhost ~]# btrfs fi show
Label: none  uuid: cf73a753-f541-4abb-a519-989d011671fd
Total devices 3 FS bytes used 32.00KB
devid    3 size 512.00MB used 0.00 path /dev/sdh1
devid    2 size 512.00MB used 72.00MB path /dev/sdg1
devid    1 size 512.00MB used 84.00MB path /dev/sdf1

Btrfs v0.20-rc1

As soon as we add the disk file system size in df output will show increased value but available space actually will not exceed until we are doing the balancing of data. I will show later in this next article about it.

[root@localhost ~]# df -h /btrfs2/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdf1       1.5G   64K 1006M   1% /btrfs2

Case 5 : Removing the device from configuration.

[root@localhost ~]# btrfs device delete /dev/sdh1 /btrfs1/

[root@localhost ~]# btrfs fi show
Label: none  uuid: cf73a753-f541-4abb-a519-989d011671fd
Total devices 3 FS bytes used 32.00KB
devid    2 size 512.00MB used 72.00MB path /dev/sdg1
devid    1 size 512.00MB used 84.00MB path /dev/sdf1
*** Some devices missing

Btrfs v0.20-rc1

Case 6 : Replacing the device present in btrfs with another device of same size.

[root@localhost ~]# btrfs replace start /dev/sdg1 /dev/sdh1 /btrfs1/

[root@localhost ~]# btrfs fi show
Label: none  uuid: cf73a753-f541-4abb-a519-989d011671fd
Total devices 2 FS bytes used 32.00KB
devid    2 size 512.00MB used 72.00MB path /dev/sdh1
devid    1 size 512.00MB used 84.00MB path /dev/sdf1

Btrfs v0.20-rc1

We will be able to  see the contents in new drive after the syncing is complete.

[root@localhost ~]# mount /dev/sdh1 /btrfs1/
[root@localhost ~]# cd /btrfs1/
[root@localhost btrfs1]# ll
total 0
-rw-r–r–. 1 root root 0 Nov 22 08:07 file1
-rw-r–r–. 1 root root 0 Nov 22 08:07 file2
If we want to check the status of replacement below command can be issued.

[root@localhost btrfs1]# btrfs replace status /btrfs1/
Started on 22.Nov 08:16:28, finished on 22.Nov 08:16:28, 0 write errs, 0 uncorr. read errs

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