Git Product home page Git Product logo

zbectl's Introduction

zbectl

Functionality

zbectl is a utility for managing ZFS Boot Environments in Arch Linux similar to beadm on FreeBSD.

GRUB is used to boot the different environments.

Architecture

  • GRUB is used as the bootloader.
  • zbectl does not use the bootfs property. Instead it tells grub which entry to boot.
  • Boot Environments are located under poolname/ROOT/. For example: if your pool is named zroot then the environment called default is located under zroot/ROOT/default

ESP mountpoints

  • Each pool device has an ESP
  • ESPs are automatically mounted under /boot/efi/<partuuid>

Installation

Partition layout

Automatic

Since version 2.0 zbectl can automatically partition your devices. This works for EFI and BIOS systems. Make sure to boot your archiso in the same mode you want your installed system to boot! Simply run:

zbectl partition <your device>...

For example if you want to use the two disks sda and sdb run:

zbectl partition sda sdb

This will create the following layout on your devices.

BIOS

Part     Size   Type
----     ----   -------------------------
   1       2M   BIOS boot partition (ef02)
   2     XXXG   Solaris Root (bf00)

UEFI

Part     Size   Type
----     ----   -------------------------
   1     256M   EFI boot partition (ef00)
   2     XXXG   Solaris Root (bf00)

This will also create the requirred fat filesystem on your ESPs.

Manual

If want to manually partition your devices please keep in mind that zbectl expects your ESP/BIOS partitions to be on the same parent device as you pool. The following steps assume you have already created a fat filesystem on each of your ESPs if using EFI.

Installing your system

  • Create your pool according to your desired layout over the partuuids returned to you by the zbectl partition command above. If you manually partitioned your devices you should know the right ids to use.

Please create your pool according to the guidelines on the wiki to avoid grub not beeing able to boot from your pool.

Set the pool/dataset properties like ashift and compression according to your preference/use case.

  • The only absolutely necessary datasets are the following:
zfs create <your_pool>/ROOT
zfs create -o mountpoint=/ <your_pool>/ROOT/<environment_name>

For example if your pool is named zroot and your environment default run:

zfs create zroot/ROOT
zfs create -o mountpoint=/ zroot/ROOT/default
  • To avoid the pacman cache cluttering up your environments I recomend creating the following dataset:
zfs create -o mountpoint=/var/cache/pacman/pkg zroot/pkgcache
zbectl install

Usage

zbectl list

Lists all ZFS Boot Environments.

zbectl create [source] target

Creates a new ZFS Boot Environment named target. This clones the source environment. If no source environment is provided, the booted environment will be used.

zbectl rename source target

Renames the source environment to target.

zbectl destroy target...

Delets the target environment(s). Multiple targets can be specified.

zbectl activate

Lists available environments.

zbectl activate target

Sets the target as the default boot entry. Note that the entire name is not requirred, as long as the script can figure out which environment is ment.

zbectl update

Updates grub.cfg. Run this after a GRUB update.

zbectl mount target [mountpoint]

Mounts the target environment to /pool/ROOT/target or specified mountpoint.

zbectl unmount target

Unmounts the target environment.

zbectl chroot target [command]

Mounts the target environment to default mountpoint and chroots into it. Optionally specify command to run inside the chroot. The target gets unmounted after the command exits.

zbectl install [grub arguments]

Installs grub to all pool devices and and updates the grub.cfg. Additional arguments are passed to grub-install.

zbectl partition [device]...

This will automatically partition your devices for EFI/BIOS booting. Devices can be specified as absolute paths like /dev/sda or just the devicename like sda.

If your system is booted in EFI mode this will create a 256M ESP partition and a second partition for zfs on the specified devices.

In BIOS mode a BIOS boot partition for grub, and a second partition for zfs will be created.

Troubleshooting

GRUB

The GRUB package is unable to create boot entries for systems on ZFS. Zbectl uses an environment variable to resolve this. For more information read the note on the Arch Wiki: https://wiki.archlinux.org/index.php/Installing_Arch_Linux_on_ZFS#error:_failed_to_get_canonical_path_of

If you still receive an error you can try this older workaround:

The package includes a udev rule which creates symlinks. Run the following to activate it.

udevadm trigger

Exit Codes

The following exit codes are returned:

0 Successful execution.

1 An error occurred.

2 Invalid arguments or insufficient permissions.

3 A device related error occurred.

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.