Skip to main content

ZFS on Thinkpad: Automated Snapshots

Snapshotting the whole world #

I had a lot of fun setting up automated snapshots on the fileserver. It made me realize that it would probably be pretty easy to do the same thing for my laptop.

I wanted to avoid having to install Arch from scratch using one of the ZFS bootloader solutions, so I tried to find a distro with a ZFS on root installer. I remembered that Ubuntu had ZFS support, but it looks like they have since removed it from the v23+ installers.

It's pretty surprising to me that almost nobody offers ZFS on root except Proxmox. Guess that's why Proxmox is so awesome.

I was able to find an Arch-based distro with ZFS on root called CachyOS, which actually looks pretty dang slick. It also has a package repository with tons of packages rebuilt with LTO/x86-64-v3 for better performance. The default options are not bad either -- so similar to EndeavourOS that I literally just copied my home folder over after installation and everything works.

The default ZFS options aren't bad in CachyOS either. The max ARC size is set to like 90% of system ram (currently 14gb on my 16gb thinkpad), and the default datasets look like this:

❯ zfs list
NAME                          USED  AVAIL  REFER  MOUNTPOINT
zpcachyos                    12.0G   445G    96K  none
zpcachyos/ROOT               11.9G   445G    96K  none
zpcachyos/ROOT/cos           11.9G   445G    96K  none
zpcachyos/ROOT/cos/home      5.59G   445G  5.46G  /home
zpcachyos/ROOT/cos/root      4.14G   445G  4.13G  /
zpcachyos/ROOT/cos/varcache  2.16G   445G  2.16G  /var/cache
zpcachyos/ROOT/cos/varlog     540K   445G   300K  /var/log

Setting up snapshots #

I installed sanoid from the arch repo and then just copied my own instructions from the fileserver snapshot post linked above. Only had to change the dataset names and modify the syncoid command.

just had to add recursive option to the sanoid.conf for this machine:

        use_template = production
        recursive = yes

## templates

        frequently = 4
        hourly = 24
        daily = 3
        monthly = 0
        yearly = 0
        autosnap = yes
        autoprune = yes

        autoprune = yes
        frequently = 0
        hourly = 72
        daily = 30
        monthly = 6
        yearly = 0
        autosnap = no

In the fileserver examples, both of those proxmox hosts were logged in as root, which meant I needed to use --no-privilege-elevation in the syncoid command.

The thinkpad is obviously not logged in as root, so it needs to run the syncoid command as sudo, but still needs --no-privilege-elevation or else it will be trying to use "sudo" on the backup server as well.

Working command (-F the first time):

sudo syncoid -r --no-privilege-elevation zpcachyos/ROOT thinkstation2:bigpool/snapshots/thinkpad

How it looks on the backup server:

root@thinkstation2:/bigpool/snapshots/thinkpad# tree -La 2
└── cos
    ├── home
    ├── root
    ├── varcache
    └── varlog

I copied and pasted the exact same systemd timer (syncoid.timer) from the backup server for use on this machine.

to do: