Skip to content

Instantly share code, notes, and snippets.

@SamSirry
Last active March 15, 2021 00:17
Show Gist options
  • Select an option

  • Save SamSirry/3e339deeb3c4f3fd05c2c6486e05aaab to your computer and use it in GitHub Desktop.

Select an option

Save SamSirry/3e339deeb3c4f3fd05c2c6486e05aaab to your computer and use it in GitHub Desktop.

Revisions

  1. SamSirry renamed this gist Mar 15, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. SamSirry created this gist Mar 15, 2021.
    37 changes: 37 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    Moving the OS to the zfsroot.
    Source:
    https://www.reddit.com/r/zfs/comments/9zr5gr/which_linux_disro_is_the_most_stable_and/eadpmgm/?context=3
    https://web.archive.org/web/20210226222225if_/https://www.reddit.com/r/zfs/comments/9zr5gr/which_linux_disro_is_the_most_stable_and/

    Original code follows later. simplified code is here. USE THE ORIGINAL CODE after adaptation.

    add-apt-repository universe
    apt update
    apt install zfs-initramfs
    zpool create -o ashift=12 -o mountpoint=none ...
    zpool export os
    zpool import -R /z os -d /dev/disk/by-id
    zfs create -o mountpoint=/ os/linux
    rsync -aHSXAx /target/ /z/
    for d in dev dev/pts proc sys run ; do mount -o bind /{,z/}$d ; done
    echo "Make sure zfs module doesn't eat half your RAM, adjust as you want but don't make them equal";
    echo "options zfs zfs_arc_min=$((128*1024*1024))" >> /z/etc/modprobe.d/zfs.conf
    echo "options zfs zfs_arc_max=$((256*1024*1024))" >> /z/etc/modprobe.d/zfs.conf
    chroot /z/ add-apt-repository universe
    chroot /z/ apt update
    chroot /z/ apt install zfs-initramfs
    chroot /z/ update-initramfs -c -k all
    chroot /z/ update-grub
    chroot /z/ grub-install /dev/sda
    for d in dev/pts dev proc sys run ; do umount /z/$d ; done

    -----------------------------------------------------------------------
    Original code:

    add-apt-repository universe && apt update && apt install zfs-initramfs
    zpool create -o ashift=12 -O mountpoint=none ... && zpool export os && zpool import -R /z os -d /dev/disk/by-id && zfs create -o mountpoint=/ os/linux
    rsync -aHSXAx /target/ /z/ && for d in dev dev/pts proc sys run ; do mount -o bind /{,z/}$d ; done
    echo "Make sure zfs module doesn't eat half your RAM, adjust as you want but don't make them equal"; echo "options zfs zfs_arc_min=$((128*1024*1024))" >> /z/etc/modprobe.d/zfs.conf ; echo "options zfs zfs_arc_max=$((256*1024*1024))" >> /z/etc/modprobe.d/zfs.conf
    chroot /z/ add-apt-repository universe && chroot /z/ apt update && chroot /z/ apt install zfs-initramfs
    chroot /z/ update-initramfs -c -k all && chroot /z/ update-grub && chroot /z/ grub-install /dev/sda
    for d in dev/pts dev proc sys run ; do umount /z/$d ; done