ZFS: Mounting Pool

Hi

I have 1 SSD drive that supports TRIM and also I have 250GB HDD. My setup is as follow:
Code:
                Pool Name        Mount to
SSD Drive       root             legacy
HDD Drive       tank             /tank

The way I've created these pools are as follow:
zpool create -m /boot/zfs/root root /dev/ada0p1
mkdir /boot/zfs/root/tank
zpool create -m /boot/zfs/root/tank tank /dev/ada1p1

  1. Every time I boot up my machine, tank is not getting mounted. I have to initiate zpool import -f tank in order to mount this pool.
    • How can I make tank pool to get mounted automatically?
    • Do I need to add this to /etc/fstab? If so why the other pool, root, is getting mounted automatically without modifying /etc/fstab?
  2. When I use tunefs -t enable /dev/ada0p1 to enable TRIM support on my SSD, I get an error about superblock, How can I check that TRIM is enabled on my SSD?
  3. Very noob question :), and sorry if it's off topic, when I compile my kernel with device crypto for ZFS encryption, do I still need to add crypto_load="YES" to my /boot/loader.conf?

Please let me know if more information needed.
Thanks in advance.
 
I'm not 100% certain why your second pool does not show up on boot. ZFS keeps a cache file in /boot/zfs/zpool.cache that it uses on boot to load additional pools. I can only think that for some reason the second pool has not been added to this file. It may be worth trying to export and re-import the pool. This is the first time I've ever seen someone specify a directory under /boot/zfs to mount a pool but I see no obvious reason why this would of caused a problem. Do you have to specify the -f flag every time you import? This suggests the system is appearing with a different host ID every boot which is very strange. If not, then you really shouldn't specify -f unless you get an error without it and know what you're doing. People regularly get themselves in trouble by using -f when they shouldn't of.

I assume that the file system on the SSD pool is actually being used as your root filesystem? If you want the second pool mounted on /tank, it only needs its mountpoint property set to /tank, not /boot/zfs/root/tank.

tunefs is used to tune UFS filesystems. The thread below gives some information on how to use TRIM on ZFS, and some sysctl flags that will let you know if it's working. As far as I can see it should be enabled by default.

viewtopic.php?f=48&t=44803

There is no ZFS encryption support in OpenZFS (the fork used by everyone other than Oracle). Currently, the only way to get an encrypted pool is to encrypt to raw disk devices first using GELI, then build you pool on top of that encrypted devices. You shouldn't need to recompile your kernel to do this, all the support is either already in the kernel or can be loaded dynamically on boot. I'm sure there's a few guides on here for setting up a ZFS pool on GELI. Encryption is listed as a desirable feature on the OpenZFS website, I do hope they actually implement it but it could easily be years away.

*Just to add to the last point, adding an entry to /boot/loader.conf will dynamically load a module. If you compile the same module directly into the kernel, then you obviously don't need the entry in loader.conf anymore. If loading a module dynamically is working though, It's hardly worth rebuilding the kernel just to add it statically.
 
@usdmatt Thanks for your reply. Very helpful information.

I was practicing and experimenting with ZFS. I did import and export the pool and then reset still no luck:
zpool import -f tank
zpool export tank

I ended up reinstalling my system, but this time after boot from DVD, and jump to shell I used /tmp directory. For pool creation I used:
zpool create -o altroot=/tmp/ZROOT -o cachefile=/tmp/zpool.cache root /dev/ada0p2
zpool create -o altroot=/tmp/ZROOT -o cachefile=/tmp/zpool.cache tank mirror /dev/ada1p1 /dev/ada2p1

Then setup file system:
zfs create -o mountpoint=none root/ROOT
zfs create -o mountpoint=none root
zfs create -o mountpoint=none tank
zfs create -o mountpoint=/tank tank/ztank
zfs create -o mountpoint=/ root/ROOT/default

After FreeBSD installation, tank still not getting mounted automatically. Any idea why?

Thanks
 
Last edited by a moderator:
Did you copy the cache file to the new system after installing FreeBSD?
As mentioned in my last post it needs this to know what pools to import on boot.

Code:
cp /tmp/zpool.cache /boot/zfs/

I probably would've just got the system working with the boot pool, then created the second pool when the machine was fully up.

Also, you'll want the following in /etc/rc.conf if you haven't already. Without this the pool should still be imported and show in zfs/zpool commands, but none of the file systems will be mounted automatically.

Code:
zfs_enable="YES"
 
@usdmatt

Sorry again for responding late. I was trying different methods to setup ZFS in virtual environment.

Did you copy the cache file to the new system after installing FreeBSD?
Yes I did :).


I probably would've just got the system working with the boot pool, then created the second pool when the machine was fully up.
So I booted up from CD/DVD (VirtualBox). In VirtualBox I created 4 SATA hard drive ada0, ada1, ada2, and ada3

Note for now I'm not using encryption. I've created 2 partitions in ada0:
Code:
ada0p1 => Type: freebsd-boot, Size: 512k
ada0p2 => Type: freebsd-zfs, Size: Reset of the drive

ada1 has 2 partitions as well:
Code:
ada1p1 => Type: freebsd-swap, Size: 1G
ada1p2 => Type: freebsd-zfs, Size: Reset of the drive

bootsys is on ada0p2 and rootsys is on ada1p2. System boots up OK except I have to use
zpool import -f bootsys
to get the bootsys to be loaded.

In the newly installed ZFS system, I followed:
Code:
cd /
gpart create -s gpt ada2
gpart create -s gpt ada3
gpart add -a 4k -t freebsd-zfs ada2
gpart add -a 4k -t freebsd-zfs ada3

gnop create -S 4096 /dev/ada2p1
gnop create -S 4096 /dev/ada3p1
zpool create tank mirror /dev/ada2p1.nop /dev/ada3p1.nop
zpool export tank
gnop destroy /dev/ada2p1.nop
gnop destroy /dev/ada3p1.nop
zpool import tank

zfs set mountpoint=none tank
zfs set checksum=fletcher4 tank

zfs create -o mountpoint=/tank -o compression=off tank/data

And then I reboot my computer:
shutdown -r now

tank still not getting mounted and I have to issue
zpool import tank


I still don't know why tank won't get mounted automatically.

Thanks
 
Last edited by a moderator:
Back
Top