How add more space in a Btrfs Filesystem, How add a new partition, How add a new disk, Linux

SSD and HDD
The pc has dual boot : windows10 and Fedora34.
Fedora34 is in /dev/sdc :

  • sdb1: /boot/efi
  • sdc1: swap
  • sdc2: root

I want to use the 100GiB sdb5 partition, it is a simple volume created in windows and is not formatted.

[root@f34 chris]# lsblk -f
NAME   FSTYPE FSVER LABEL        UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sda                                                                                  
└─sda1 ntfs         New Volume   A254DEF854DECDE3                                    
sdb                                                                                  
├─sdb1 vfat   FAT32              30E8-0B14                              47.6M    50% /boot/efi
├─sdb2                                                                               
├─sdb3 ntfs                      BA3CFF7F3CFF354B                                    
├─sdb4 ntfs                      D46AE8676AE84836                                    
├─sdb5                                                                               
└─sdb6 ntfs         woody        06300BE4300BD997                                    
sdc                                                                                  
├─sdc1 swap   1     swap-label   6468fdcc-d524-4800-97d2-2eeace653326                [SWAP]
├─sdc2 btrfs        f34_lv_btrfs ff8bfa82-86d7-4170-9e0a-858bf735ed77   36.1G    73% /
└─sdc3 ext4   1.0   Leslie       b4198cab-1173-454d-8e9e-2b010a504171                
sr0                                                                                  
zram0                                                                                [SWAP]
[root@f34 chris]# 

BTRFS fedora 34

[root@f34 chris]#  btrfs filesystem show
Label: 'f34_lv_btrfs'  uuid: ff8bfa82-86d7-4170-9e0a-858bf735ed77
	Total devices 1 FS bytes used 98.51GiB
	devid    1 size 135.03GiB used 100.02GiB path /dev/sdc2

[root@f34 chris]# 
[root@f34 chris]# btrfs subvolume list /
ID 256 gen 262831 top level 5 path root
ID 261 gen 261283 top level 256 path var/lib/machines
[root@f34 chris]# 

On internet say that Btrfs has btrfs volumes and btrfs subvolumes, and works approximately as LVM.
I want to have more space in the root partition sdc2, there is the 100GiB sdb5 partition which is not formatted yet.
I was working in the past with LVM and found it very useful, physical volume, volume group, logical volume.
To add more space there was only neccesary running some commands.
Now with Btrfs the default file system in fedora 34, people say that it have interesting advantages, ok, but.
How can we add more space in the existed btrfs root partition there in fedora 34?
Thanks in advance.

1 Like

The words that guides you towards the solution are.

Steps:

  • Check the current space in your disk.
  • Space in /dev/sdc2 partition , size: 136G, avail: 37G
[root@f34 chris]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  7.7G     0  7.7G   0% /dev
tmpfs          tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs          tmpfs     3.1G  1.8M  3.1G   1% /run
/dev/sdc2      btrfs     136G   99G   37G  74% /
tmpfs          tmpfs     7.8G   44K  7.8G   1% /tmp
/dev/sdb1      vfat       96M   49M   48M  51% /boot/efi
tmpfs          tmpfs     1.6G  996K  1.6G   1% /run/user/1000

You can insert a new disk, create one or more partitions there. You can use an available space in your currents disks (SSD or HDD).

 btrfs device add /dev/sdb5 /
  • check
    btrfs device usage /
[root@f34 chris]# btrfs device usage /
/dev/sdc2, ID: 1
   Device size:           135.03GiB
   Device slack:              0.00B
   Data,single:            99.01GiB
   Metadata,single:         1.01GiB
   System,single:           4.00MiB
   Unallocated:            35.01GiB

/dev/sdb5, ID: 2
   Device size:           100.00GiB
   Device slack:              0.00B
   Unallocated:           100.00GiB
  • check the new space is reflected in the disk.
    df -h /
[chris@f34 ~]$ df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc2       236G  105G  131G  45% /
[chris@f34 ~]$ 

Now /dev/sdc2 has 236G in size, 136G(before) + 100G(/dev/sdb5).

Very good. That’s all.


Something Additional, it’s not necessary

You can balance the space in your disk

  • Distribute the metadata across the devices. This take me 15 minutes, you can use balance filters to narrow down the balanced data.
btrfs filesystem balance /
[root@f34 chris]# btrfs filesystem balance /

Done, had to relocate 103 out of 103 chunks
[root@f34 chris]# 

After that, there is more space in /dev/sdc2, avail: 137G

[root@f34 chris]# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc2       236G   99G  137G  43% /
[root@f34 chris]#
5 Likes

In this way, your btrfs FS_TREE is in raid0 mode - that means if any one of the two disks failed, you will lost all your data.

Please be aware of this risk and adjust your usage pattern and backup arrangement accordingly.

Which one is your SSD and which is your HDD?
lsblk -f -o +SIZE will show partition size as well.

1 Like

Strictly speaking no balance is required. If the reason for growing the fire system is temporary, for example. Then it’s easier to remove the device when no longer needed.

Further, if the default single profile (one copy, similar to linear) for data is acceptable no data balance is needed. But you might want to change the metadata profile, for example to raid1, to provide redundancy for the file system itself (excludes data). This looks like

btrfs balance start -mconvert=raid1 /

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.