btrfs or Butter FS is a filesystem and has some interesting features:

 

  • One can have FS snapshots. It is like a freeze of the filesystem at some point of time.
  • btrfs is a extent-based filesystem. This means there are no lists of pointers. btrfs tracks contiguous blocks.
  • btrfs makes checksums of data and metadata. Therefore it can detect errors in the filesystem in “realtime”.
  • One can switch from ext3/4 to btrfs.

 

Some users may want to use the BTRFS file system instead of ext2/ext3/ext4 filesystems. This post explains how to convert ext2/ext3/ext4 filesystems to btrfs.

 

Converting Ext File Systems to Btrfs

 

Btrfs supports the conversion of ext2, ext3, and ext4 file systems to Btrfs file systems. The original ext file system metadata is stored in a snapshot named ext#_saved so that the conversion can be reversed if necessary.

 

Use the btrfs-convert utility to convert an ext file system. Always make a backup copy before converting a file system. To convert a non-root ext file system, perform the steps listed below.

 

1. Unmount the ext file system.

# df -hP /data
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda

 

# umount /data

 

2. Use fsck to check the integrity of the ext file system.

# fsck /dev/sda 
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/sda: clean, 11/655360 files, 83137/2621440 blocks

 

3. Use the btrfs-convert utility to convert the file system.

# btrfs-convert /dev/sda
create btrfs filesystem:
	blocksize: 4096
	nodesize:  16384
	features:  extref, skinny-metadata (default)
creating ext2 image file
creating btrfs metadatacopy inodes [o] [         2/        11]
conversion complete

 

4. Edit /etc/fstab and change the file system type to btrfs.

# vi /etc/fstab
UUID=e5b5c118-fb56-4fad-a45d-ff5fad9a649d /data           btrfs   defaults      0  0

 

5. Mount the converted file system on the original mount point.

# mount /dev/sda /data

 

6. Verify the new filesystem type in “mount” command.

# df -hP /data
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda         10G  342M  9.7G   4% /data

 

# mount | grep data
/dev/sda on /data type btrfs (rw,relatime,seclabel,space_cache,subvolid=5,subvol=/)

 

Note:

You cannot convert the root file system or a bootable partition, such as /boot, to Btrfs. 

 

هل كانت المقالة مفيدة ؟ 0 أعضاء وجدوا هذه المقالة مفيدة (0 التصويتات)