• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Convert Ext File Systems to Btrfs

By admin

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        9.8G   37M  9.2G   1% /data
# 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 fileystem 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.
How to Resize / Expand a Btrfs Volume / Filesystem

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to configure xhost to be persistent across reboots in Linux
  2. Can’t start X11 applications after “su” or “su -” to another user
  3. Basic “ls” Command examples in Linux
  4. Linux OS Service ‘rpcgssd’
  5. “yum clean all” not clearing yum repository cache in CentOS/RHEL/OEL
  6. How To Create a Partition Using “parted” Command
  7. CentOS / RHEL : Installing and Configuring ASMLib
  8. How to add additional language support in CentOS/RHEL
  9. Basic vi commands (cheat sheet)
  10. MySQL Server Error – “Can’t Create A New Thread (errno 11)”

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary