# Can't install Root on ZFS FreeBSD 9.2



## fred974 (Dec 6, 2013)

Hello everyone,

I have been trying to set up a new ZFS environment for three weeks now and I keep getting the following error message:

```
cannot mount '/mnt/zroot': failed to create mountpoint
```

In order to do my root ZFS installation on FreeBSD 9.2, I am using the guide from aisecure.net and adapted it so it works for three disks on RAID-Z1 instead of mirror
http://www.aisecure.net/2012/01/16/rootzfs/. So far this is what *I* did:


```
gpart delete -i 2 ada0
gpart delete -i 1 ada0
gpart destroy -F ada0

gpart delete -i 2 ada1
gpart delete -i 1 ada1
gpart destroy -F ada1

gpart delete -i 2 ada2
gpart delete -i 1 ada2
gpart destroy -F ada2

gpart create -s gpt ada0
gpart add -b 34 -s 94 -t freebsd-boot ada0
gpart add -t freebsd-zfs -l disk0 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

gpart create -s gpt ada1
gpart add -b 34 -s 94 -t freebsd-boot ada1
gpart add -t freebsd-zfs -l disk1 ada1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1

gpart create -s gpt ada2
gpart add -b 34 -s 94 -t freebsd-boot ada2
gpart add -t freebsd-zfs -l disk2 ada2
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada2

gnop create -S 4096 /dev/gpt/disk0
gnop create -S 4096 /dev/gpt/disk1
gnop create -S 4096 /dev/gpt/disk2

zpool create -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot raidz1 /dev/gpt/disk0.nop /dev/gpt/disk1.nop /dev/gpt/disk2.nop

zpool export zroot

gnop destroy /dev/gpt/disk0.nop /dev/gpt/disk1.nop /dev/gpt/disk2.nop

==> zpool import -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot <== This is when i get the error message
```

Can anyone tell me why when I type the last line, I get that message? My box had FreeNAS on it before. Could it be because of the previous pool that I had? How can *I* wipe all the three disks more effectively?

Thank you all.

Fred


----------



## SirDice (Dec 6, 2013)

A lot of howtos use /mnt/zroot or something like it as a temporary mount point. Unfortunately, if you boot the CD/DVD and go to Shell or Live option the root filesystem is read-only. This includes the /mnt/ directory. Use something like /tmp/zroot instead, you should be able to write there.

So use something like this:
`zpool create -o altroot=/tmp/zroot -o mountpoint=/ -o cachefile=/var/tmp/zpool.cache zroot raidz1 /dev/gpt/disk0.nop /dev/gpt/disk1.nop /dev/gpt/disk2.nop`

Then proceed to extract everything to /tmp/zroot/.


----------



## fred974 (Dec 6, 2013)

Thank you for your quick reply @SirDice,

I'll give that a go tonight and will keep you posted 

Fred


----------



## fred974 (Dec 13, 2013)

Hi @SirDice
	
	



```

```
,

Thank you very much for your advi_c_e, it did sol_v_e the problem that I had. Would anyone know why I get the following error message when I try to run `zpool set feature@lz4_compress=enabled zroot`:

```
cannot set property for 'zroot' : invalid property 'feature@lz4_compress'
```

Thank you.


----------



## chrcol (Dec 16, 2013)

Guys I followed this guide and works well. https://wiki.freebsd.org/RootOnZFS/GPTZ ... .0-RELEASE

I did not do it all word for word as I found I was able to set up the partitions before running bsdinstall from the mfsBSD environment.  So I created the GPT partitions 4k aligned (even tho though  512-byte drives), I did not do the virtual device setup meaning my ZFS was set up with a 512-byte ashift.

After the filesets were made I ran bsdinstall (which to say is a huge improvement over sysinstall), the process at this point was very simple much more streamlined than previous versions of FreeBSD.  In the end make sure to remember to install the bootloader on all HDD's and to run the final commands as in that guide.  I did install the cache file even tho though it said I don't need to.


----------



## ShelLuser (Dec 16, 2013)

fred974 said:
			
		

> I have been trying to set up a new ZFS environment for three weeks now and I keep getting the following error message:
> 
> ```
> cannot mount '/mnt/zroot': failed to create mountpoint
> ```


The reason that this is happening is because the behaviour of zpool has changed. In the previous situation it would create the pool and use /mnt as the mountpoint. That behaviour was actually not fully correct since /mnt was the so called alternate root, not the mountpoint perse.

You can solve this by specifying both the mountpoint and alternate root of the pool you're creating. So basically, this command `# zpool create -o altroot=/mnt zroot /dev/gpt/disk0` doesn't work using FreeBSD 9.2 and now needs to be specified like this: `# zpool create -m / -o altroot=/mnt zroot /dev/gpt/disk0`.

See also this message I wrote about this change in behaviour some time ago. And when you're there I'd also recommend reading the HOWTO which the OP of that thread wrote; it also deals with installing ZFS as the root filesystem, excellent material.


----------



## fred974 (Dec 16, 2013)

Hi @ShelLuser,

Thank you for sharing your knowledge on the subject. Could you please tell me if *I* can do the mountpoint all in one line as `zpool create -m / -o altroot=/mnt zroot  mountpoint=/ zroot /dev/gpt/disk0` instead on doing  `zpool create -m / -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0` and then `zfs set mountpoint=/ zroot`?


----------



## ShelLuser (Dec 16, 2013)

fred974 said:
			
		

> Could you please tell me if i can do the mountpoint all in one line as follow:
> 
> `zpool create -m / -o altroot=/mnt zroot  mountpoint=/ zroot /dev/gpt/disk0`


Do check up with the zpool(8) manualpage. The -m option is merely an alias for the mountpoint property, so you don't have to use both at the same time. Also keep in mind that if you specify multiple properties all of them will need to be specified as such using -o.


----------



## fred974 (Dec 17, 2013)

Thank you @ShelLuser*.*


----------

