Switching from ext4 to btrfs

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:

cd /
time 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.

cryptsetup -y -v -s 512 luksFormat /dev/sdc2

Then open it and give it an arbitrary name:

cryptsetup luksOpen /dev/sdc2 cryptssd

4. Create filesystem using btrfs. This is the reason for all this effort. Although this is the easiest.

mkfs.btrfs /dev/mapper/cryptssd

5. Adapt /etc/fstab, e.g., with genfstab -U /mnt >> /mnt/etc/fstab

UUID=3b8bb70c-390a-4a9e-9245-ea19af509282       /       btrfs   rw,relatime     0 0
UUID=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.

mkdir boot proc run sys tmp

Then edit the configuraton file for GRUB:

vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=5a74247e-75e8-4c05-89a7-66454f96f974:cryptssd:allow-discards root=/dev/mapper/cryptssd"

grub-install --target=i386-pc /dev/sdb
grub-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.

pacman -S btrfs-progs

vi /etc/mkinitcpio.conf
. . .
BINARIES="/usr/bin/btrfs"
. . .
mkinitcpio -p linux

8. Extracting back from the tar-file.

time tar xf /mnt/c/home/klm/ssd1.tar

9. Adding TRIM for SSD:

systemctl status fstrim
systemctl enable fstrim.timer
systemctl start fstrim.timer

Show timers (like crontab -l):

systemctl --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.

SSD Speed on Dell XPS 13 9350

In Hard-Disk and SSD Speed Comparisons I compared a Mushkin SSD with 60 GB against a ADATA with 128 GB against a Seagate 1 TB hard disk drive. The SSD’s had roughly three times the speed of the hard disk drive. I.e., 380 MB/s vs. 134 MB/s for reading Mushkin vs. Seagate, and 297 MB/s vs. 131 MB/s for writing ADATA vs. Seagate.

I also compared USB-thumb-drives against above Seagate 1 TB hard drive in Hard-Disk and USB Drive Speed Comparisons. Read times were comparable (100-200 MB/s), while for writing the Seagate drive was roughly 4 to 5-times faster (100 MB/s vs 20 MB/s).

Hard drives speeds and prices in 2013 are given in Harddisk Drive Speed in MB/s. Read speeds are roughly 200 MB/s for enterprise drives.

Now the read- and write-speeds of the SSD in the Dell XPS 13 9350 are quite astonishing: up to 1.5 GB/s for reading, 532 MB/s for writing. Even if you use LUKS/dm-crypt the values are 840 MB/s for reading, and 428 MB/s for writing. Below are the measurements using gnome-disk-utility.

Without encryption:
Screenshot from 2016-07-17 14-47-25

Continue reading

dotScale 2013 MySQL Talk

Very interesting talk on the scaling challenge at WordPress.com given by Barry Abrahamson, CTO of WordPress.

Some key points:

  1. 500 million database tables
  2. 3 data centers in USA
  3. 400.000 shards moved per day
  4. storage on SSD
  5. ~10% of total infrastructure costs are related to backups
  6. ~500 GB / shard
  7. 50 million sites
  8. 2.200 servers, and 500 database servers

Compare this with infrastructure costs for WordPress.

Barry on WordPress

In June, I gave a talk at the dotScale conference in Paris about WordPress.com’s MySQL database architecture and infrastructure. The video is now online:

View original post