From owner-freebsd-questions@FreeBSD.ORG Mon Feb 25 15:14:39 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 40A9415B for ; Mon, 25 Feb 2013 15:14:39 +0000 (UTC) (envelope-from bw.mail.lists@gmail.com) Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D190B277 for ; Mon, 25 Feb 2013 15:14:38 +0000 (UTC) Received: by mail-ee0-f41.google.com with SMTP id c13so1474438eek.28 for ; Mon, 25 Feb 2013 07:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=xkSsWVT2OiPRyv+568XcYFkY2tLOHMfBgqSMNVe2gKs=; b=xpYA3GpSMs8PmmkHx7AbvkRuBDHVOPrlaC1XqkV4HXvzMznQwgIiVCEVgGgN38v5G8 +LH3rngYCvPnjO4mTtURtqZ7bBwhj/GbDFVCfCoeOVra6OYYlB79tY3azV4DwAZSnSp+ eehE/LkaxKyM7MftEs2yDjTMc8C2DDKudXe4VXG+N4XqF/3P6h0stH16bvSY4ZPhVYCl eGO4q+75qOqcPi3V/NeztZazoU+VA3XQBSpXECMCPdda/9tKPvK1gbaQg4+pPHq9Pdb/ f4l0Gc/R/3zBKm0h7DJrKJxn6TTzzcH8vC2/F3X8iMfhZAcBzFnVgBCf1+Ti7Lv72UGE qSFg== X-Received: by 10.14.184.68 with SMTP id r44mr39550855eem.40.1361805271954; Mon, 25 Feb 2013 07:14:31 -0800 (PST) Received: from [172.28.21.100] ([87.213.55.2]) by mx.google.com with ESMTPS id a1sm18860456eep.2.2013.02.25.07.14.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Feb 2013 07:14:31 -0800 (PST) Message-ID: <512B7FD0.6040405@gmail.com> Date: Mon, 25 Feb 2013 16:14:24 +0100 From: bw User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: ZFS root, error 2 when mounting root References: <5129E079.4040906@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Feb 2013 15:14:39 -0000 On 02/25/2013 03:13 PM, Paul Kraus wrote: > On Feb 24, 2013, at 4:42 AM, bw.mail.lists wrote: > >> Basically, I tried to follow https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE, but ended up with a system that didn't know how to mount /. >> >> There are two scripts attached. > > I did not see any attachments. > Mail list got rid of them, I didn't know it will do that. Appended inline at the end of this mail. Stuff will probably get wrapped, but at least it's there. > >> The main difference I see between those two scripts is that one doesn't use a cache file and the other one does, hence the name of the scripts. But it should work without cachefile too, shouldn't it? The other difference is how mountpoints are set, but I can't figure out what could be wrong there. > > I am guessing without seeing the scripts, but I assume the cache you refer to is the /boot/zfs/zpool.cahce file. This file instructs the kernel which zpools to import at boot time. If this file is missing or damaged the kernel cannot import any zpools. So you MUST have a valid zpool.cache file in order to import the zpool containing the "/" zfs dataset That was my understanding, too, but the instructions on the wiki say there's no need to copy the cache file. In fact, there is no cache file to copy, since the pool is created with zpool create -o altroot=/mnt -O canmount=off zroot mirror /dev/gpt/g0zfs /dev/gpt/g1zfs No cache file. The wiki article was changed recently to eliminate that part, the message on the wiki is: "Fix so that the default instructions does not install data directly to the zroot pool. Simplify instructions regarding cache files, they are no longer needed. Fixes and cleanups." Either the instructions are wrong, or something in my script is. I assume it's my script. > > -- > Paul Kraus > Deputy Technical Director, LoneStarCon 3 > Sound Coordinator, Schenectady Light Opera Company > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > ZFSNOCACHE: ========================================================= DISK0="da0" DISK1="da1" echo "will use pool zroot, made up of disks $DISK0 and DISK1" echo "Creating partitions..." echo " $DISK0" gpart create -s gpt $DISK0 gpart add -s 122 -t freebsd-boot -l g0boot $DISK0 gpart add -s 4G -t freebsd-swap -l g0swap $DISK0 gpart add -t freebsd-zfs -l g0zfs $DISK0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISK0 echo " $DISK1" gpart create -s gpt $DISK1 gpart add -s 122 -t freebsd-boot -l g1boot $DISK1 gpart add -s 4G -t freebsd-swap -l g1swap $DISK1 gpart add -t freebsd-zfs -l g1zfs $DISK1 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISK1 echo"done" echo "Loading kernel modules..." kldload opensolaris kldload zfs kldload geom_mirror echo "done" echo 'Setting swap as mirror...' gmirror label gswap /dev/gpt/g0swap /dev/gpt/g1swap echo 'done' echo "Creating zroot..." zpool create -o altroot=/mnt -O canmount=off zroot mirror /dev/gpt/g0zfs /dev/gpt/g1zfs echo "done" echo "Creating filesystems..." echo " checksum" zfs set checksum=fletcher4 zroot echo ' /' zfs create -o mountpoint=/ zroot/ROOT echo ' /tmp' zfs create -o compression=off -o exec=on -o setuid=off zroot/tmp chmod 1777 /mnt/tmp echo ' /usr' zfs create zroot/usr zfs create zroot/usr/local zfs create -o compression=off -o setuid=off zroot/usr/ports zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/distfiles zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/packages zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/usr/src zfs create zroot/usr/obj echo ' /var' zfs create zroot/var zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/crash zfs create -o exec=off -o setuid=off zroot/var/db zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/db/pkg zfs create -o exec=off -o setuid=off zroot/var/empty zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/log zfs create -o compression=gzip -o exec=off -o setuid=off zroot/var/mail zfs create -o exec=off -o setuid=off zroot/var/run zfs create -o compression=off -o exec=on -o setuid=off zroot/var/tmp chmod 1777 /mnt/var/tmp echo ' /home' zfs create -o setuid=off zroot/home echo 'done' echo 'Installing FreeBSD' cd /usr/freebsd-dist export DESTDIR=/mnt for file in base.txz lib32.txz kernel.txz doc.txz ports.txz src.txz; do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done echo 'done' echo 'Setting up the new system' echo ' loader.conf' echo 'zfs_load="YES"' >> /mnt/boot/loader.conf echo 'geom_mirror_load="YES"' >> /mnt/boot/loader.conf echo ' rc.conf' echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf echo 'hostanme="hostname.domain.org"' >> /mnt/etc/rc.conf echo 'ifconfig_bce0="inet 10.1.1.2 netmask 255.255.255.0"' >> /mnt/etc/rc.conf echo 'defaultrouter="10.1.1.1"' >> /mnt/etc/rc.conf echo 'sshd_enable="YES"' >> /mnt/etc/rc.conf echo ' periodic.conf' echo 'daily_status_gmirror="YES"' >> /mnt/etc/periodic.conf echo ' fstab' echo '# Device Mountpoint FStype Opts Dump Pass#' >> /mnt/etc/fstab echo '/dev/mirror/gswap none swap sw 0 0' >> /mnt/etc/fstab echo 'done' echo 'Setting mountpoints on zroot' zfs unmount -a zpool set bootfs=zroot/ROOT zroot zfs set mountpoint=/ zroot/ROOT zfs set mountpoint=/zroot zroot zfs set mountpoint=/tmp zroot/tmp zfs set mountpoint=/usr zroot/usr zfs set mountpoint=/var zroot/var zfs set mountpoint=/home zroot/home zfs set readonly=on zroot/var/empty echo 'done' echo 'exporting the pool' zpool export zroot echo 'all done, can reboot.' ========================================================= ZFSWITHCACHE: ========================================================= DISK0="da0" DISK1="da1" echo "will use pool zroot, made up of disks $DISK0 and DISK1" echo "Creating partitions..." echo " $DISK0" gpart create -s gpt $DISK0 gpart add -b 34 -s 64k -t freebsd-boot -l g0boot $DISK0 gpart add -s 4G -a 4k -t freebsd-swap -l g0swap $DISK0 gpart add -a 4k -t freebsd-zfs -l g0zfs $DISK0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISK0 echo " $DISK1" gpart create -s gpt $DISK1 gpart add -b 34 -s 64k -t freebsd-boot -l g1boot $DISK1 gpart add -s 4G -a 4k -t freebsd-swap -l g1swap $DISK1 gpart add -a 4k -t freebsd-zfs -l g1zfs $DISK1 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISK1 echo"done" echo "Loadin kernel modules..." kldload opensolaris kldload zfs kldload geom_mirror echo "done" echo 'Setting swap as mirror...' gmirror label gswap /dev/gpt/g0swap /dev/gpt/g1swap echo 'done' echo "Creating $POOL..." zpool create -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot mirror /dev/gpt/g0zfs /dev/gpt/g1zfs echo "done" echo "Creating fielsystems" zfs create -o setuid=off zroot/tmp chmod 1777 /mnt/tmp zfs create zroot/usr zfs create zroot/usr/home cd /mnt ln -s usr/home home cd - zfs create zroot/usr/local sleep 5 zfs create -o compression=on -o exec=off -o setuid=off zroot/usr/src zfs create zroot/var zfs create -o exec=off -o setuid=off zroot/var/backups zfs create -o compression=on -o exec=off -o setuid=off zroot/var/crash zfs create -o exec=off -o setuid=off zroot/var/db zfs create -o compression=on -o exec=on -o setuid=off zroot/var/db/pkg zfs create -o exec=off -o setuid=off zroot/var/empty zfs create -o compression=on -o exec=off -o setuid=off zroot/var/log zfs create -o compression=on -o exec=off -o setuid=off zroot/var/mail zfs create -o exec=off -o setuid=off zroot/var/run zfs create -o setuid=off zroot/var/tmp chmod 1777 /mnt/var/tmp zfs create -o setuid=off zroot/usr/ports zfs create -o exec=off -o setuid=off zroot/usr/ports/distfiles zfs create -o exec=off -o setuid=off zroot/usr/ports/packages echo "done" echo "Making zfs bootable, hopefully" zpool set bootfs=zroot zroot mkdir -p /mnt/boot/zfs cp -p /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache echo "done?" echo 'Installing FreeBSD' cd /usr/freebsd-dist export DESTDIR=/mnt for file in base.txz lib32.txz kernel.txz doc.txz ports.txz src.txz; do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done echo 'done' echo 'Setting up the new system' echo ' loader.conf' echo 'zfs_load="YES"' >> /mnt/boot/loader.conf echo 'geom_mirror_load="YES"' >> /mnt/boot/loader.conf echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf echo ' rc.conf' echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf echo 'hostanme="hostname.domain.org"' >> /mnt/etc/rc.conf echo 'ifconfig_bce0="inet 10.1.1.2 netmask 255.255.255.0"' >> /mnt/etc/rc.conf echo 'defaultrouter="10.1.1.1"' >> /mnt/etc/rc.conf echo 'sshd_enable="YES"' >> /mnt/etc/rc.conf echo ' periodic.conf' echo 'daily_status_gmirror="YES"' >> /mnt/etc/periodic.conf echo ' fstab' echo '# Device Mountpoint FStype Opts Dump Pass#' >> /mnt/etc/fstab echo '/dev/mirror/gswap none swap sw 0 0' >> /mnt/etc/fstab echo 'done' echo 'Make sure empty stays empty' zfs set readonly=on zroot/var/empty echo 'done' echo 'all done, can reboot: shutdown -r now' =========================================================