Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Apr 2016 23:14:19 +0200
From:      Sebastian Wolfgarten <sebastian@wolfgarten.com>
To:        freebsd-questions@freebsd.org
Subject:   ZFS migration - New pool lost after reboot
Message-ID:  <0A383C91-FCBA-4B9E-A95A-157A13708125@wolfgarten.com>

next in thread | raw e-mail | index | archive | help
Dear all,

I have a bit of an issue and I hope you are able to point me into the =
right direction for solving this.

Following a hard disk failure I have accidentally created a striped ZFS =
mirror and now I am trying to turn it (back) into a mirrored pool via a =
temporary hard disk I put into the server. This was in response to a =
post I did some time ago =
(https://groups.google.com/forum/#!topic/mailing.freebsd.questions/qT-2WTs=
cBqM =
<https://groups.google.com/forum/#!topic/mailing.freebsd.questions/qT-2WTs=
cBqM>).

Now ada0 is the replacement disk, I would like to use it to rebuild my =
mirrored pool in line with some instructions I have found online (see =
https://blog.grem.de/sysadmin/Shrinking-ZFS-Pool-2014-05-29-21-00.html =
<https://blog.grem.de/sysadmin/Shrinking-ZFS-Pool-2014-05-29-21-00.html>),=
 however I am experiencing some problems. Here is what I did:

0) Existing zroot pool to migrate

zroot/ROOT                    126G  5,02T    96K  none
zroot/ROOT/default            126G  5,02T   126G  /
zroot/tmp                    9,69M  5,02T  9,69M  /tmp
zroot/usr                    34,8G  5,02T    96K  /usr
zroot/usr/home               30,2G  5,02T  30,2G  /usr/home
zroot/usr/ports              4,58G  5,02T  4,58G  /usr/ports
zroot/usr/src                6,64M  5,02T  6,64M  /usr/src
zroot/var                    92,7G  5,02T    96K  /var
zroot/var/crash                96K  5,02T    96K  /var/crash
zroot/var/log                 412M  5,02T   412M  /var/log
zroot/var/mail               92,3G  5,02T  92,3G  /var/mail
zroot/var/tmp                 100K  5,02T   100K  /var/tmp

1) Create required partitions on temporary hard disk ada0
gpart create -s GPT ada0
gpart add -t freebsd-boot -s 128 ada0
gpart add -t freebsd-swap -s 4G -l newswap ada0
gpart add -t freebsd-zfs -l newdisk ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

2) Create new pool (newpool)

zpool create -o cachefile=3D/tmp/zpool.cache newpool gpt/newdisk

3) Create snapshot of existing zroot pool and copy it over to new pool=20=

zfs snapshot -r zroot@movedata
zfs send -vR zroot@movedata | zfs receive -vFd newpool
zfs destroy -r zroot@movedata

4) Make the new pool bootable
=09
zpool set bootfs=3Dnewpool/ROOT/default newpool

5) Mount new pool and prepare for reboot

cp /tmp/zpool.cache /tmp/newpool.cache
zpool export newpool
zpool import -c /tmp/newpool.cache -R /mnt newpool
cp /tmp/newpool.cache /mnt/boot/zfs/zpool.cache
zfs set mountpoint=3D/ newpool/ROOT
reboot

When I execute the steps above, the new pool is not imported =
automatically after reboot and as such, the system boots from the old =
zpool. Furthermore the new pool only features /tmp, /var and /usr if I =
manually import it afterwards - any ideas why the full structure of the =
zroot pool is not copied either? Furthermore any ideas on how to =
permanently import the new pool?

Lastly if somebody has got (better) instructions for how to migrate a =
zfs pool, please let me know.

Many thanks.

Best regards
Sebastian




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0A383C91-FCBA-4B9E-A95A-157A13708125>