Auto-importing a zfs pool

Hi all,

I have a "root" pool and a "data" pool setup in my zfs system.

Code:
mylo# zpool list
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
zdata  4.06T   645G  3.43T    15%  ONLINE  -
zroot   149G  6.86G   142G     4%  ONLINE  -

The "zroot/root" file system is mounted at boot from loader.conf for "/", and everything else gets auto mounted fine by setting "mountpoint" for that file system. My fstab is empty because everything gets mounted by zfs.

But my second pool doesn't get auto mounted even though I have set a mount point for that file system. I guess this is because I have to import it first with "zpool import zdata", and then it gets mounted like bellow.

Code:
mylo# zfs list
NAME          USED  AVAIL  REFER  MOUNTPOINT
zdata         430G  2.24T  24.0K  none
zdata/data    430G  2.24T   430G  /mnt/data
zroot        8.69G   138G    18K  none
zroot/home   3.38G   138G  3.38G  /home
zroot/local  1.49G   138G  1.49G  /usr/local
zroot/obj     233M   138G   233M  /usr/obj
zroot/ports   902M   138G   902M  /usr/ports
zroot/root    498M   138G   496M  legacy
zroot/src    76.0M   138G  76.0M  /usr/src
zroot/swap      2G   140G   175M  -
zroot/tmp    1.45M   138G  1.45M  /tmp
zroot/var     152M   138G   152M  /var

I already have "zfs_enable='YES'" in my rc.conf, and I thought that would be enough to get zfs to import and mount any pools I have. Is there a correct way to get zdata to import/mount automatically at boot?

Thanks!
 
Long shot, but is your root pool encrypted with /boot on a separate partition? I'm not sure if this is even a possibility but I'm wondering if you have two zpool.cache files and when you import the pool, it's not updating the one that's being read by ZFS during boot.
 
No, the root pool is working fine. I have a second zpool on another set of disks and its not getting imported automatically.

I have two cache-files but I thought FreeBSD 9.2 does not need this file anymore.

If I need then I need to try to update the cache file.
 
I had the exact same problem. Two of my non-root pools remain in exported state and must be manually imported. This is not normal. Temporary fix by placing in /boot/loader.conf:
Code:
zpool_cache_load="YES"
zpool_cache_type="/boot/zfs/zpool.cache"
zpool_cache_name="/boot/zfs/zpool.cache"
 
But here you provide the name to the cache file. I have two cache-files which I think is the problem.

I will try via the Live-CD to import both and generate a new cache-file and use this. Maybe it works.
 
Why do you have two cache files? The cache belongs on the root pool, the other pools will be mounted after root is mounted and the cache file is read.

But here you provide the name to the root zpool

No, that's THE zfs cache file. The only cache file, unless you specify the location as elsewhere in the setting posted above. There is no reason to have more than one zpool.cache
 
Yes, sorry about the name, I read it wrong. Sure you provide the cache file.

That is the point, during zpool creation a cache file was used. I need to fix this point as stated above.
 
If you are able to boot into your root pool, all you need to do is:
# zpool import -f <poolname>
For each pool. The cache file will update its self. You need Live-CD only if you are unable to boot into your installed FreeBSD world.
 
No, the root pool is working fine.

I gather that the root pool works, I was asking if your root pool is encrypted. I'm not sure how ZFS behaves now that FreeBSD doesn't need the cache file. I assume it finds the boot pool automatically, but I'm not sure whether the cache file is still required for additional pools.

The reason I asked if you have an encrypted root pool is because I envisioned the below sequence of events happening (Which are irrelevent if your pool isn't encrypted):

  • You install FreeBSD using an encrypted pool. As part of the install you are required to create a separate un-encrypted /boot partition because the kernel needs to be loaded before decryption can happen.
  • A zpool.cache file is created inside /boot, which is now on the un-encrypted partition
  • You boot into your new OS and your encrypted / file system is mounted
  • You create/import the second pool and a zpool.cache file is created inside /boot, which is now on top of your encrypted filesystem.
  • You reboot, and the kernel picks up the zpool.cache file off the un-encrypted boot partition and sees no mention of the second pool.

I'm not even sure if it's possible that the above could ever happen, or how FreeBSD acts now that no zpool.cache file is required, but I can't think of any other reasons why an imported pool should not be available on boot. Unless the devs have screwed up and the new zpool.cache-less code completely forgets about additional pools.
 
I re-imported the pool and deleted the cache file. No, nothing is encrypted.

Now it seems to work and the additional pool is imported and mounted.
 
to mount automatically zdata run:
zpool set cachefile=/boot/zfs/zpool.cache zdata

It will save currently mounted pools to cache and when reboot import this pool automatically.

Of course, zfs parameter canmount for this pool has to be set to on
zfs set canmount=on zdata
 
Back
Top