Rudd-O / zfs-fedora-installer

Fedora on ZFS root installer
35 stars 6 forks source link

Use in centos? #11

Closed fire closed 6 years ago

fire commented 8 years ago

Is it possible for a centos version?

Sloepie commented 8 years ago

It is absolutely possible, because about a year ago I had ZFS working natively on CentOS and used it in a testing environment for more than a half year.

Because Grub can not (yet?) handle native ZFS (root) pools properly I used one of the tools Rudd-O made available for Fedora in order to solve the same Grub problem for Fedora.

But after I upgraded to a newer CentOS version (with a clean install), it appeared that Rudd-O had changed that tool and while I had not made a copy of it I could not get it working any more.

And, as I am not a programmer, I could not not completely understand what his tool was exactly doing. So I finally gave it up and moved to FreeBSD as at the moment ZFS on FreeBSD is more developed than ZFS on Linux (ZOL) and especially because Grub does not know (yet?) how to handle Root Pools properly.

However once the system booted properly, ZOL was also working fine with CentOS.

Rudd-O commented 8 years ago

Any pull requests that add CentOS support, I will happily merge.

Remember this program here fixes the GRUB not knowing how to handle root pools problem.

Sloepie commented 8 years ago

Hello Rudd-O,

I would love to get CentOS working with ZFS, but one of the reasons I switched to FreeBSD is lack of time. Also my programming capabilities and my understanding of Grub are not good enough to be really helpful.

Nevertheless, as the problems seems to sit for the most part in the fact that Grub does not know how to handle (mirrored) root pools and I have had Centos working natively with ZFS before with the help of your tools it must be possible to get it working again.

If you don’t mind working together with me this way? I still have my own notes (from august 2014) available how to set up a working ZFS environment on CentOS with your original tools. (This was the CentOs system that I initially got working with native ZFS)

FYI: If I remember right I could not reinstall ZFS on CentOS because you removed the contents of /usr/src/grub-mkconfig.in in this command patch -p2 < /usr/src/zfs/patches/grub-mkconfig-zfs-support.diff

And of course I don't know what else has changed in the meantime

Maybe you can find out what the problem is when I send you the complete notes, because the notes I made mainly consist of the commands to be given in the right order, with some comments to explain to myself what happens

However, as it is partly in Dutch, I have to translate it before I can send the notes to you. I don't have time do that before the beginning of next week. And in about 4 weeks I will have a bit more time to set up a testing environment again in order to try things out

So please let me know if this is acceptable for you and whether you like me to send these notes to you.

Rudd-O commented 8 years ago

Sup. Happy to help. In my installer, GRUB is deployed, not to a ZFS dataset, but to a very small ext2 partition. This completely evades the problem of not being able to use GRUB in a mirrored pool altogether.

The patch in question is gone, because a better solution was developed:

https://github.com/Rudd-O/zfs-fedora-installer/tree/master/grub-zfs-fixer

This solution avoids having to recompile GRUB, it also avoids having to block GRUB from updating (which would give you the bad, useless upstream GRUB and break your boot), and all it does is patch a few files at runtime (yes, hacky but better than nothing).

Build RPM, install built RPM on system that has vanilla GRUB, presto, GRUB can now properly generate menus for systems that have ZFS root pool (but, of course, not GRUB itself installed within the root pool). The menu generation thing was the only reason why GRUB needed to be recompiled, from the standpoint of my installer script. Since GRUB no longer needs to be recompiled (just that patcher RPM installed), the diff is no longer necessary, and recompiling GRUB is no longer necessary, and blocking GRUB from updating is no longer necessary.

I am confident that the link above containing a RPM that patches your GRUB would work just fine in CentOS.

I welcome your notes in this bug. Even if they are in dutch, that's what Google Translate is for.

Sloepie commented 8 years ago

Hello Rudd-O

Ofcourse I tried your grub-zfs-fixer and it should be great not having to freeze the grub anymore. But I could not get it working.

But after the installation and the reboot Grub could not boot ZFS. But I don't remember the exact error message. Maybe it kept looking for /dev/sd? and could not find the pool

I remember that I had set it up on two mirrored disk, including the ext2 partition (I tested it with the ext2 partition also mirrored and an ext2 only on the first disk.)

Underneath you will find the script. But I am not 100% sure whether or not I changed things trying to get your grub-zfs-fixer running and whether or not it is complete or that there are parts that don't belong here because of this testing. That I also wanted to test before I would send you the file.

Also I do not remember what I used from the pluralsight blog as the link does not exist anymore and what part came from you In general if I remember right I first installed ZFS on a booted CentOs System and then I created with chroot the ZFS root file system.

To remember better what I did I have to set it up in virtualbox again. So if you can not make sense what happens in this script, let me know.
Than I will set it up in virtualbox again next week and see if I can reconstruct the script. I have some more notes about setting up a rooted ZFS system in which some parts also refer to things I did before in ZFS

It is a bit messy but I believe there is an 80% chance that this is the original and complete script (except for the pluralsight blog, but maybe I only used that as a reference) with which I got CentOS on ZFS running

I hope it can help solve the problem. It would be great to have CentOS running on ZFS without having to freeze Grub and kernel updates.

Please let me know how it is going

Best regards,

Okay here the script starts:

Install dependencies yum localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm yum install kernel-devel zfs

setup zfs to startup at boot http://blog.pluralsight.com/zfs-it%E2%80%99s-that-simple chkconfig --add zfs

Begin hier:

website met originele instructies: http://rudd-o.com/linux-and-free-software/installing-fedora-on-top-of-zfs

kopieer fstab-decode van lokaal naar server als normale user maarten niet als root maarten scp fstab-decode maarten@192.168.23.100:/home/maarten

op server move bestand naar /sbin mv fstab-decode /sbin/

controleer of partitie /tijdelijk niet is gemount (mag niet gemount zijn) umount /dev/sda2

disable selinux nano /etc/selinux/config selinux=disabled setenforce 0 (werkt niet, reboot nodig) sestatus

Install dependencies yum install -y git patch kernel-devel gcc zlib-devel libuuid-devel libtool automake autoconf cd /usr/src git clone https://github.com/zfsonlinux/spl git clone https://github.com/Rudd-O/zfs cp /sbin/grub2-mkconfig /usr/src/grub-mkconfig.in patch -p2 < /usr/src/zfs/patches/grub-mkconfig-zfs-support.diff bestand staat in: /usr/src/grub-mkconfig.in mv /usr/src/grub-mkconfig.in /usr/src/grub2-mkconfig

ZFS installeren yum localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm yum install kernel-devel zfs

shutdown now maak snapshot

yum install zfs-dracut zpool create syspool -m none -o ashift=12 /dev/vda2 zfs create syspool/ROOT zfs create syspool/ROOT/centos zfs set compression=on syspool zfs set atime=off syspool zpool export syspool zpool import -o altroot=/sysroot syspool zfs set mountpoint=/ syspool/ROOT/centos

rsync -axv / /sysroot/ rsync -axv /dev/ /sysroot/dev/

maak snapshot

chroot /sysroot/ mount -t proc proc /proc mount -t sysfs sys /sys mount /boot

nano /etc/fstab vervang de root mount / met syspool/ROOT/centos zfs noatime 0 0

/usr/src/grub2-mkconfig | tee /boot/grub2/grub.cfg

dracut -f /boot/initramfs-uname -r.img uname -r

umount /boot umount /sys umount /proc exit zpool export syspool

Klaar? reboot

Op 03-01-16 om 19:21 schreef Rudd-O:

Sup. Happy to help. In my installer, GRUB is deployed, not to a ZFS dataset, but to a very small ext2 partition. This completely evades the problem of not being able to use GRUB in a mirrored pool altogether.

The patch in question is gone, because a better solution was developed:

https://github.com/Rudd-O/zfs-fedora-installer/tree/master/grub-zfs-fixer

This solution avoids having to recompile GRUB, it also avoids having to block GRUB from updating (which would give you the bad, useless upstream GRUB and break your boot), and all it does is patch a few files at runtime (yes, hacky but better than nothing).

I am confident that the link above containing a RPM that patches your GRUB would work just fine in CentOS. Build RPM, install on system that has vanilla GRUB, presto, GRUB can now properly generate menus for systems that have ZFS root pool (but, of course, not GRUB itself installed within the root pool).

I welcome your notes in this bug. Even if they are in dutch, that's what Google Translate is for.

— Reply to this email directly or view it on GitHub https://github.com/Rudd-O/zfs-fedora-installer/issues/11#issuecomment-168526808.

Rudd-O commented 8 years ago

Please post a picture of the boot error as it is shown by the initial RAM disk, then shift+pageup (that scrolls one screenful up) and take another picture of that to post here.

I'll close the bug provisionally but if the instructions below do not work to install on CentOS, please let me know what fails and I will happily adapt them.

https://rudd-o.com/linux-and-free-software/installing-fedora-on-top-of-zfs/index

Rudd-O commented 8 years ago

Note: deploy-zfs deploys grub-zfs-fixer. It is not clear to me whether grub-zfs-fixer works on CentOS, but I am truly more than happy to make it work (all it does, is patch the grub2-mkconfig program). I accept changes to make the script work on CentOS too.

Rudd-O commented 8 years ago

I'll reopen the issue to track progress of making everything work with CentOS.

Rudd-O commented 7 years ago

The code has been refactored substantially and there should be minimal changes needed outside of pm.py to enable CentOS support. Hint hint, it's easy to contribute that support as a pull request now!

Rudd-O commented 6 years ago

I'm closing this due to lack of interest.