How to Create and Manage Btrfs File System in Linux - Part 2
Abstract: 16. To create subvolume we can use the below command. Here i have created two subvolumes. # btrfs subvolume create /mnt/tecmint_btrfs1/subvol1Remove L
12. Now we need to extend the mount point size /mnt/tecmint_btrfs1/ for this, we don’t have to extent the logical volume, instead we can add the device to mount point, it will extend the size of file-system.
# btrfs device add /dev/tecmint_vg/tecmint_lv2 /mnt/tecmint_btrfs1/
13. After adding device to btrfs filesytem, now verify the mount point size using ‘df -h‘ command.
# df -hAdd Device to Btrfs
14. Now, check the status of the added device.
# btrfs device stats /mnt/tecmint_btrfs1/Verify Device Status
If in-case, you want to remove the logical volume tecmint_lv2 from mount point, you can use the below commands.
# btrfs device delete /dev/tecmint_vg/tecmint_lv2 /mnt/tecmint_btrfs1/ # df -hRemove LVM Device Useful Available options in Btrfs
a. To check the disk usage of mount point.
# btrfs filesystem df /mnt/tecmint_btrfs1/Check Disk Usage
b. To list the btrfs file-system with more information’s. Mounted and unmounted using –all-devices.
# btrfs filesystem show --mounted
Instead of using –mounted we can list every devices using –all-devices.
List Btrfs Filesystemsc. To force a sync for the file-system identified by path {/mnt/tecmint_btrfs1/}.
# btrfs filesystem sync /mnt/tecmint_btrfs1/Sync Btrfs Filesystems
d. To defragment the files and directory metadata.
# btrfs filesystem defragment -v -r /mnt/tecmint_btrfs1/
- -r = recursively defragment through directories.
- -v = verbose.
- -c = to compress the file contents while defragmenting.
c. Checking file-system using btrfsck command to check the btrfs file-system.
# btrfsck /dev/tecmint_vg/tecmint_lv1Scan Btrfs Filesystems Step 3: Creating Btrfs Subvolumes
Btrfs subvolume are not a block devices, but it will behaves like block devices, not like LVM, ZFS volumes. Subvolumes are thought as a POSIX file namespace, These namespace can be accessed via the top level subvolume of the file-system by b-tree structure that contains directories.
Can create multiple subvolumes inside each subvolumes and we can mount the subvolume using it’s ID without mounting it’s parent subvolumes. We can create, delete the subvolume using simple commands.
Snapshots: This to Create a writeable/readonly snapshot of the subvolume, Snapshots to create the copy of writes but here it will not make copies of files instead it will shared the metadata and data’s of original subvolumes. We can create snapshot by read-only and writeable.
15. Before creating subvolume list if any subvolume existing.
# btrfs subvolume list /mnt/tecmint_btrfs1/
16. To create subvolume we can use the below command. Here i have created two subvolumes.
# btrfs subvolume create /mnt/tecmint_btrfs1/subvol1 # btrfs subvolume create /mnt/tecmint_btrfs1/subvol2
17. Now list and check for the newly created subvolumes.
# btrfs subvolume list /mnt/tecmint_btrfs1/Create Btrfs Subvolume
18. Then navigate to mount point /mnt/tecmint_btrfs1/ and list to see the newly created subvolumes what we have created in above steps.
# cd /mnt/tecmint_btrfs1/subvol1/
Copy some of the random files from /etc/ to subvol1.
# cp /etc/[abcde]* .Verify Btrfs Subvolumes Pages: 1 2 3