Open In App

How to install and format a partition with the Btrfs on Ubuntu?

Last Updated : 02 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss btrfs, its features, and the installation of btrfs. We will generalize each step on how we can create a partition using the fdisk utility and how we can make use of mkfs command utility to format the partition in btrfs.

What is Btrfs?

The Btrfs, B-Tree File System is a file system and volume manager. it was developed in the year 2007 and it was merged in the year 2009 with Linux Kernel. it has two advanced features such as a copy-on-write and checksums. it is not the successor of the ext4 file system but it may be in the future. it has some other features as:

  • Online resizing of volumes
  • Data compression transparently
  • Maximum volume size is 16 exbibytes
  • Multi-device spanning and pooling
  • Checksums of data and metadata
  • Supports RAID levels 0,1,10

How to install and format a partition with the Btrfs on Ubuntu?

Step 1: Installation of btrfs

First, we need to install btrfs using an apt package manager. This will install all the packages and dependencies required for btrfs.

sudo apt install btrfs-progs -y

 

Step 2: Granting root privilege

Then we need to create a partition and It requires root privileges for creating a partition, so we will use the command as

sudo -s

 

Step 3: Checking Block Device

lsblk is a command utility used to display block devices, it displays the device connected to the system and the partition created on the respective block device. 

lsblk

 

It displays the “sda” block device in which partitions are created.

Step 4: Creating a partition using fdisk

So, we will use fdisk utility for creating and manipulating the partition table. Thus, we use fdisk with block device “sda”

fdisk /dev/sda 

 

Step 5: Options used for fdisk

  • n – for creating a new partition
  • d – for deleting the partition
  • w – for writing the partition table
  • l – for partition type
  • p – for printing the partition table

Step 6: Created a primary partition of volume size 1GB

 So, we will create a primary partition with a volume size of 1Gib.

 

Step 7: Formatting partition as btrfs

 After creating a partition, we need to format the partition with btrfs using mkfs command

sudo mkfs.btrfs -L gfg /dev/sd

 

Step 8: Mounting partition

 We need to mount the partition, so we will create a directory using mkdir

mkdir /gfg

 

 We will mount the partition in /gfg directory using the mount command

mount /dev/sda4 /gfg 

 

Step 9: Checking partition mount point

Again, we can check our partition point using lsblk or df command

lsblk is used to display the partition and its mount point

lsblk 

 

df command is used to display the total partition volume and the volume used out of the total space

df -h

 

Conclusion

In this article, we discussed btrfs and its key features. we have also seen how we can create a partition using fdisk utility and can make use of that. fdisk is a great tool for creating, maintaining and manipulating the partition table.  


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads