ZFSonLinux modification for data rescue

Can't mount a version 6 file system on a version 5000 pool. Pool must be upgraded to mount this file system.

If you have this error message, you’ve got configured your ZFS to death… With normal tools, you are not able to mount the filesystem!

But there is a solution…

So, first of all, this is a warning! Modding the kernel driver for zfs could be dangerous for your data! Do that only if you know what you are doing!

ok, this is the starting point:

[  715.987916] Can't mount a version 6 file system on a version 5000 pool
[  715.987916] . Pool must be upgraded to mount this file system.

Next download ZFS on Linux source.

~/zfs-0.6.1/module/zfs# vi zfs_vfsops.c
error = zfs_get_zplprop(os, ZFS_PROP_VERSION, &zsb->z_version);

//insert the next line here!
zsb->z_version = 5;

if (error) {
  goto out;
} else if (zsb->z_version >
    zfs_zpl_version_map(spa_version(dmu_objset_spa(os)))) {
    (void) printk("Can't mount a version %lld file system "
    "on a version %lld pool\n. Pool must be upgraded to mount "
    "this file system.", (u_longlong_t)zsb->z_version,
    (u_longlong_t)spa_version(dmu_objset_spa(os)));
    error = ENOTSUP;
    goto out;
}

then:

./configure
make
make install

-> reboot and cross your fingers!

root@nas:~# zfs mount tank/data
filesystem 'tank/data' can not be mounted due to error 95
cannot mount 'tank/data': Invalid argument
root@nas:~# dmesg

[ 4.660482] Can't mount a version 6 file system on a version 5000 pool
[ 4.660482] . Pool must be upgraded to mount this file system.
[ 135.339418] Can't mount a version 6 file system on a version 5000 pool
[ 135.339418] . Pool must be upgraded to mount this file system.

hmm, strange… this could not be!

lets have a look at the kernel module:

root@nas:/lib/modules# find . * -name "zfs*"
./3.8.0-19-generic/updates/dkms/zfs.ko
./3.8.0-19-generic/extra/zfs
./3.8.0-19-generic/extra/zfs/zfs.ko
3.8.0-19-generic/updates/dkms/zfs.ko
3.8.0-19-generic/extra/zfs
3.8.0-19-generic/extra/zfs/zfs.ko
root@nas:/lib/modules# ls -alh 3.8.0-19-generic/updates/dkms/zfs.ko
-rw-r--r-- 1 root root 1.9M Jun 13 23:42 3.8.0-19-generic/updates/dkms/zfs.ko
root@nas:/lib/modules# ls -alh 3.8.0-19-generic/extra/zfs/zfs.ko
-rw-r--r-- 1 root root 1.9M Jun 17 23:18 3.8.0-19-generic/extra/zfs/zfs.ko

ok, here is the problem, there are two kernel modules. the latest is the right one.

root@nas:/lib/modules# zpool export tank

root@nas:/lib/modules# rmmod zfs

root@nas:/lib/modules# insmod 3.8.0-19-generic/extra/zfs/zfs.ko
root@nas:/lib/modules# dmesg

[ 228.768167] ZFS: Loaded module v0.6.1-1, ZFS pool version 5000, ZFS filesystem version 5
root@nas:/lib/modules# zpool import
pool: backup
  id: 17239626620456453971
  state: ONLINE
  status: The pool is formatted using a legacy on-disk version.
  action: The pool can be imported using its name or numeric identifier, though
          some features will not be available without an explicit 'zpool upgrade'.
  config:

    backup ONLINE
      ata-ST2000DL004_HD204UI_S2H7J90C604300 ONLINE

pool: tank
  id: 8305814720459405854
  state: ONLINE
  action: The pool can be imported using its name or numeric identifier.
  config:

    tank ONLINE
      raidz1-0 ONLINE
        ata-ST4000DM000-1F2168_W300ANP2 ONLINE
        ata-ST4000DM000-1F2168_W3008ZVS ONLINE
        ata-ST4000DM000-1F2168_W300ANNA ONLINE

root@nas:/lib/modules# zpool import tank
cannot mount '/tank': directory is not empty
root@nas:/lib/modules# cd /tank
root@nas:/tank# ls
data
root@nas:/tank# cd data
root@nas:/tank/data# ls
files....
root@nas:/tank/data#

yeah! 🙂
now you can start to copy your files to your backup drive!

good luck!