I am running DragonFlyBSD for quite some time now, but I never took the time to explore how Hammer2 really works concerning its snapshot abilities.
This post is my first try at it and I intend it to be a little memo.
First let’s gather some info about our mounted filesystems.
$ mount | grep hammer2 serno/QM00005.s1d on / (hammer2, local) /dev/serno/QM00005.s1e@DATA on /build (hammer2, local)
There are 2 different mountpoints interesting for us : / and /build. Each of them has a different Hammer2 filesystem mounted. Let’s try to retrieve a bit more info about them using the hammer2 command.
$ sudo hammer2 info /dev/serno/QM00005.s1d: ROOT LOCAL /dev/serno/QM00005.s1e: DATA LOCAL
Each filesystem contains two different PFS (pseudo-filesystem). As stated in the manual of hammer2 command :
All hammer2 filesystem have a PFS called "LOCAL" which is typically mounted locally on the host in order to be able to issue commands for other PFSs on the filesystem. The mount also enables PFS configuration scanning for that filesystem.
We can get a list of the PFS on a filesystem with the following command. We should take a look at the non-LOCAL PFS.
$ sudo hammer2 pfs-list # same as sudo hammer2 pfs-list / Type ClusterId (pfs_clid) Label MASTER 5941a1a3-5e71-11e8-9efd-010000000000 ROOT MASTER 5941a0df-5e71-11e8-9efd-010000000000 LOCAL $ sudo hammer2 pfs-list /build Type ClusterId (pfs_clid) Label MASTER 5946dd39-5e71-11e8-9efd-010000000000 DATA MASTER 5946dc79-5e71-11e8-9efd-010000000000 LOCAL
"Default value for label is based on partition of special: `a' defaults to "BOOT" , `d' defaults to "ROOT", and any other partition defaults to "DATA"."
According to the previous quote from mount_hammer2 manual page, it seems that mounting a partition ending with d will use the ROOT label by default and mounting any letter but a and d partition will choose the DATA label so the following lines are the same :
$ sudo mount_hammer2 /dev/serno/QM00005.s1d /mnt $ sudo mount_hammer2 /dev/serno/QM00005.s1d@ROOT /mnt
This seems to work as a regular filesystem more or less for now, except for the label part.
Now let’s try to take a snapshot as it’s one feature of the Hammer2 filesystem.
$ sudo hammer2 snapshot / "$(date +%F_%H%M%S)" $ sudo hammer2 pfs-list / Type ClusterId (pfs_clid) Label MASTER 5941a1a3-5e71-11e8-9efd-010000000000 ROOT MASTER 5941a0df-5e71-11e8-9efd-010000000000 LOCAL SNAPSHOT 20d7fca2-6417-11e8-9d94-010000000000 2018-05-30_163833
We can see the resulting PFS with our generated label with type SNAPSHOT. Let’s try to mount it with mount_hammer2, read-only so we won’t unintentionally change the data it contains.
$ sudo mount_hammer2 -o ro /dev/serno/QM00005.s1d@2018-05-30_163833 /mnt $ ls -l /mnt/ total 36 -r--r--r-- 1 root wheel 6686 Apr 9 02:20 COPYRIGHT drwxr-xr-x 1 root wheel 0 Apr 9 02:20 bin drwxr-xr-x 1 root wheel 0 May 23 12:09 boot drwxr-xr-x 1 root wheel 0 May 23 12:09 build drwxr-xr-x 1 root wheel 0 Apr 9 02:20 compat drwxr-xr-x 1 root wheel 0 May 23 12:10 dev -rw------- 1 root wheel 16384 May 30 16:23 entropy drwxr-xr-x 1 root wheel 0 May 30 16:24 etc drwxr-xr-x 1 root wheel 0 May 23 12:11 home drwxr-xr-x 1 root wheel 0 Apr 9 02:20 lib drwxr-xr-x 1 root wheel 0 Apr 9 02:20 libexec drwxr-xr-x 1 root wheel 0 May 23 12:10 mnt drwxr-xr-x 1 root wheel 0 May 23 12:10 proc drwxr-xr-x 1 root wheel 0 May 30 09:51 root drwxr-xr-x 1 root wheel 0 Apr 9 02:20 sbin lrwxr-xr-x 1 root wheel 11 May 23 12:10 sys -> usr/src/sys drwxrwxrwt 1 root wheel 0 May 23 12:09 tmp drwxr-xr-x 1 root wheel 0 May 23 12:10 usr drwxr-xr-x 1 root wheel 0 Apr 9 02:20 var
So it seems that our snapshot contains what was in /. Except for some mountpoints as /build for example.
In order to delete a snapshot one has to issue the following command.
$ sudo hammer2 pfs-delete 2018-05-30_163833 # if in / $ sudo hammer2 -s / pfs-delete 2018-05-30_163833 # if in /build for example (another hammer2 filesystem)