How can I scrub the ZFS subvol of a LXC?

jsabater

Member
Oct 25, 2021
102
8
23
48
Palma, Mallorca, Spain
As the title says, I can use the zfs command to get information about the subvolume of a LXC that resides in my zfspool pool, e.g.

zfs get all zfspool/subvol-109-disk-0

How can I scrub that subvolume to make sure everything is fine after running into issues with the filesystem and having to reboot? zpool show the status is fine, but I would like to make sure the subvolumes are fine, too (and I don't know if they are included in this check):

Code:
# zfs list
NAME                        USED  AVAIL     REFER  MOUNTPOINT
zfspool                    6.30G  3.51T      104K  /zfspool
zfspool/subvol-108-disk-0  5.89G  4.11G     5.89G  /zfspool/subvol-108-disk-0
zfspool/subvol-109-disk-0   292M   732M      292M  /zfspool/subvol-109-disk-0

# zpool status -v zfspool
  pool: zfspool
 state: ONLINE
  scan: scrub repaired 0B in 00:03:41 with 0 errors on Mon Apr  3 06:57:14 2023
config:

        NAME                                  STATE     READ WRITE CKSUM
        zfspool                               ONLINE       0     0     0
          mirror-0                            ONLINE       0     0     0
            ata-ST4000NM0245-1Z2107_ZC13613C  ONLINE       0     0     0
            ata-ST4000NM0245-1Z2107_ZC139JR7  ONLINE       0     0     0

errors: No known data errors

Thanks in advance.
 
zpool scrub YourPoolName scrubs the whole pool including all datasets (your subvol) and zvols. If it doesn't show checksum errors, that dataset should be fine.
 
If you read all data (e.g. via a backup) you will implicitly do "a kind of a scrub" of that data due to auto healing in case of a checksum error.
 
zpool scrub YourPoolName scrubs the whole pool including all datasets (your subvol) and zvols. If it doesn't show checksum errors, that dataset should be fine.

Yes, that is done every month:

Code:
# cat /etc/cron.d/zfsutils-linux
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# TRIM the first Sunday of every month.
24 0 1-7 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/trim ]; then /usr/lib/zfs-linux/trim; fi

# Scrub the second Sunday of every month.
24 0 8-14 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi

It's the default settings of the package.

I just run a manual scrub via /usr/lib/zfs-linux/scrub and it finished in a few minutes showing no errors:

Code:
# zpool status -v zfspool
  pool: zfspool
 state: ONLINE
  scan: scrub repaired 0B in 00:02:17 with 0 errors on Thu Apr  6 16:17:47 2023
config:

        NAME                                  STATE     READ WRITE CKSUM
        zfspool                               ONLINE       0     0     0
          mirror-0                            ONLINE       0     0     0
            ata-ST4000NM0245-1Z2107_ZC13613C  ONLINE       0     0     0
            ata-ST4000NM0245-1Z2107_ZC139JR7  ONLINE       0     0     0

errors: No known data errors

Thanks for your feedback. I just wanted to be ultra-sure that the data in the pool was fine.
 
I run backups every 12 hours via Proxmox Backup Server using the snapshot mode. Out of curiosity, would that count?
At least not for VMs, because there dirty-bitmapping is used so reading parts of the virtual disks can be skipped.
 
At least not for VMs, because there dirty-bitmapping is used so reading parts of the virtual disks can be skipped.
Yes, almost all data will be read.... better than nothing however. There is also some data still in ARC, so that will also not be read. Most of the time, the metadata is also cached and will not be read from disk again. Instead of backup, you can also send the dataset to /dev/null so that you will have read all non-cached data yet in the end.

However, this is not as good as doing a real scrub on the pool, yet better than nothing.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!