There is a newer version of this guide for Ubuntu 20.04.
With Ubuntu 19.10 there is finally (experimental) ZFS setup option. And frankly, you should use it instead of the manual installation procedure. However, manual installation does offer it’s advantages - especially when it comes to pool layout and naming. If manual installation is needed, there is great Root on ZFS installation guide that’s part of ZFS-on-Linux project but its final ZFS layout is a bit too complicated for my taste. Here is my somewhat simplified version of the same intended for a singe disk installations.
After booting into Ubuntu desktop installation we want to get a root prompt. All further commands are going to need root credentials anyhow.
sudo-i
The very first step should be setting up a few variables - disk, pool, host name, and user name. This way we can use them going forward and avoid accidental mistakes. Just make sure to replace these values with ones appropriate for your system.
To start the fun we need debootstrap package. With 19.10 ZFS is available in main repository so we don’t need to add universe as in the previous Ubuntu versions.
aptinstall--yesdebootstrap
General idea of my disk setup is to maximize amount of space available for pool with the minimum of supporting partitions. If you are planning to have multiple kernels, increasing boot partition size might be a good idea. Major change as compared to my previous guide is partition numbering. While having partition layout different than partition order had its advantages, a lot of partition editing tools would simply “correct” the partition order to match layout and thus cause issues down the road.
Assuming UEFI boot, two additional partitions are needed. One for EFI and one for booting. Unlike what you get with the official guide, here I don’t have ZFS pool for boot partition but a plain old ext4. I find potential fixup works better that way and there is a better boot compatibility. If you are thinking about mirroring, making it bigger and ZFS might be a good idea. For a single disk, ext4 will do.
Since we’re dealing with encrypted data, we should auto mount it via crypttab. If there are multiple encrypted drives or partitions, keyscript really comes in handy to open them all with the same password. As it doesn’t have negative consequences, I just add it even for a single disk setup.
Now we get grub started and update our boot environment. Due to Ubuntu 19.10 having some kernel version kerfuffle, we need to manually create initramfs image. As before, boot cryptsetup discovery errors during mkinitramfs and update-initramfs as OK.
If your default id_rsa key is different than the one you use for GitHub, it’s still possible to use simple git push regardless. Trick is in adding mapping to identity file in ~/.ssh/config:
Host github.com
User git
IdentityFile ^^~/.ssh/id_rsa_github^^
IdentitiesOnly yes
This will ensure all communication with github.com uses id_rsa_github key.
Considering how verbose make output is, it’s really easy to miss warnings or errors. What we need is a bit of color. However, make being such an old program, doesn’t support any ANSI coloring. However, since both errors and warnings have standardized formats, it’s relativelly easy to use grep to color them.
This will color all lines following the Makefile:number: format in default color. Extending this for catching errors is similar as there is just an extra match of “.Stop”:
And yes, the order of greps is important as we first want to capture errors. Matched lines are to be colored red (01;31) and prefixed with ANSI escape sequence thus preventing the second grep matching. Lines matching the second grep will get similar treatment, just in yellow (01;33).
Instead of remembering this, we can create a new amake function that will do the coloring:
One of many details available in Windows but not in Ubuntu is automatic backlight change when system switches from AC to battery. And it’s not just a dumb change to predefined value either. Every switch from AC to battery and vice versa restores the last value system had. Ubuntu on the other hand just keeps the backlight as is resulting in me manually adjusting it every time. Lookup on Internet for applications providing this functionality gave me no warm fuzzy feeling so I decided to roll my own. I mean, how hard can it be.
Well, actually annoyingly hard if you want to support every interface out there. As I wanted to support only my Dell XPS 15, I had quite a bit easier work.
The main part of the story is in two files: /sys/class/power_supply/AC/online and /sys/class/backlight/intel_backlight/brightness. All what’s needed was actually a small script handling tracking and restoring brightness values every once in a while. This is roughly what I ended with:
#!/bin/bashSTORED_AC=`cat /var/cache/.backlight.ac`STORED_BAT=`cat /var/cache/.backlight.bat`
while(true);doBRIGHTNESS=`cat /sys/class/backlight/intel_backlight/brightness`IS_AC=`cat /sys/class/power_supply/AC/online`if[["$IS_AC"!="$LAST_AC"]];thenif[["$IS_AC"!="0"]];thenif[["$STORED_AC"!=""]];thenecho-e"Restoring AC backlight to $STORED_AC"echo$STORED_AC>$FILE_BRIGHTNESSfielseif[["$STORED_BAT"!=""]];thenecho-e"Restoring battery backlight to $STORED_BAT"echo$STORED_BAT>$FILE_BRIGHTNESSfifiLAST_AC=$IS_ACelseif[["$IS_AC"!="0"]];thenif[["$STORED_AC"!="$BRIGHTNESS"]];thenecho$BRIGHTNESS> /var/cache/.backlight.ac
STORED_AC=$BRIGHTNESSfielseif[["$STORED_BAT"!="$BRIGHTNESS"]];thenecho$BRIGHTNESS> /var/cache/.backlight.bat
STORED_BAT=$BRIGHTNESSfififisleep0.5done
As you can see, the script is just checking in loop if there was an AC status change. If computer was plugged or unplugged, it simply restores the last saved value for that power state. If power status remained the same, it will track any brightness change so it’s possible to restore it later. Really simple and really working.
And yes, the script above contains no error handling. If you want to see the real stuff, it’s available on GitHub. Even better, it’s available as a Debian package if you want to install it.
Moving from Windows to Ubuntu, there is one shortcut I surely miss - Ctrl+Shift+Escape. On Ubuntu this does absolutely nothing.
Fortunately one can always add a custom shortcut to System Monitor:
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings \"['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"GSCHEMA=org.gnome.settings-daemon.plugins.media-keys.custom-keybinding
GPATH=/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/
gsettings set$GSCHEMA:$GPATH name "System Monitor"
gsettings set$GSCHEMA:$GPATHcommand"gnome-system-monitor"
gsettings set$GSCHEMA:$GPATH binding "<Primary><Shift>Escape"
However, this is not quite “it”. The major issue is that, if System Monitor is already open, it will remain in background. As this is Linux, of course there is a command line solution for this.
First we need to install wmctrl package
sudoaptinstall wmctrl
Then we can setup a script to run System Monitor and activate it’s window. Since application itself is single instance, this does exactly what we need: