-
Notifications
You must be signed in to change notification settings - Fork 0
ZFSBasicDiskManagement
In this page we will take a closer look at some ZFS commands that already appeared elsewhere, with a focus on basic maintenance operations.
One of the greatest features of ZFS is how easy are its standard tools. Let's see the most common of them.
This command enables to create and maintain zpools as a whole, assigning and substituting (whole) disks and managing change.
The zpool status comand shows the present state of a pool :
user@nas:~$ zpool status
pool: zfspool
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
zfspool ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
ata-VBOX_HARDDISK_VB33e4cb68-e66806e3 ONLINE 0 0 0
ata-VBOX_HARDDISK_VB736b0a1e-d314dba7 ONLINE 0 0 0
ata-VBOX_HARDDISK_VB3dfd818f-9b413e39 ONLINE 0 0 0
errors: No known data errors
This command performs lots of different functions at the filesystem level. One very common example is to get a list of all filesystems:
user@backup:~$ zfs list
NAME USED AVAIL REFER MOUNTPOINT
backuppool 475M 18.4G 96K /mnt/storage
backuppool/DocumentsBackup 474M 18.4G 474M /mnt/storage/DocumentsBackup
testpool 208K 18.9G 24K /mnt/test
buser@backup:~$
Another very common usage is to display the list of all snapshots of some filesystem:
buser@backup:~$ zfs list -t snapshot backuppool/DocumentsBackup
NAME USED AVAIL REFER MOUNTPOINT
backuppool/DocumentsBackup@2024.07.26-00.48.47 88K - 474M -
buser@backup:~$
Here we understand that the backuppool/DocumentsBackup filesystem has only one snapshot, dated 2024.07.26-00.48.47.
The scrub operation is used to fix potential problems that have been found on a ZFS pool.
Let's launch one .
user@nas:~$ sudo zpool scrub zfspool
user@nas:~$ zpool status
pool: zfspool
state: ONLINE
scan: scrub repaired 0B in 00:00:02 with 0 errors on Sun Jul 28 21:20:27 2024
config:
NAME STATE READ WRITE CKSUM
zfspool ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
ata-VBOX_HARDDISK_VB33e4cb68-e66806e3 ONLINE 0 0 0
ata-VBOX_HARDDISK_VB736b0a1e-d314dba7 ONLINE 0 0 0
ata-VBOX_HARDDISK_VB3dfd818f-9b413e39 ONLINE 0 0 0
errors: No known data errors
The following command will display all the history of the pool since it was created. All this information is stored on the pool itself .
user@nas:~/src/zfs-backup$ sudo zpool history
History for 'zfspool':
2024-07-20.23:27:11 zpool create -o ashift=12 -f zfspool raidz /dev/disk/by-id/ata-VBOX_HARDDISK_VB33e4cb68-e66806e3 /dev/disk/by-id/ata-VBOX_HARDDISK_VB736b0a1e-d314dba7 /dev/disk/by-id/ata-VBOX_HARDDISK_VB3dfd818f-9b413e39
2024-07-20.23:37:13 zfs set mountpoint=/mnt/raid zfspool
2024-07-20.23:37:50 zfs create zfspool/Documents
2024-07-20.23:42:37 zfs set compression=lz4 zfspool/Documents
2024-07-20.23:47:52 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-21.01:29:51 zfs snapshot zfspool/Documents@2024.07.21-01.29.51
2024-07-21.02:08:28 zfs destroy zfspool/Documents@2024.07.21-01.29.51
2024-07-21.02:10:11 zfs snapshot zfspool/Documents@2024.07.21-02.10.05
2024-07-21.02:10:16 zfs send -R zfspool/Documents@2024.07.21-02.10.05
2024-07-21.20:49:20 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-22.04:46:56 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-23.19:44:49 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-25.00:45:44 zfs snapshot zfspool/Documents@2024.07.25-00.45.44
2024-07-25.00:47:34 zfs destroy zfspool/Documents@2024.07.25-00.45.44
2024-07-25.00:47:44 zfs rollback zfspool/Documents@2024.07.21-02.10.05
2024-07-25.00:49:32 zfs snapshot zfspool/Documents@2024.07.25-00.49.32
2024-07-25.01:03:11 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-25.22:25:27 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-26.00:44:42 zfs send -I zfspool/Documents@2024.07.21-02.10.05 zfspool/Documents@2024.07.25-00.49.32
2024-07-26.00:48:07 zfs destroy zfspool/Documents@2024.07.25-00.49.32
2024-07-26.00:48:17 zfs destroy zfspool/Documents@2024.07.21-02.10.05
2024-07-26.00:48:47 zfs snapshot zfspool/Documents@2024.07.26-00.48.47
2024-07-26.00:48:56 zfs send -R zfspool/Documents@2024.07.26-00.48.47
2024-07-28.20:51:23 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-28.21:20:25 zpool scrub zfspool
2024-07-29.06:10:03 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-30.16:49:09 zfs snapshot zfspool/Documents@2024.07.30-16.49.08
2024-07-30.16:49:12 zfs send -I zfspool/Documents@2024.07.26-00.48.47 zfspool/Documents@2024.07.30-16.49.08
2024-07-30.16:49:12 zfs destroy zfspool/Documents@2024.07.30-16.49.08
2024-10-01.21:20:51 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-21.21:56:32 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-27.17:44:32 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-27.21:53:46 zfs snapshot zfspool/Documents@2024.10.27-21.53.46
2024-10-27.21:53:51 zfs send -I zfspool/Documents@2024.07.26-00.48.47 zfspool/Documents@2024.10.27-21.53.46
2024-10-27.21:53:51 zfs destroy zfspool/Documents@2024.10.27-21.53.46
2024-10-27.21:55:46 zfs set xattr=sa zfspool
2024-10-27.21:56:07 zfs snapshot zfspool/Documents@2024.10.27-21.56.07
2024-10-27.21:56:10 zfs send -I zfspool/Documents@2024.07.26-00.48.47 zfspool/Documents@2024.10.27-21.56.07
2024-10-27.21:56:11 zfs destroy zfspool/Documents@2024.10.27-21.56.07
2024-10-27.21:57:39 zfs snapshot zfspool/Documents@2024.10.27-21.57.39
2024-10-27.21:57:42 zfs send -I zfspool/Documents@2024.07.26-00.48.47 zfspool/Documents@2024.10.27-21.57.39
2024-10-27.21:57:42 zfs destroy zfspool/Documents@2024.10.27-21.57.39
2024-10-27.21:59:12 zfs snapshot zfspool/Documents@2024.10.27-21.59.11
2024-10-27.21:59:15 zfs send -I zfspool/Documents@2024.07.26-00.48.47 zfspool/Documents@2024.10.27-21.59.11
2024-10-27.22:13:33 zfs snapshot zfspool/Documents@2024.10.27-22.13.33
2024-10-27.22:15:19 zfs snapshot zfspool/Documents@2024.10.27-22.15.19
2024-10-27.22:18:59 zfs snapshot zfspool/Documents@2024.10.27-22.18.59
2024-10-27.22:49:51 zfs send -I zfspool/Documents@2024.10.27-21.59.11 zfspool/Documents@2024.10.27-22.18.59
2024-10-29.21:57:26 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-29.22:46:02 zfs send -I zfspool/Documents@2024.07.26-00.48.47 zfspool/Documents@2024.10.27-22.18.59
user@nas:~/src/zfs-backup$
This comes in very handy when, say, you need to recreate your server, because at the top of the list you would find all the commands you executed to create it in the first place :)
Let's perform the same command on the backup server:
buser@backup:~$ sudo zpool history
History for 'backuppool':
2024-07-21.00:30:55 zpool create -o ashift=12 -f backuppool mirror /dev/disk/by-id/ata-VBOX_HARDDISK_VBd6b07a1a-5fed615f /dev/disk/by-id/ata-VBOX_HARDDISK_VBad84d57b-ac3f5cd2
2024-07-21.00:34:24 zfs set mountpoint=/mnt/storage backuppool
2024-07-21.02:10:17 zfs recv -v backuppool/DocumentsBackup
2024-07-21.02:10:20 zfs set readonly=on backuppool/DocumentsBackup
2024-07-26.00:44:43 zfs recv -v backuppool/DocumentsBackup
2024-07-26.00:45:35 zfs destroy backuppool/DocumentsBackup@2024.07.21-02.10.05
2024-07-26.00:46:09 zfs destroy backuppool/DocumentsBackup@2024.07.25-00.49.32
2024-07-26.00:46:48 zfs destroy backuppool/DocumentsBackup
2024-07-26.00:48:57 zfs recv -v backuppool/DocumentsBackup
2024-07-26.00:49:01 zfs set readonly=on backuppool/DocumentsBackup
2024-10-27.21:59:04 zfs rollback backuppool/DocumentsBackup@2024.07.26-00.48.47
2024-10-27.21:59:15 zfs recv -v backuppool/DocumentsBackup
2024-10-27.22:49:53 zfs recv -v backuppool/DocumentsBackup
History for 'testpool':
2024-07-21.00:18:53 zpool create testpool /dev/disk/by-id/ata-VBOX_HARDDISK_VBb713d0e5-bc544b92
2024-07-21.00:23:22 zfs set mountpoint=/mnt/test testpool
2024-07-21.20:49:48 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-22.04:47:22 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-23.19:45:23 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-25.22:26:09 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-28.20:51:28 zpool import -c /etc/zfs/zpool.cache -aN
2024-07-29.06:09:57 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-01.19:42:10 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-21.21:56:43 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-27.17:44:34 zpool import -c /etc/zfs/zpool.cache -aN
2024-10-29.21:58:09 zpool import -c /etc/zfs/zpool.cache -aN
buser@backup:~$
Please note that here we have separate stories for the different pools.
Now that we saw ZFS basic disk management commands, it's time for the serious stuff: let's head on to ZFS Disk Change
ZFS Backup, (c) 2024 Luca Finzi Contini - Use it at your own risk but enjoy doing so :)