LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 03-20-2014, 09:52 PM   #1
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
Question 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.
 
Old 03-21-2014, 05:08 PM   #2
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444

Original Poster
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
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

Last edited by ReaperX7; 03-21-2014 at 05:29 PM.
 
Old 03-21-2014, 09:11 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,563

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
Thanks for the solution and update.
 
Old 03-21-2014, 11:21 PM   #4
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444

Original Poster
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
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.
 
Old 03-22-2014, 04:14 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,563

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
You are out in space without a tether on this one. Not sure how many people have attempted this. Worthy experiment I'd think.
 
Old 03-22-2014, 04:49 PM   #6
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
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.
 
1 members found this post helpful.
Old 03-22-2014, 05:05 PM   #7
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444

Original Poster
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
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.

Last edited by ReaperX7; 03-22-2014 at 05:26 PM.
 
Old 03-22-2014, 05:13 PM   #8
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by ReaperX7 View Post
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!

Last edited by re_nelson; 03-22-2014 at 05:16 PM.
 
Old 03-22-2014, 06:40 PM   #9
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by ReaperX7 View Post
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.
 
1 members found this post helpful.
Old 03-22-2014, 07:31 PM   #10
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by re_nelson View Post
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...]

Last edited by re_nelson; 03-22-2014 at 07:35 PM.
 
Old 03-23-2014, 07:34 AM   #11
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444

Original Poster
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
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?
 
Old 03-24-2014, 04:12 PM   #12
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444

Original Poster
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
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.

Last edited by ReaperX7; 03-24-2014 at 09:37 PM.
 
Old 03-26-2014, 12:30 AM   #13
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-Current
Posts: 6,444

Original Poster
Blog Entries: 15

Rep: Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013Reputation: 2013
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.

Last edited by ReaperX7; 03-26-2014 at 12:31 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem installing Arch system on a ZFS root: "ZFS: Cannot find bootfs." on boot. tajjada Linux - Software 4 12-25-2013 03:07 AM
ZFS and LFS re_nelson Linux From Scratch 2 05-25-2013 06:19 PM
LXer: Article ZFS data integrity testing and more random ZFS thoughts. LXer Syndicated Linux News 0 05-15-2010 01:51 PM
ZFS Root / Boot into ZFS from a usb flash drive Kataku Solaris / OpenSolaris 1 07-15-2006 05:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 07:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration