Last active
November 24, 2016 23:42
-
-
Save kaid/6449801 to your computer and use it in GitHub Desktop.
funtoo_zfs_install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boot { | |
generate grub | |
default "Funtoo ZFS" | |
timeout 4 | |
} | |
"Funtoo Linux" { | |
kernel bzImage[-v] | |
} | |
"Funtoo ZFS" { | |
kernel vmlinuz[-v] | |
initrd initramfs-genkernel-x86_64[-v] | |
params real_root=ZFS=rpool/ROOT/funtoo | |
params += dozfs | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/fstab: static file system information. | |
# | |
# <fs> <mountpoint> <type> <opts> <dump/pass> | |
/dev/sda3 none swap sw 0 0 | |
/dev/sda2 /boot ext3 defaults 1 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo -e "\e[00;31mPlease set your root password....\e[00m" | |
if [ -z $1 ] | |
then echo -e "\e[00;31mno passwd arg\e[00m" | |
exit 1 | |
fi | |
export ROOTPASS=$1 | |
echo -e "\e[00;31mDownloading stage3....\e[00m" | |
cd /root | |
wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz | |
echo -e "\e[00;31mPartitioning disk....\e[00m" | |
sgdisk -Z -n 1:2048:67583\ | |
-n 2:67584:591871\ | |
-n 3:591872:4786176\ | |
-N 4\ | |
-t 1:ef02\ | |
-t 2:8300\ | |
-t 3:8200\ | |
-t 4:bf01\ | |
-g /dev/sda | |
echo -e "\e[00;31mFormatting boot....\e[00m" | |
mkfs.ext3 /dev/sda2 | |
echo -e "\e[00;31mMaking swap....\e[00m" | |
mkswap /dev/sda3 | |
echo -e "\e[00;31mSwitching on swap....\e[00m" | |
swapon /dev/sda3 | |
echo -e "\e[00;31mCreating ZFS pool....\e[00m" | |
zpool create -f -o ashift=9 -o cachefile= -O compression=on -m none -R /mnt/funtoo rpool /dev/sda4 | |
echo -e "\e[00;31mSetting up ZFS volumes....\e[00m" | |
zfs create rpool/ROOT | |
zfs create -o mountpoint=/ rpool/ROOT/funtoo | |
zfs create -o mountpoint=/home rpool/HOME | |
zfs create rpool/FUNTOO | |
zfs create -o mountpoint=/usr/portage -o compression=off rpool/FUNTOO/portage | |
zfs create -o mountpoint=/usr/portage/distfiles rpool/FUNTOO/portage/distfiles | |
zfs create -o mountpoint=/usr/portage/packages rpool/FUNTOO/portage/packages | |
zfs create -o mountpoint=/usr/src rpool/FUNTOO/src | |
zpool set cachefile=/etc/zfs/zpool.cache rpool | |
mkdir -p /mnt/funtoo/etc/zfs | |
cp /etc/zfs/zpool.cache /mnt/funtoo/etc/zfs/zpool.cache | |
echo -e "\e[00;31mPreparing stage3....\e[00m" | |
cd /mnt/funtoo | |
cp /root/stage3-latest.tar.xz . | |
tar xJpf stage3-latest.tar.xz | |
rm stage3-latest.tar.xz | |
mount /dev/sda2 boot | |
mount -t proc none proc | |
mount --rbind /dev dev | |
mount --rbind /sys sys | |
cp /etc/resolv.conf /mnt/funtoo/etc/ | |
echo -e "\e[00;31mInstalling Funtoo....\e[00m" | |
env HOME=/root TERM=$TERM ROOTPASS=$ROOTPASS chroot /mnt/funtoo /bin/bash <<-CHROOT | |
cat /proc/mounts > /etc/mtab | |
echo noop > /sys/block/sda/queue/scheduler | |
echo -e "\e[00;32m(1) Syncing the portage tree....\e[00m" | |
emerge --sync | |
curl -L http://goo.gl/bn4HEk -o /etc/fstab | |
curl -L http://goo.gl/Sa8umk -o /etc/boot.conf | |
echo -e "\e[00;32m(2) Building linux kernel....\e[00m" | |
emerge -v vim the_silver_searcher gentoo-sources | |
cd /usr/src/linux | |
make defconfig | |
make localmodconfig | |
cat >> .config <<-KERN | |
CONFIG_CRYPTO_DEFLATE=y | |
CONFIG_ZLIB_DEFLATE=y | |
KERN | |
make bzImage modules | |
make install | |
make modules_install | |
echo -e "\e[00;32m(3) Setting up ZFS kernel modules....\e[00m" | |
emerge zfs genkernel | |
echo -e "\e[00;32m(4) Setting up GRUB....\e[00m" | |
hostid > /etc/hostid | |
echo "sys-boot/grub libzfs" >> /etc/portage/package.use | |
emerge grub | |
grub-install --no-floppy /dev/sda | |
cat /proc/mounts | grep -v rootfs > /etc/mtab | |
boot-update | |
echo -e "\e[00;32m(5) Generating initramfs....\e[00m" | |
genkernel --zfs --no-clean --no-mrproper --loglevel=5 initramfs > /var/log/genkernel-initramfs.log | |
echo -e "\e[00;32m(6) Finishing Funtoo installation....\e[00m" | |
rc-update add zfs boot | |
rc-update add dhcpcd default | |
rc-update add sshd default | |
chpasswd <<-CHPW | |
root:$ROOTPASS | |
CHPW | |
exit | |
CHROOT | |
unset ROOTPASS | |
echo -e "\e[00;31mSwitching off swap....\e[00m" | |
swapoff /dev/sda3 | |
echo -e "\e[00;31mCleaning up....\e[00m" | |
umount -l proc dev sys boot | |
cd / | |
zpool export rpool | |
echo -e "\e[00;31mdone! \e[00m" | |
reboot | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting. When was this last tested? For the kernel configuration, I did need the following too:
Not required any more? I think they are.