LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   LFS with zfsroot (ZFS-On-Linux) (https://www.linuxquestions.org/questions/linux-from-scratch-13/lfs-with-zfsroot-zfs-on-linux-4175498919/)

ReaperX7 03-20-2014 08:52 PM

LFS with zfsroot (ZFS-On-Linux)
 
Okay before anyone says License Incompatibility between CDDL and GPL, yes I already know so let's get to the meat and potatoes of this topic.

I have ZFS-On-Linux built on my LFS compliant host (Slackware 14.1 x64) and installed.

I have little experience outside of FreeBSD with ZFS (which tends to fairly automate the process), so I would like to know how to actually setup a ZFSRoot partition, zpool, with the exception of my 50MB ext2 boot partition on /dev/sda1. I know you can create a swap partition on ZFS, but I know off hand the methods to create zpools is rather complex compared to setting up JFS, Ext4, or any other Linux based native File System.

In the tradition of the LFS books, I would simply like to know the proper command sequences to create a zpool on /dev/sda2 with the remaining file space only with zpool label zfsroot.

Just curious, but is this the correct command for creating a zpool, as well as any sequential commands to setup the partitions and the root file system?

Code:

zpool create -f -m $LFS ztank /dev/sda2
For swap is this correct?

Code:

zfs create ztank/swap -V 2G -b 4K
mkswap -f /dev/ztank/swap
swapon /dev/ztank/swap

For fstab:

Code:

/dev/zvol/ztank/swap none swap discard 0 0
I'm mostly learning at this point, so all I need is some guidance really.

Many thanks ahead of time however. :hattip:

ReaperX7 03-21-2014 04:08 PM

Okay I think I got it.

This is what I used:

Code:

zpool create -f -m zroot /mnt/lfs /dev/sda4
As well as this for the swap partition.

Code:

zfs create ztank/swap -V 2G -b 4K
mkswap -f /dev/ztank/swap
swapon /dev/ztank/swap

I did have to create a separate EXT4 filesystem for /boot mounted from sda3.

I'll have to learn how to dismount these partitions but so far so good. :) I think I have to run:

Code:

zpool export zroot

jefro 03-21-2014 08:11 PM

Thanks for the solution and update.

ReaperX7 03-21-2014 10:21 PM

I don't think I'm anywhere near done however. This is still an ongoing effort and until I can get the system actually booted, no way to tell if it'll work.

Still a working Z-LFS would be nice. And actually that Z-LFS has a nice ring to it.

jefro 03-22-2014 03:14 PM

You are out in space without a tether on this one. Not sure how many people have attempted this. Worthy experiment I'd think.

re_nelson 03-22-2014 03:49 PM

Quote:

Originally Posted by jefro (Post 5139448)
You are out in space without a tether on this one. Not sure how many people have attempted this. Worthy experiment I'd think.

I'm one and it works for me. It was a lengthy, involved process with the first effort an utter failure but the second time around works just dandy. With an emphasis on lengthy, I can post the steps I followed to get a fully-functional, error-free ZFS-based LFS system.

If desired, I can post it here (since I keep a journal of virtually everything I do) but be cautioned that a cascade of text will follow and some is specific to my system. Also be advised that I did it atop GPT. Furthermore, I use my own highly-customized initramfs.

I'll share everything I have about this but I don't want to imply any warranty above "...it works for me" and I want to keep the hand-holding to a bare minimum. In short, I'll share it with those caveats and a cautionary note you're on your own thereafter.

ReaperX7 03-22-2014 04:05 PM

Post away good sir!!!

I'm basing mine off of MBR for now, but it should be a fairly straight forward process for either. I know it recommends you add the zpool scrub <pool> to the cron jobs on a weekly basis.

I don't mind being out in space on this one. I like how featureful ZFS is and know GNU/Linux+ZFS is fairly much do-it-yourself due to the license.

One thing I do like, because LFS is distributed mostly as a book rather than an actual physical distribution, there is not license restriction on redistributing a how-to guide. I wonder if LFS has any hints regarding this?

One thing I do know, you have to set up a initrd to load the SPL and ZFS modules ahead of times, cron job, and some other stuff setup like fstab and all, but I've got several guides that all explain different stuff so I'm hoping everything works.

re_nelson 03-22-2014 04:13 PM

Quote:

Originally Posted by ReaperX7 (Post 5139464)
Post away good sir!!!

Let me assemble it into a tarball form due to the sheer amount of data involved and I'll provide a link from whence it can be downloaded. Furthermore, I have to review it for anything that may be too personal and perhaps eliminate the cuss words when the first attempt was such a loss! :)

...and remember, it will be provided "as is". At our company, it truly is March Madness. We have several people out of the office and a torrent of tasks that have us working long hours. So, what you see is what you get!

re_nelson 03-22-2014 05:40 PM

Quote:

Originally Posted by ReaperX7 (Post 5139464)
One thing I do know, you have to set up a initrd to load the SPL and ZFS modules ahead of times, cron job, and some other stuff setup like fstab and all, but I've got several guides that all explain different stuff so I'm hoping everything works.

The highly-specific-to-my-system tarball can be found here:

http://www.onairusa.com/ZFS-LFS/ZFS-LFS_20140322.tar.xz

Do NOT download it or unpack it until you fully understand and agree to the terms of the following disclaimer, which is also included in the tarball in a longer version:

Quote:

...what I have generously shared here (with some personal data
omitted) goes into the ``what you see is what you get'' category. I have no
time for followup questions at all. In short, you're totally on your own
with the material here.

That said, since you're advanced enough to even handle a project such as
LFS, it's presumed you're highly motivated and intelligent and equipped with
the skills to use the full complement of the rich Unix toolset. And with
this material, you have at least a fighting chance to enjoy LFS on ZFS.

It's also presumed that this is NOT planned for a production system. It also
makes the assumption that you're a genuine hacker in the true sense of that
word. That means you get immense joy from breaking things and then doing the
troubleshooting involved.

-----------------------------------------------------------------------------
THERE IS NO WARRANTY EXPRESSED OR IMPLIED. THIS MAY OR MAY NOT BE FIT
FOR ANY PURPOSE OR EVEN NO PURPOSE AT ALL. IF YOU DAMAGE YOUR SYSTEM
IN ANY WAY, SHAPE OR FORM, THE FAULT IS YOURS AND ANY REMEDY RESTS
SOLELY WITH YOU AND YOU ALONE.

IN THE MANNER OF PONTIOUS PILATE, ``I NOW WASH MY HANDS''.

GOOD LUCK -- YOU'LL SURELY NEED IT. IF ANY OF THIS IS TOO HARSH, THEN
PURGE THE CONTENTS OF THIS TARBALL FROM YOUR SYSTEM AND HAVE A NICE DAY.
-----------------------------------------------------------------------------
And now I walk away from active involvement in this thread. I'll look in from time to time to get an idea of progress but any questions directed to me will be redirected to /dev/null. Fini.

re_nelson 03-22-2014 06:31 PM

Quote:

Originally Posted by re_nelson (Post 5139501)
The highly-specific-to-my-system tarball...

One thing inadvertently omitted from that tarball is my GRUB2 (grub-2.02-beta2) configuration to launch ZFS/LFS. I do it all by hand so it lacks the preamble found in most machine-generated grub.cfg files:

Code:

insmod part_gpt
insmod part_msdos

insmod lvm
insmod ufs2
insmod xfs
insmod zfs

menuentry '0: ZFS/zducky/LFS3 64-bit/Kernel 3.10.33 nvidia' {
    set root=lvm/vg01-lfs3
    linux  /boot/bzImage-3.10.33 root=ZFS=zducky/LFS3 quiet ro nvidia
    initrd  /boot/generic-3.10.33.img
}

menuentry '1: Gentoo 2.2 AMD64' {
    set root=lvm/vg01-gentoo64
    linux  /boot/kernel root=/dev/mapper/vg01-gentoo64 quiet dolvm ro nox
    initrd  /boot/initramfs
}

menuentry '2: Slackware 64-bit current/initrd.gz' {
    set root=lvm/vg03-slackware64
    linux  /boot/vmlinuz root=/dev/mapper/vg03-slackware64 quiet ro
    initrd  /boot/initrd.gz
}

menuentry '3: FreeBSD 9.2 (/boot/loader)' {
    set root='(hd0,gpt3)'
    kfreebsd /boot/loader
}

menuentry '4: Mageia 4 64-bit' {
    set root=lvm/vg02-mageia64
    linux  /boot/vmlinuz root=/dev/mapper/vg02-mageia64 nokmsboot splash quiet ro vga=795
    initrd  /boot/initrd.img
}

[...19 other similar entries elided...]


ReaperX7 03-23-2014 06:34 AM

I'm already compiling a guide from all of this. Thanks for sharing this. The ZFS sysvinit script was useful. I'm also working on an import of dracut to make loading a proper initramfs more simplified to preload SPL and ZFS modules. I'm hoping to get the first build up and running by Tuesday at least, Friday at most.

If all goes as planned, and my system doesn't take a dump, I'll report back with hopefully good news.

I'm still reading through the journal though and have a good question. How long does a zpool scrub take on average?

ReaperX7 03-24-2014 03:12 PM

System build started today as of 1:00 PM Pacific Time.

Partition label as such:

/dev/sda3 - 100MB - ext4 - mounted to /boot
/dev/sda4 - 79GB - zfs - mounted to / via $LFS(/mnt/lfs) lz4 compression enabled

Ran commands:

zpool create -f -m $LFS zroot /dev/sda4

Set zpool cache with:

zpool set cachefile=/etc/zfs/zpool.cache zroot

enabled lz4 compression with:

zfs set compression=lz4 zroot

Created zswap and mounted:

zfs create zroot/swap -V 2G -b 4K
mkswap -f /dev/zroot/swap
swapon -v /dev/zroot/swap


Create boot directory and mounted sda3 to /boot with:

mount -v -t ext4 $LFS/boot /dev/sda3

Began download of all files for LFS...

(No errors so far.)

Update before I sign off for the day...

Currently compiling the system. Should be done with the bootstrap system in about a day or so. Should have the full system built by the weekend maybe, but we'll see.

Stopping at Binutils-2.24 Pass 2 for the day.

ReaperX7 03-25-2014 11:30 PM

Had a nasty incident today. Not sure what happened but the zroot became corrupted on boot up and refused to remount.

Had to destroy the z-volume entirely and start all over again. Not sure what exactly happened there. Going to continue on with LFS using JFS as a temporary measure until I can completely tarball the completed system up, rebuild the ZFS volume and then untar the backup onto the ZFS volume, reset it, and then try again that way.

I used the proper dismounting techniques but it claims the volume got corrupted. Very strange.

Going to attempt to restore it with the tables as:

zvol/root
zvol/swap

...as the volume partitions. I really wish there was an easier way to do this, but unfortunately there isn't ArchLinux has a good tutorial I'm going to try after I tarball the system up upon completion.


All times are GMT -5. The time now is 11:49 AM.