# create btrfs FS on sda partition 3
mkfs.btrfs /dev/sda3
Mounting btrfs and Creating a sub-volume
mkdir /mnt/myfs
mount /dev/sda3 /mnt/myfs
cd /mnt/myfs
# Since we're cd'd into /mnt/myfs - this creates a subvolume called `mydata` inside of `/mnt/myfs`
[root@sysresccd /mnt/myfs]# btrfs subvolume create mydata
Create subvolume './mydata'
[root@sysresccd /mnt/myfs]# ls -la /mnt/myfs
drwxr-xr-x 1 root root 14 Aug 15 11:15 .
drwxr-xr-x 14 root root 4096 Aug 15 11:15 ..
drwxr-xr-x 1 root root 0 Aug 15 11:15 mydata
[root@sysresccd /mnt/myfs]# btrfs subvolume list /mnt/myfs
ID 257 gen 8 top level 5 path mydata
Setting a label for a btrfs filesystem
btrfs filesystem label /mnt/myfs "mydata"
# Or, directly on the partition
btrfs filesystem label /dev/sda3 "mydata"
Enable compression for a subvolume / folder using `chattr` (+c - lowercase C = enable compression for NEW files in this folder - will not affect existing files)
[root@sysresccd /mnt/root/var/newlogs]# lsattr
------------------- ./logdata
[root@sysresccd /mnt/root/var/newlogs]# chattr +c logdata
[root@sysresccd /mnt/root/var/newlogs]# lsattr
--------c---------- ./logdata
Disable copy-on-write per-file / per-folder (+C - capital C = disable copy-on-write / COW)
[root@sysresccd /mnt/myfs]# chattr +C mydata
[root@sysresccd /mnt/myfs]# lsattr
---------------C--- ./mydata
Get Partition UUIDs using lsblk
lsblk -o NAME,PATH,FSTYPE,PARTUUID
NAME PATH FSTYPE PARTUUID
loop0 /dev/loop0 squashfs
sda /dev/sda
├─sda1 /dev/sda1 ext4 f2f886a3-69b6-4ea6-87e4-c09e5cd830e4
├─sda14 /dev/sda14 d1f9156b-8149-4c86-abb4-02319d7859e4
└─sda15 /dev/sda15 vfat ce0d08a4-ea60-4f3f-b06d-d61a1d1560ea
sdc /dev/sdc
└─sdc1 /dev/sdc1 xfs 913b0a09-a337-ac45-93fe-64ab23be14a0
Adding btrfs to /etc/fstab
# Remove the 'compress' option if you don't want automatic compression
LABEL=mydata /mnt/myfs btrfs defaults,noatime,compress 0 0
# Using `subvol=` we can choose to mount a specific subvolume here
LABEL=mydata /mnt/mydata btrfs subvol=/mydata,defaults,noatime,compress 0 0
# You can also use standard /dev/sdx0 notation, or partition UUIDs
/dev/sda3 /mnt/myfs btrfs defaults,noatime,compress 0 0
UUID=d1f9156b-8149-4c86-abb4-02319d7859e4 /mnt/myfs btrfs defaults,noatime,compress 0 0
Creating, removing, and managing snapshots of btrfs
[root@sysresccd /mnt/myfs]# mkdir snapshots
# Create a snapshot of the subvolume `mydata` into the folder `snapshots/`
[root@sysresccd /mnt/myfs]# btrfs subvolume snapshot /mnt/myfs/mydata /mnt/myfs/snapshots/mydata-2019-08-15
# We can see the snapshots appear as subvolumes of myfs
[root@sysresccd /mnt/myfs]# btrfs subvolume list /mnt/myfs
ID 257 gen 8 top level 5 path mydata
ID 2536 gen 3216 top level 327 path snapshots/mydata-2019-08-15
# To remove a snapshot, just remove it like a subvolume
[root@sysresccd /mnt/myfs]# btrfs subvolume delete /mnt/myfs/snapshots/mydata-2019-08-15
Defragmenting and forcing re-compression of folders/subvolumes
# -v = verbose (print filenames as they're defragged)
# -r = defrag recursively (warning: usually will not descend into subvolumes. you must specify each subvolume individually)
# -clzo = Force re-compress all affected files with LZO while they're defragmented
[root@sysresccd /mnt/myfs]# btrfs filesystem defragment -v -r -clzo /mnt/myfs/mydata
Foreigners / Customers Russians / Artists / Vendors
Mar 10, 2022${toc} apt update apt install -y tayga Configure sysctl / ensure IPv4 and IPv6 forwarding is enabled For Tayga to work properly, you must have both IPv4 and IPv6 forwarding enabled. Since the NAT64 server will also function effectively like a router, the sysctl config that's generated below will:
Feb 13, 2021# Error handling set -e     # Exit immediately if a command exits with a non-zero status. set -u     # Treat unset variables as an error when substituting. set -E     # If set, the ERR trap is inherited by shell functions. set -o pipefail   # the return value of a pipeline is the status of the last command to exit with                   # a non-zero status, or zero if no command exited with a non-zero status
Feb 2, 2021Setting up your real physical Cisco router to send un-altered routes to your Quagga server cisco core router config for sending routing data to quagga ip access-list standard DENY-ALL-IPV4   deny   any exit ipv6 access-list DENY-ALL-IPV6   deny ipv6 any any exit
Feb 2, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up