ZFS migration - New pool lost after reboot
Sebastian Wolfgarten
sebastian at wolfgarten.com
Thu Apr 28 21:23:19 UTC 2016
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-2WTscBqM <https://groups.google.com/forum/#!topic/mailing.freebsd.questions/qT-2WTscBqM>).
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=/tmp/zpool.cache newpool gpt/newdisk
3) Create snapshot of existing zroot pool and copy it over to new pool
zfs snapshot -r zroot at movedata
zfs send -vR zroot at movedata | zfs receive -vFd newpool
zfs destroy -r zroot at movedata
4) Make the new pool bootable
zpool set bootfs=newpool/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=/ 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
More information about the freebsd-questions
mailing list