Solved Zfs striped mirror install

joholo

New Member


Messages: 6

Hello FreeBSD community,

Next week I will be building my server, which will run FreeBSD (I come from a Linux background). So I was doing some testing in a VM with FreeBSD. So my server will have 4 harddrives which will be setup in a striped mirror (raid10). So I tried to install FreeBSD on 4 virtual disks each 10GB.

The installer has not an option to create a striped mirror only mirrors. I went to the shell and typed the following commands:

Code:
gpart create -s gpt ada0
gpart create -s gpt ada1
gpart create -s gpt ada2
gpart create -s gpt ada3

zpool create zroot mirror /dev/ada0 /dev/ada1 mirror /dev/ada2 /dev/ada3

zpool status gives no warnings and shows to mirrors in zroot. So my question is how do I populate /tmp/bsdinstall_etc/fstab and mount it under /mnt? Because my zpool isn't showing up in /dev/. Handbook source: https://www.freebsd.org/doc/handbook/bsdinstall-partitioning.html

Thank you for your time!
 

kpa

Beastie's Twin

Reaction score: 1,843
Messages: 6,318

The standard method of "mounting" a ZFS is pool is zpool import. This should do the job for the installation to proceed:

zpool import -R /mnt zroot

The pool is not a standard UNIX device and that's why you don't see a device node or nodes for it in /dev.
 
OP
joholo

joholo

New Member


Messages: 6

Thanks for your quick response.

So I tried to install FreeBSD again. While creating the zpool I got the error: cannot mount '/zroot' : failed to create mountpoint. Then I tried zpool import -R /mnt zroot as you suggested. I got the error: cannot import 'zroot' : a pool with that name is already created/imported, and not additional pools with that name were found. Should I unimport export the zroot pool and import it again?

Okay, zpool export zroot exported the pool, when I tried to import it failed to create a mountpoint.
 

kpa

Beastie's Twin

Reaction score: 1,843
Messages: 6,318

Export the pool first to unmount it from its current mountpoint that is now /zroot (the name of the pool).

zpool export zroot

The reason you got the error at first is because in the installation environment the root directory / is read-only and new directories can not be created.
 
OP
joholo

joholo

New Member


Messages: 6

When importing the pool (ofc unmounting it first) it tries to mount on /mnt/zroot instead on /mnt with zpool import -R /mnt zroot.

Update: So I found out that /mnt read-only is when installing FreeBSD. /tmp is not, but the handbook said I need to mount it at /mnt. I'm confused sorry.
 

kpa

Beastie's Twin

Reaction score: 1,843
Messages: 6,318

You need to modify the dataset layout of the pool so that there is a dataset with mountpoint property set to /. Something like:

Code:
zfs create zroot/ROOT
zfs create zroot/ROOT/default
zfs set canmount=no zroot
zfs set canmount=yes zroot/ROOT/default
zfs set mountpoint=/ zroot/ROOT/default

After that the zroot/ROOT/default dataset (filesystem in other words) would be mounted directly at /mnt if the pool was imported with -R /mnt. The /mnt directory on the installation media is read-only but it will be read-write if you mount a read-write filesystem on the directory.
 
OP
joholo

joholo

New Member


Messages: 6

I think I have found a solution. In the installer I created a mirror of 4 drives via the installer partitioner. After the installation I remove ada[2,3]p3 from zroot and added those two as a mirror to zroot.

I now got:
Code:
zroot       ONLINE
  mirror-0  ONLINE
    ada0p3  ONLINE
    ada1p3  ONLINE
  mirror-1  ONLINE
    ada2p3  ONLINE
    ada3p3  ONLINE

It's bootable so I guess it works, but I don't know if this is the proper way to do this??
 

kpa

Beastie's Twin

Reaction score: 1,843
Messages: 6,318

Yes, that works too. I should have thought about that... Extending bootable pools with additional VDEVs is completely fine as long as you make sure you partition the disks used in the additional VDEVs correctly and have boot blocks exactly as the disks in original single VDEV so that the pool is bootable from any disk in the pool in case of a disk failure.
 
Top