fixing a busted ZFS upgrade

David Newman dnewman at networktest.com
Sat Apr 2 14:34:57 UTC 2011


On 4/2/11 2:23 AM, krad wrote:
> 
> 
> On 31 March 2011 07:15, David Newman <dnewman at networktest.com
> <mailto:dnewman at networktest.com>> wrote:
> 
>     On 7/29/10 3:18 PM, Martin Matuska wrote:
> 
>     >
>     > For recovering a system that does not boot anymore, you can use mfsBSD
>     > ISO's:
>     > http://mfsbsd.vx.sk
>     >
>     > You can boot from the iso and repair the boot record.
> 
>     Nearly a year ago mfsBSD saved me from a munged 8.0->8.1 upgrade of a
>     ZFS box and allowed me to revive a ZFS root partition.
> 
>     I've done the same stupid thing again in moving from 8.1 to 8.2, only
>     now the server won't boot from the 8.2 mfsBSD ISO, or the 8.1 ISO. In
>     both cases it hangs at loader.conf.
> 
>     Thanks in advance for any clues on reviving this system.

<snip>

> I script my installs for upgrading zfsroot as its safer that way. Hes my
> script for installing after everything is built
> 
> #!/usr/local/bin/bash
> 
> if [ $UID != 0 ] ; then
>   echo your not root !! ; exit 1
> fi
> 
> date=`date '+%Y%m%d'`
> oroot=`grep "vfs.root.mountfrom=\"zfs:system-4k/" /boot/loader.conf |
> sed -e "s#^.*\"zfs:system-4k/be/##" -e "s#\"##"`
> nroot="root$date"
> snap="autoup-$RANDOM"
> zpool=system-4k
> 
> export DESTDIR=/$zpool/be/$nroot
> 
> 
> if [ "$oroot" =  "$nroot" ] ; then
>  echo "i cant update twice in one day"; exit 1
> fi
> 
> echo building in $zpool/be/$nroot
> 
> zfs snapshot $zpool/be/$oroot@$snap && 
> zfs send $zpool/be/$oroot@$snap | zfs receive -vv $zpool/be/$nroot    && 
> cd /usr/src && 
> make installkernel && 
> make installworld && 
> sed -i -e "s#$zpool/be/$oroot#$zpool/be/$nroot#"
> /$zpool/be/$nroot/boot/loader.conf && \
> echo "Installing boot records.." && 
> zpool status system-4k | grep -A 2 mirror | grep ad | sed -e
> "s/p[0-9]//"  | 
>         while read a b; do 
>                 gpart bootcode -b /zfsboot/pmbr -p /zfsboot/gptzfsboot
> -i 1 $a;  
>         done && 
> cp -v /zfsboot/zfsloader /$zpool/be/$nroot/boot/. && 
> echo -en "\n\nNow run these two commands to make the changes live, and
> reboot
>  zfs set mountpoint=legacy $zpool/be/$nroot
>  zpool set bootfs=$zpool/be/$nroot $zpool\n\n"
> 
> it assumes this kind of layout
> 
> 
> $ zfs list | grep be
> system-4k/be                              35.7G  1.03T   156K  /system-4k/be
> system-4k/be/current                      1.40G  1.03T   924M  legacy
> system-4k/be/root20110226                 2.80G  1.03T   882M  legacy
> system-4k/be/root20110302                 3.24G  1.03T   882M  legacy
> system-4k/be/root20110306                 1.32G  1.03T   882M  legacy
> system-4k/be/root20110312                 1.36G  1.03T   923M  legacy
> system-4k/be/tmp                           852K  1.03T   336K  /tmp
> system-4k/be/usr-local                    2.98G  1.03T  2.61G  /usr/local/
> system-4k/be/usr-obj                      5.10G  1.03T  2.10G  /usr/obj
> system-4k/be/usr-ports                    5.99G  1.03T  2.29G  /usr/ports
> system-4k/be/usr-ports/distfiles          1.18G  1.03T   156K
>  /usr/ports/distfiles
> system-4k/be/usr-src                      1.53G  1.03T   999M  /usr/src
> system-4k/be/var                          5.30G  1.03T   812M  /var
> system-4k/be/var/log                      4.21G  1.03T  2.67G  /var/log
> system-4k/be/var/mysql                    82.5M  1.03T  33.9M  /var/db/mysql

Thanks for this script. Problem is, I can't get to the point where I can
run it. I've tried booting from 8.1 and 8.2 mfsBSD ISOs but both hang at
loader.conf.

Thanks for any clues on getting beyond this point. . .

dn



More information about the freebsd-fs mailing list