logo

Ubuntu 14.04 Upgrade - zpool rescue

I run a 1.5TB Ubuntu NAS at home to store my Movies & Music - due to an unfortunate incident that nearly wiped out years of family photos, I chose raidz over mdam due to it's resiliance. Recently, that resiliance was put to the test when I decided to upgrade from Ubuntu 12.04 to 14.04...

ZFS on Linux

Upgrade Ubuntu 12.04

Upgrade Ubuntu 12.04 to 14.04...

$ sudo do-release-upgrade

... enable sources...

$ sudo nano /etc/apt/sources.list.d/zfs-native-stable-trusty.list
deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main  
deb-src http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main  

... and update zfs...

$ sudo apt-get update && sudo apt-get upgrade  

... export-import zpool - this is where the trouble begins:

$ sudo zpool export
$ sudo zpool import
data1                                 UNAVAIL    0    0    0    insufficient replicas  
  raidz1-0                            UNAVAIL    0    0    0    insufficient replicas
    ata-WDC-WD2500JS-abc-123          UNAVAIL    0    0    0    corrupted data
    ata-WDC_WD2500JS-abc-124-part1    ONLINE     0    0    0
    ata-WDC_WD2500JS-abc-125-part1    ONLINE     0    0    0
    ata-WDC_WD2500JS-abc-126          UNAVAIL    0    0    0    corrupted data

... not good!

To the Google manual

A couple of hours searching, and I didn't come up with much...

... until I came across this Github ticket:

Raw disk is identified as part of pool instead of the partitions that belong to it #2876

... and this discussion thread:

ZFS pool is identifying raw disk as part of pool instead of the partitions that belong to it

... so, it turns out zpool gets all confused with primary partitions - bless!

Lets give zpool a helping hand

For some reason (I can't remember why), I built my raidz with four primary partitions spanning four entire disks - lets give zpool a helping hand:

$ sudo mkdir /mnt/zfs-data1 && cd /mnt/zfs-data1

$ sudo ln -s /dev/disc/by-id/ata-WDC_WD2500JS-abc-123-part1 .
$ sudo ln -s /dev/disc/by-id/ata-WDC_WD2500JS-abc-124-part1 .
$ sudo ln -s /dev/disc/by-id/ata-WDC_WD2500JS-abc-125-part1 .
$ sudo ln -s /dev/disc/by-id/ata-WDC_WD2500JS-abc-126-part1 .

... now run:

$ sudo zpool import -fd /mnt/zfs-data1/ data1

... bingo:

$ sudo zpool status
data1                                 ONLINE    0    0    0  
  raidz1-0                            ONLINE    0    0    0
    ata-WDC-WD2500JS-abc-123-part1    ONLINE    0    0    0
    ata-WDC_WD2500JS-abc-124-part1    ONLINE    0    0    0
    ata-WDC_WD2500JS-abc-125-part1    ONLINE    0    0    0
    ata-WDC_WD2500JS-abc-126-part1    ONLINE    0    0    0

Now to make it permanent

$ sudo nano /etc/init.d/zfs-mount
do_start()  
{
    ...       
    # Workaround: Raw disk identified as part of pool instead of partitions #2876
    zpool import -fd /mnt/zfs-data1/ data1 
    zfs mount -a
    ...
}

So, in the end I managed recover my zpool, and save my Music & Movies collection. I hope this turns up in a Google search for somebody in their hour of need...