FreeNAS root on ZFS

Status
Not open for further replies.

HarryE

Cadet
Joined
May 27, 2011
Messages
6
As I am a big fan of ZFS, I tweaked FreeNAS to boot&run completely from ZFS. No UFS at all. On a single 2Gb stick, root filesystem takes 431Mb on ZFS.
Having root on ZFS brings the advantages of customization of the filesystem (rw root) without the worries of "pulling-the-plug" solved by read-only root +MD of nanobsd.
The upgrades/downgrades could be simple zfs receive or clone/rollbacks.


The web interface doesn't see the zpool but sees the snapshots in root zfs.
I suppose I have to go into some sqlite db and manually add something, since the autoimport doesn't work for active zpools.

Any ideas on how to do this?
 

survive

Behold the Wumpus
Moderator
Joined
May 28, 2011
Messages
875
Hi HarryE,

Sounds like a very cool project you have going on there. Be sure to let us know what you find out!

-Will
 

HarryE

Cadet
Joined
May 27, 2011
Messages
6
Almost there...

Here it is:
I used my regular FreeBSD 8.2 to create 3 partitions on a 2GB stick as described in FreeBSD's Root-on-zfs tutorial, 1 for bootstrap, one for swap, and one for zpool.
Then I created the zpool, named it nanozfs to please the two worlds :smile: . Inside I created 3 zfs filesystems named nanozfs/part1, nanozfs/cfg and nanozfs/data.
Next I copied the content of the FreeNAS partitions from another stick into nanozfs/part1, nanozfs/cfg and nanozfs/data filesystems accordingly.
Adjusted loader.conf, fstab, rc.conf and created a necessary fsck_zfs (as a simple exit 0). Removed /conf/default/etc/remount.
At some point there was a "zpool set bootfs=nanozfs/part1 nanozfs" involved.
Since then I found the necessary tables to be modified in order to manually import zfs filesystems into web interface.
In the morning I'll download a newer version of FreeNas, create a nanozfs/part2 filesystem, copy the content + tweaks into it.
Then snaphot nanozfs/cfg, nanozfs/data just in case I want to rollback.
A zpool set bootfs=nanozfs/part2 nanozfs will help to boot the new version.
 

liveisousb

Cadet
Joined
Oct 6, 2014
Messages
2
Hey HarryE, have you been able to do this for 9.2.1.8?

I've only been able to do a hacky workaround.

!! THIS IS PROBABLY TOTALLY UNSUPPORTED USE AT YOUR OWN RISK !!

Setup:
- machine has small internal drive as /dev/ada0 and boot from a "liveisousb"
- boot into mfsBSD from liveisousb
- setup /dev/ada0 with a zpool "autoroot" mounted to /mnt
- copy mfsBSD's mfsroot to /mnt/
- copy FreeNAS USB image to /mnt/
- copy FreeNAS /boot to /mnt/
- copy a chroot script to /mnt/
- reboot

How it works:
- when the system boots up from /dev/ada0
- loads mfsroot into RAM
- script does zpool import autoroot
- runs chroot script
- FreeNAS running USB image is mounted as /freenas
- /cfg and /data is mounted on /freenas/cfg and /freenas /data
- devfs is mounted as /freenas/dev
- FreeNAS continues boot from /freenas/etc/rc

I tried to simplify it with a script which you will need to modify to suit your environment:
https://github.com/johnko/johnko.github.io/blob/master/posts/tech/20141005-freenas-on-zfs-root.md
https://github.com/johnko/johnko.github.io/blob/master/scripts/mfsbsd-freenaszfs.sh
 

mjws00

Guru
Joined
Jul 25, 2014
Messages
798
Heh. Is that better than running 9.3 alpha? Nice necro. Like the script and mfsbsd. :)
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Sorry, I'm gonna lock this thread. It's more than 3 years old. There is no reason to pull up a thread that old with a question. :P

This will be part of 9.3, so be patient. Or go grab the alpha builds and give them a try. :)
 

solarisguy

Guru
Joined
Apr 4, 2014
Messages
1,125
May be instead of a locked thread, someone who knows/understands ZFS root changes in 9.3 would explain them here. The thread title and posts seem to be relevant, just FreeNAS 9.3 took a different(?) route.
 
  • Like
Reactions: Oko
Status
Not open for further replies.
Top