Btrfs Filesystem /etc/fstab Entry To Mount It Automatically At Linux System Startup

Cpanel/Whm License $3/mo Plesk License $10/mo Cloudlinux License $5/mo

I‘ve RAID-1 based btrfs store backups on my person system and how do I mount a multi-volume btrfs filesystem using /etc/fstab file when my Linux server comes online?

[donotprint][/donotprint]The file /etc/fstab contains descriptive information about the various file system on a Linux or Unix-like system. It is the duty of the system administrator to properly create and maintain this file. This is also useful if you don’t have an initrd or your initrd does not
scan for a btrfs device on boot. In this tutorial you will learn how to mount a btrfs device using /etc/fstab.

How to format hard disk as a btrfs device?

Warning: mkfs.btrfs command destroy the data and replace the file system with a new one on existing disk. Be careful with the device names. It cannot be stressed enough how important it is to make a backup of your system before you do this.

The syntax is:
# mkfs.btrfs /dev/sdb
To create RAID-1 of /dev/sda and /dev/sdb, enter (no need to create partitions):
# mkfs.btrfs -d raid1 -m raid1 /dev/sda /dev/sdb

Finding information about your btrfs device

You can see the btrfs filesystem with info with the following command:
# btrfs filesystem show /mount/point/
# btrfs filesystem show /dev/DEVICE
# btrfs filesystem show /dev/sda
# btrfs filesystem show

Fig.01 Linux btrfs filesystem show device information command

So, I’ve two devices /dev/sda and /dev/sdb. You can use any one of the device to mount btrfs.
If your btrfs device mounted at /data/, enter:
# btrfs filesystem df /data/
Sample outputs:

Data, RAID1: total=48.00GiB, used=47.51GiB
System, RAID1: total=8.00MiB, used=16.00KiB
Metadata, RAID1: total=3.00GiB, used=1.62GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

mount command syntax

The syntax is:
# mkdir /data/
# mount /dev/sda /data
# btrfs filesystem df /data/

Syntax for /etc/fstab file

First find out UUID of your device, enter:
# blkid /dev/sda
# lsblk --fs /dev/sda
Sample outputs:

NAME FSTYPE LABEL UUID                                 MOUNTPOINT
sda  btrfs        e5b5c118-fb56-4fad-a45d-ff5fad9a649d /data

Edit /etc/fstab, enter:
# vi /etc/fstab
The syntax is as follows to mount btrfs device using UUID at /data/ mount point:

UUID=e5b5c118-fb56-4fad-a45d-ff5fad9a649d /data           btrfs   defaults      0  0

Save and close the file. There you have it, an entry is added to /etc/fstab so the new disk will be mounted automatically at system startup.

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Related posts

Zuckerberg to Study Crypto in Quest to Fix Facebook


Zooko Wilcox Envisions ‘Ambitious’ Changes for Zcash Cryptocurrency


ZombieChain Comes Alive: Can Ethereum Sidechains Save the Dapps?


ZoKrates Seeks to Bring Best of Zcash to Ethereum with Devcon Debut


Zk-Starks? New Take on Zcash Tech Could Power Truly Private Blockchains


Zk-Snarks Everywhere: Ethereum Privacy Tech Hits Tipping Point


ZipZap to Offer Cash-for-Bitcoin Service at 28,000 UK Locations


ZipZap Resumes Cash-to-Bitcoin Services for UK Shoppers


ZipZap Raises $1.1 Million to Grow Global Bitcoin Payments Network


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More