# Mounting Root Failed



## markfisher (Jul 14, 2013)

Hi

I'm trying to set[]up ZFS on my computer using this: http://www.keltia.net/howtos/mfsbsd-zfs91/ (no mirroring). I'm skipping the beginning section(s) and start from the section _"Partitioning the drives"_.

I'm using FreeBSD-9.1-RELEASE-amd64-memstick.img copied onto a USB memory stick and boot up the computer from it. From bsdinstall, I go directly to "Shell".

Here are the steps:

```
mount -rw /
kldload zfs
kldload geom_eli

gpart delete -i 1 ada1
gpart delete -i 2 ada1
gpart delete -i 3 ada1
gpart delete -i 4 ada1
gpart destry ada1
dd if=/dev/zero of=/dev/ada1 bs=512 count=10 # Not necessary :-)

gpart create -s gpt ada1
gpart add -b 40 -s 64K -a 4k -t freebsd-boot ada1
gpart add -s 2G -a 4k -t freebsd-zfs -l zboot0 ada1
gpart add -s 4G -a 4k -t freebsd-swap -l swap0 ada1
gpart add -a 4k -t freebsd-zfs -l zpool0 ada1

gpart set -a bootme -i 2 ada1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1

mkdir /root/keys
dd if=/dev/random of=/root/keys/boot.key bs=128k count=1
geli init -b -K /root/keys/boot.key -s 4096 -l 256 /dev/gpt/zpool0
geli attach -k /root/keys/boot.key /dev/gpt/zpool0

zpool create zboot gpt/zboot0
zpool create zpool gpt/zpool0.eli

zfs set checksum=fletcher4 zboot
zfs set checksum=fletcher4 zpool


zfs create -o compression=off zpool/root
zfs create -o mountpoint=/zpool/root/usr zpool/usr
zfs create -o mountpoint=/zpool/root/usr/obj -o compression=lzjb zpool/usr/obj
zfs create -o mountpoint=/zpool/root/usr/local zpool/usr/local
zfs create -o mountpoint=/zpool/root/usr/src -o compression=lzjb zpool/usr/src

zfs create -o mountpoint=/zpool/root/usr/ports -o compression=lzjb -o setuid=off zpool/usr/ports
zfs create -o mountpoint=/zpool/root/usr/ports/distfiles -o compression=off -o exec=off -o setuid=off zpool/usr/ports/distfiles
zfs create -o mountpoint=/zpool/root/usr/ports/packages -o compression=off -o exec=off -o setuid=off zpool/usr/ports/packages

zfs create -o mountpoint=/zpool/root/home zpool/home
zfs create -o mountpoint=/zpool/root/tmp -o compression=lzjb -o exec=off -o setuid=off zpool/tmp
chmod 1777 /zpool/root/tmp

zfs create -o mountpoint=/zpool/root/var zpool/var
zfs create -o exec=off -o setuid=off zpool/var/run
zfs create -o exec=off -o setuid=off zpool/var/db
zfs create -o compression=lzjb  -o exec=on -o setuid=off zpool/var/db/pkg
zfs create -o exec=off -o setuid=off zpool/var/empty
zfs create -o compression=lzjb -o exec=off -o setuid=off zpool/var/log
zfs create -o exec=off -o setuid=off -o mountpoint=/zpool/root/var/tmp -o compression=lzjb zpool/var/tmp
chmod 1777 /zpool/root/var/tmp

zfs set reservation=512m zpool
cd /usr/freebsd-dist

for i in base kernel ports src; do
xz -d -c $i.txz | tar -C /zpool/root -xf -
done

vi /zpool/root/boot/loader.conf [B]# The content is in the bottom[/B]
vi /zpool/root/etc/sysctl.conf  [B]# The content is in the bottom[/B]
vi /zpool/root/etc/rc.conf      [B]# The content is in the bottom[/B]

mkdir /boot/zfs
zpool export zpool && zpool import zpool
cp /boot/zfs/zpool.cache /zpool/root/boot/zfs/

cp -r /root/keys /zpool/root/boot/

cd /zpool/root
mv boot oldboot
mkdir /zboot/boot
cp -Rp oldboot/* /zboot/boot/

vi /zpool/root/etc/fstab      [B]# The content is in the bottom[/B]
cd /

zfs umount -a

zfs set mountpoint=legacy zpool
zfs set mountpoint=/tmp zpool/tmp
zfs set mountpoint=/home zpool/home
zfs set mountpoint=/var zpool/var
zfs set mountpoint=/var/run zpool/var/run
zfs set mountpoint=/var/db zpool/var/db
zfs set mountpoint=/var/db/pkg zpool/var/db/pkg
zfs set mountpoint=/var/empty zpool/var/empty
zfs set mountpoint=/var/log zpool/var/log
zfs set mountpoint=/var/tmp zpool/var/tmp
zfs set mountpoint=/usr zpool/usr
zfs set mountpoint=/usr/src zpool/usr/src
zfs set mountpoint=/usr/obj zpool/usr/obj
zfs set mountpoint=/usr/local zpool/usr/local
zfs set mountpoint=/usr/ports zpool/usr/ports
zfs set mountpoint=/usr/ports/distfiles zpool/usr/ports/distfiles
zfs set mountpoint=/usr/ports/packages zpool/usr/ports/packages

zfs set readonly=on /zpool/root/var/empty
zpool set bootfs=zpool/root zpool

shutdown -r now
```

In my /zpool/root/boot/loader.conf I have:

```
zfs_load="YES"
geom_label_load="YES"
geom_uzip_load="YES"
vm.kmem_size="8G"
vfs.root.mountfrom="zfs:zpool/root"
vfs.zfs.txg.timeout="5"

geli_zpool0_keyfile0_load="YES"
geli_zpool0_keyfile0_type="gpt/zpool0:geli_keyfile0"
geli_zpool0_keyfile0_name="/boot/keys/boot.key"
```

In my /zpool/root/etc/sysctl.conf I have:

```
kern.maxvnodes=260000
```

In my /zpool/root/etc/rc.conf I have:

```
zfs_enable="YES"
geli_swap_flags="-e aes -l 256 -s 4096 -d"
```

In my /zpool/root/etc/fstab I have:

```
/dev/gpt/swap0.eli    none    swap    sw    0    0
```

After restarting the system can't mount root.

Thanks for the help.


----------



## wildtollwut (Jul 21, 2013)

What's the error message/code?


----------

