ZFS – mounting corrupt zpools and datasets
###################################
2 METHODS exist:
METHOD1 – mount the zpool readonly
METHOD2 – mount the zpool normal but without mounting any of the datasets/filesystems. then one by one mount each of the filesystems until you see the bad filesystem, then mount the bad filesystem with readonly flag set.
FIRST STEPS
============
Get list of pools:
# zpool import
I see I have Vol1 and Vol2, each with datasets (cant see datasets yet, but we know they exist).
If this fails:
# zpool import Vol1
# zpool import Vol2
Each import also mounts the datasets (zfs filesystems) that are associated with each zpool.
Method1
========
Try a readonly zpool import:
# zpool import -o readonly=on Vol1
# zpool import -o readonly=on Vol2
Now you can get your all of your data out.
Method2
========
If that doesnt work you can zpool import just the zpool (without mounting the zfs filesystems/datasets), and then manually import/mount the zfs datasets – then when you find the bad dataset, just mount it readonly. Then you can backup the bad dataset and not have to backup EVERYTHING as in last step.
# zpool import -N Vol1
Then mount the datasets one by one
# zfs mount Vol1/Datasetname1
# zfs mount Vol1/Datasetname2
continue thru every data set
Then you will find out the bad dataset for example Datasetname2. So set the readonly flag on it
# zfs set readonly=on Vol1/Datasetname2
Now you can reboot the system should come up with those datasets as readonly. Do not copy out with “zfs send/zfs receive” as the corruption could creep over to the destination. Instead use cp -a, tar and tools like that to copy over.