Btrfs is a modern copy on write (COW) file system for Linux aimed at implementing advanced features while also focusing on fault tolerance, repair and easy administration.
Timeshift for Linux is an application that provides functionality similar to the System Restore feature in Windows and the Time Machine tool in macOS. This details how to setup and use Timeshift with Btrfs.
- Endeavour OS: Snapshotting with Timeshift
- No space left, despite having 200GB free space (BTRFS install)
-
Install the
timeshift
package usingyay
. -
Install the
timeshift-autosnap
package usingyay
to automatically create a snapshot every pre-upgrade. -
Install the
grub-btrfs
package usingyay
to allow booting into snapshots through Grub. -
Complete the setup through the Timeshift wizard:
-
Authenticate (as it requires
sudo
). -
Select BTRFS as Snapshot Type.
-
Select the main btrfs partition as the Snapshot Location.
-
Select the desired Snapshot Levels. Default options are fine.
-
Leave the Include @home subvolume in backups option unchecked.
-
Click Finish.
-
-
Create the first snapshot by clicking the Create button.
-
Start and Enable the system's
cron
service (i.e.cronie.service
) so that scheduled backups work. -
Regenerate a new GRUB config so that
grub-btrfs
works as intended.
-
timeshift-autosnap
should only keep 3 older snapshots by default according to its config,/etc/timeshift-autosnap.conf
. -
If it is not working reliably, it is recommended for you to use the Timeshift desktop application to delete older snapshots manually from time to time.
If you are using a Btrfs filesystem, it is recommended for you to "balance" your Btrfs volumes on a monthly basis in order to ensure that the free space available on your device is properly unallocated.
Warning
Leaving your Btrfs volume unbalanced for too long might cause you No space left
errors in the long run.
-
Install the
btrfs-assistant
application usingyay
. -
Launch the
btrfs-assistant
application. You will be asked to authenticate (as it requiresroot
permissions). -
Click the Start button in the Balance section to balance your Btrfs volumes.
This details how to disable and remove a swap device on a system running BTRFS.
-
First, verify that swap is indeed currently enabled on the system:
-
First method:
inxi -j
Sample output:
Swap: ID-1: swap-1 type: file size: 512 MiB used: 511.8 MiB (100.0%) file: /swap/swapfile
-
Second method:
swapon --show
Sample output:
NAME TYPE SIZE USED PRIO /swap/swapfile file 512M 511.8M -2
[!NOTE]
Take note of the swap device name such as in this sample being/swap/swapfile
. -
-
Disable the swap device (i.e.
/swap/swapfile
):swapoff /swap/swapfile
-
Unmount the swap volume (i.e.
/swap
) so it can be deleted:sudo umount /swap
-
Delete the
@swap
BTRFS subvolume using the Btrfs Assistant application:-
Launch the Btrfs Assistant application. Install the
btrfs-assistant
package usingyay
if you do not have it already. -
Navigate to the Subvolumes tab.
-
From the list of subvolumes, locate and highlight the
@swap
subdirectory by selecting it. -
Click the Delete button.
-
When prompted to confirm, click the Yes button.
-
-
Remove or comment entries in the system's
fstab
file relating to the swap device or subvolume:-
Edit the
fstab
file:sudo nano /etc/fstab
-
Remove or comment any entries relating to the swap device or subvolume like so:
#UUID=bzxd1bo8-9nnb-ddet-qykk-qjdgr9yytybg /swap btrfs subvol=/@swap,noatime 0 0 #/swap/swapfile swap swap defaults 0 0
-
-
Restart the system and reuse the same step to verify that swap has been disabled.