this post was submitted on 13 Aug 2023
8 points (100.0% liked)

FOSS (സ്വതന്ത്ര സോഫ്റ്റ്‌വെയർ)

1 readers
1 users here now

Community to discuss about opensource software, GNU/Linux , and news

Other communities in this instance

[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

For discussion about this instance

[email protected]

founded 1 year ago
MODERATORS
 

BTRFS is a copy on write filesystem (COW)

Unlike journaling file systems like ext4, BTRFS does not overwrite the data when it is modified, instead it writes the data to a new block and changes metadata to point to the latest version of the file. This provides better protection against power failures.

Snapshots

BTRFS offers fast incremental snapshot creation and tools to backup and restore.

Creating the file system and btrfs partition

parted /dev/nvmexxx
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) mkpart primary btrfs 4MiB 100%
(parted) print
(parted) quit

after the partition is created, create the btrfs file system on it by running

sudo mkfs.btrfs /dev/sdxy

Mounting the partition

Temporary mount with

sudo mount /dev/sdxy /mountpoint

Show info about the btrfs

To see the UUID, size, usage of all btrfs disks.

sudo btrfs filesystem show

See detailed disk usage

sudo btrfs filesystem usage /Subvol

Creating the subvolumes

To create a subvolume called data

sudo btrfs subvolume create /mountpoint/data

List all the subvolumes

To create a subvolume called data

sudo btrfs subvolume list /mountpoint/data

Mounting the subvolumes

to make the mount permanent, edit the '/etc/fstab' file

UUID=DISKUUUD /MOUNTPOINT   btrfs   defaults,noatime,commit=120,compress=zstd:1 0 0

{: .nolineno file="/etc/fstab" } These are mount options for the root subvol

  • noatime : Do not modify metadata on file read. Reduces disk writes.
  • commit=120: Time interval for writing changes to disk. Default is 30. Reduces disk writes.
  • compress=zstd:1 : Filesystem level compression. Reduces disk writes.

Create a readonly snapshot of a subvolume

sudo btrfs subvolume snapshot -r /data /data/.snapshots/name

Copying snapshots to other drives using send, receive

Send and receive is faster than rsync. The destination must be also btrfs.

sudo btrfs send /data/.snapshots/name | sudo btrfs receive  /mnt/backupDISK/backup

Restoring from a snapshot and make the snapshot writable

Copy the snapshot to the target folder.

sudo btrfs property set -tsf /data/snapshot ro false

Creating backups of your snapshot on a remote machine

btrfs send -p /data/ /data/.snapshots/new_snaphot | ssh root@ip "btrfs receive /mnt/backups"
top 10 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 1 year ago* (last edited 1 year ago) (1 children)

Cool. Thank you, A10aa.

OpenSuse had recommended btrfs, but I chose ext4 as its more familiar/popular. Also, I was installing Leap in an HDD.
Will try it when I install linux again(athinini ethra kollam aavumoo aavo?)

Unrelated, but does anyone know to improve booting time in linux. I've looked up the archwiki n followed some of the points there.

[–] [email protected] 2 points 1 year ago (1 children)

Try it. It is really easy to setup backup automation for btrfs with btrbk and Cron https://github.com/digint/btrbk

Boot time optimization

Generally speaking don't boot from HDD, use faster media if you can. Usually I don't shutdown my machine 😕 always suspend or hibernate.

[–] [email protected] 2 points 1 year ago
[–] [email protected] 2 points 1 year ago (1 children)

If you haven't migrated to btrfs already (like me), it may be worth waiting a few more kernel release cycles. There is a good chance that bcachefs will get added to the kernel in the meantime. Bcachefs is everything that btrfs promised to be. It even supports native encryption unlike btrfs (btrfs can only be installed inside a partition encrypted with something like dmcrypt).

[–] [email protected] 1 points 1 year ago

Good to know, I mainly use BTRFS for the snapshot feature and super easy RAID0 setups. Bcachefs looks promising, I will give it a try once it is in the kernel and widely tested.

[–] [email protected] 2 points 1 year ago (1 children)
[–] [email protected] 1 points 1 year ago

How? More robust since it came out much earlier? Anything else?

[–] [email protected] 1 points 1 year ago (1 children)

So, I have a 14TB ext hdd formatted as ext4 for a while now. I only have about 700gb left while I type this message. I do notice ext4 being slow sometimes. When the disk was emptier it would reach speeds of 140mb/s while now it often only goes to 50mb/s.

Do you think btrfs would give me better performance?

The disk is mainly used as AI storage or big games.

[–] [email protected] 1 points 1 year ago (1 children)

I think ext4 will give you better perf see this post https://www.phoronix.com/news/Linux-5.14-File-Systems but for big files performance diff is negligible I guess.

[–] [email protected] 2 points 1 year ago

I see, thanks!