Code Monkey home page Code Monkey logo

zfs_on_root's Introduction

ZFS_ON_ROOT

for Ubuntu 23.04 and higher

This is a very basic script that I created to make it quicker for me to set up VMs or play around with ZFS-based installation of Ubuntu. The script will set up a system using ZFSBootMenu(ZBM) and rEFInd. EFI entries are created directly wich efibootmgr for ZBM and for rEFInd. Why? Purely to have a backup in case something goes wrong.

Why ZBM? Because I had enough of random issues with GRUB and ZFS. ZBM just works and integrates a number of ZFS dedicated functionalities that makes my life easier. Why rEFInd? Now, this is not technically needed, but it's simple to use, tweak, and maintain and works like a charm in dual/multi-boot environments.

The script is based on the documentation from OpenZFS, ZFSBootMenu, and with some ideas taken from ubuntu-server-zfsbootmenu. The script currently install Ubuntu on a single disk, with zpool encrypted with native ZFS encryption, and no ZSys installation (I don't use ZSys and it will be deprecated in any case). The layout of the partitions is a modified version of what used by ZFSBootMenu as I create the following:

  • Partition 1: EFI
  • Partition 2: Swap (size is automatically calculated by the script and it's set at the same size of the amount of memory you have)
  • Partition 3: zroot

The script uses the ZFS layout recommended by ZBM

Starting from version 1.0.16 the script has been production-tested on various brands of laptops and desktops machines with no reported issue. There's little to no documentation at this stage, although the script is pretty much self-explanatory.

Feel free to provide feedback, open issues, or send pull requests.

Important

You need to update the variables in zfs_on_root_zbm.sh to point to the correct disk and setup the initial variables to define the behaviour of the script.

If your machine uses RTL8821CE as a wifi chipset you are 99% guaranteed to face connectivity issues bad enough to impact the stability of your system, even during the installation. Set the relevant variable to "true" and the script will download, compile, and install the working drivers. If you are in this situation connect your machine to the network with a physical cable and avoid wifi during the installation.

Usage

gsettings set org.gnome.desktop.media-handling automount false
sudo -i 
cd
apt update && sudo apt install -y git vim
git clone https://github.com/dzacca/zfs_on_root.git
cd zfs_on_root
vi zfs_on_root_zbm.sh

Edit the variables at the beginning of the file and make sure to change RUN to true, or the script will exit without doing anything.

# Change ${RUN} to true to execute the script
RUN="false"

# Variables - Populate/tweak this before launching the script
export DISTRO="desktop"           #server, desktop
export RELEASE="mantic"           # The short name of the release as it appears in the repository (mantic, jammy, etc)
export DISK="sda"                 # Enter the disk name only (sda, sdb, nvme1, etc)
export PASSPHRASE="SomeRandomKey" # Encryption passphrase for "${POOLNAME}"
export PASSWORD="mypassword"      # temporary root password & password for ${USERNAME}
export HOSTNAME="myhost"          # hostname of the new machine
export USERNAME="myuser"          # user to create in the new machine
export MOUNTPOINT="/mnt"          # debootstrap target location
export LOCALE="en_US.UTF-8"       # New install language setting.
export TIMEZONE="Europe/Rome"     # New install timezone setting.
export RTL8821CE="false"          # Download and install RTL8821CE drivers as the default ones are faulty

## Auto-reboot at the end of installation? (true/false)
REBOOT="false"

########################################################################
#### Enable/disable debug. Only used during the development phase.
DEBUG="false"
########################################################################
########################################################################
########################################################################
POOLNAME="zroot" #"${POOLNAME}" is the default name used in the HOW TO from ZFSBootMenu. You can change it to
                 # whateven you want but I discourage it.

as root, execute the script ./zfs_on_root_zbm.sh

I adedd an option to download and install rl8821ce drivers as the ones shipped with ubuntu always gives me headhaches.

Important - EFI Default entry

If at the end of the installation, when you reboot, rEFInd doesn't show up, it's likely that your BIOS is pointing to another EFI entry. Enter the machine set-up menu at boot time and change the boot order to use rEFInd as the default one.

To Do

  • add options for more customisation

Contributors

zfs_on_root's People

Contributors

dzacca avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

adito5393

zfs_on_root's Issues

nvme and mmcblk installation fails

Cool script, congrats!
I suspect wrong grep clause in /etc/fstab generation for new system - ZBM_install() routine. If disk name ends with a digit, like 'nvme0n1', ''mmcblk1n1' or similar, 'p' is added to partition before the partition number - 'nvme0n1p1', etc.
I suggest replace grep "${DISK}${BOOT_PART}" with something like grep -E "^/dev/${DISK}(p)?${BOOT_PART}", or similar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.