Original post is here: eklausmeier.goip.de
Hearing all these wonder stories about btrfs I decided to give btrfs a try. Additionally I encrypted my SSD using LUKS.
The relevant entries in the Arch WIKI are: Setting up LUKS and btrfs. Here is the list of commands I used.
1. I saved my data from SSD using tar
and saved tar-file on hard-disk:
1cd /
2time tar cf /mnt/c/home/klm/ssd1.tar bin boot etc home opt root srv usr var
Alternatively one can use cp -a
to copy directories with symbolic links. Option -a
is the same as -dR --preserve=all
.
2. I used gparted
to partition the SSD, creating /boot
and /
(root). For /boot
I directly enabled btrfs in gparted
.
3. Encrypt the partition.
1cryptsetup -y -v -s 512 luksFormat /dev/sdc2
Then open it and give it an arbitrary name:
1cryptsetup luksOpen /dev/sdc2 cryptssd
4. Create filesystem using btrfs. This is the reason for all this effort. Although this is the easiest.
1mkfs.btrfs /dev/mapper/cryptssd
5. Adapt /etc/fstab
, e.g., with genfstab -U /mnt >> /mnt/etc/fstab
1UUID=3b8bb70c-390a-4a9e-9245-ea19af509282 / btrfs rw,relatime 0 0
2UUID=a8d6c185-0769-4ec5-9088-2c7087815346 /boot ext4 rw,data=ordered,relatime 0 2
Check results with lsblk -if
.
6. Chroot into new system using arch-chroot
and put GRUB on it, as usual. Add required directories, first.
1mkdir boot proc run sys tmp
Then edit the configuraton file for GRUB:
1vi /etc/default/grub
2GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=5a74247e-75e8-4c05-89a7-66454f96f974:cryptssd:allow-discards root=/dev/mapper/cryptssd"
3
4grub-install --target=i386-pc /dev/sdb
5grub-mkconfig -o /boot/grub/grub.cfg
Keyword :allow-discards
after cryptssd is for SSD TRIM. For a mechanical hard drive this keyword should be omitted.
7. Install btrfs utilities and programs on new system if not already installed. Add the btrfs executable to the initial RAM disk, i.e., set the entry for BINARIES
.
1pacman -S btrfs-progs
2
3vi /etc/mkinitcpio.conf
4. . .
5BINARIES="/usr/bin/btrfs"
6. . .
7mkinitcpio -p linux
8. Extracting back from the tar-file.
1time tar xf /mnt/c/home/klm/ssd1.tar
9. Adding TRIM for SSD:
1systemctl status fstrim
2systemctl enable fstrim.timer
3systemctl start fstrim.timer
Show timers (like crontab -l):
1systemctl --type=timer
10. A simple benchmark, as indicated by above time
before tar
, does not show any performance benefits so far. But performance was not the main motivator, but rather the added functionality, especially taking snapshots.