Updated Ubuntu Installation script

I’ve made some major changes to my Ubuntu installation script over the last few weeks. Mostly because I finally replaced the hard drive in my laptop and needed to do a clean installation, but also because I wanted to try and get DisplayLink drivers installed by default, which has historically been a pain.

for the latter I’m now using a lot of someone else’s work, and a little bit of my own:

install_displaylink() {
    git clone https://github.com/AdnanHodzic/displaylink-debian.git
    cd displaylink-debian
    sudo ./displaylink-debian.sh
    wget -q https://raw.githubusercontent.com/teknostatik/debian/master/20-displaylink.conf -O /etc/X11/xorg.conf.d/20-displaylink.conf
    cd ..
}

One day there will be a more elegant solution, but for now this will do.

Since writing the original draft of this post I decided that having these drivers on all my computers really isn’t required, and I would generally just plug a HDMI cable in and use the dock for just the standard I/O. But it’s still there in a script as an optional setting, in case anyone else might find it useful. I’ve also added a few more optional settings, for QMK installation and enabling the firewall by default. I tested all this on a clean install of both 24.04 and 24.10 and it all seems to work fine.

Ubuntu 23.10

I upgraded to Ubuntu 23.10 on my laptop last night. It took less than 20 minutes, and so far everything has just worked.

This is the kind of user experience I want on all my devices, and also the kind of experience I strive to deliver to others.

Making DVDs from video files

Recently I found myself needing to make a DVD from a recorded stream (of a family funeral that my Mum couldn’t attend because of covid). This is not a task I normally do, and I thought it was worth writing up how I did it in case I ever need to do it again.

Most of these instructions were put together using this wiki page, and assume you are using Ubuntu or some other Debian derivative.

Dependencies

  • ffmpeg
  • dvdauthor
  • mkisofs
  • k3b

The command line stuff

ffmpeg -i video_file_name.mkv -aspect 16:9 -target pal-dvd  -b 1800000 dvd.mpg
dvdauthor -o dvd/ -t dvd.mpg
export VIDEO_FORMAT=PAL
dvdauthor -o dvd/ -T
mkisofs -dvd-video -o dvd.iso dvd/

The GUI stuff

Take dvd.iso and burn it to DVD using K3B (or your burning software of choice – I really should investigate doing this on the command line next time).

Testing

Put the DVD into a normal DVD player and check it plays. The video should load automatically with no menus.

This worked for me. Hopefully if I have to do it again it will be in better circumstances.

Investigating Launchers

Last night I was experimenting with ulauncher as a way of easily launching apps on my computer. After using it for a few hours it seems like something that I might want to start using all the time, but it also made me start looking at other launchers like Albert which seems a little harder to install but which promises to search across my applications, my local files, and the internet.

I think that as I try and use a keyboard for most things this is the sort of application I need. At the moment I’m using dmenu which does the job well enough but which is also quite basic and relies me to choose between knowing the package name or the name that would be displayed if I was using it in a more traditional menu (so files or naultilus but not both). The launchers I’m looking at now do both of these and more, but both of them require a little hoop-jumping to get them installed so may not be suitable for my default installation image (although there is at least a PPA for ulauncher so I may very well have a go at getting that added this afternoon)

It’s something I’ll come back to, but in the meantime it’s always fun trying out new software that may one day become part of my workflow.

More changes to my i3 config file

I had my new computer delivered this week. It was good to install it from my own scripts, copy across my dotfiles, and just carry on working.

Going through this process I did note that my i3 configuration file looks a lot different than when I last blogged about it, so I thought I’d make a note of the things I’ve changed from the defaults.

First up is screen locking. My muscle memory expects to use the same keyboard shortcut as Windows, so I’ve just configured that in:

set $i3lockwall i3lock -i /home/andy/Dropbox/lock.png -t
bindsym mod4+l exec --no-startup-id $i3lockwall

I’ve also set up something to randomise my wallpaper each time I log in (with a different one on each screen if I’m using multiple monitors):

exec --no-startup-id feh --randomize --bg-scale /home/andy/Dropbox/Wallpaper/current/*

I just keep a small folder of images in Dropbox that acts as a repository to pick from, and then add/remove occasionally to keep things fresh.

And then I’ve picked applications that don’t make sense in tiled mode and make the windows float (so they appear on top of everything else and can be moved around):

for_window [class="Gimp"] floating enable
for_window [class="vlc"] floating enable
for_window [class="zoom"] floating enable
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [class="Arandr"] floating enable
for_window [class="XTerm"] floating enable

I think that’s about it for now. I’ve also made fairly significant changes to my installation and update scripts, but that’s a topic for another day.

Building a private cloud with LXD

I’ve been doing some experiments with LXD on Ubuntu and I thought it was worth publishing some of the notes I made myself so that when I come back to this at a later date I can remember what I did.

LXD is described as:

LXD (pronounced lex-dee) is the lightervisor, or lightweight container hypervisor. LXC (lex-see) is a program which creates and administers “containers” on a local system. It also provides an API to allow higher level managers, such as LXD, to administer containers. In a sense, one could compare LXC to QEMU, while comparing LXD to libvirt.

(from https://ubuntu.com/server/docs/containers-lxd)

To install:

sudo snap install lxd
sudo lxd init

Then answer some questions about where you want to store things and what file system to use.

Finding images

For Ubuntu, the syntax is:

lxc image list ubuntu:focal

(replace focal with the name of the version you are interested in)

For non-Ubuntu images, you’ll need to search https://uk.images.linuxcontainers.org/. This shortens to images So for an Oracle Linux 8 image we would type:

lxc image list images:oracle/8

Creating containers

To do this we need to tell LXC which image to build the container from and what to call it. For an Oracle Linux 8 container with the name oracle-01 we would type:

lxc launch images:oracle/8 oracle-01

Once it’s built (it shouldn’t take long) we can connect to it by using the following command:

lxc exec oracle-01 -- bash

The containers are very minimal, and I found myself having to install aditional software before I could set them up to work in the way I like (nano and wget were both missing for example).

Stopping and starting containers

I’m very used to working with Multipass, so the commands for LXD are very similar.

Start a container:

lxc start <container_name>

Stop a container:

lxd stop <container_name>

Delete a container:

lxd delete <container_name>

Viewing your current containers

The command to issue is:

lxc list

You will get to see which containers are running (with their IP address) and which containers you have that have been built but are not running.

That’s about as far as I’ve got with building the latest part of my private cloud. I’ve also been working on using Oracle’s cloud as a location for my backups, but I’ll write about that another day.

Deploying Multipass Containers

I’ve been running a lot of experiments using Multipass, which is a (fairly) new application for deploying and working with containers on various operating systems (including all the ones I use). I’ve now set up a script to deploy these containers on any Ubuntu machine I install, and thought it might be worth sharing the script that I use.

#!/bin/bash

# Script to set up multipass and then deploy a load of containers for various things
echo "---------------------------------------------"
echo "Multipass Deployment Script - v0.1, June 2020"
echo "---------------------------------------------"

# Changelog:
# 28/6/20 - Created script to deploy 5 containers (POC)

# First off, install multipass:

sudo snap install multipass --classic

# What we're going to do next is:
# 1. Deploy a container for the current LTS version of Ubuntu
# 2. Run my usual post-deployment and update scripts inside that container
# 3. Shut the container down

multipass launch focal --name ubuntu-lts
multipass exec ubuntu-lts -- wget https://www.dropbox.com/s/p5jjsbvuuskeotl/deploy_ubuntu_wsl.sh
multipass exec ubuntu-lts -- sudo mv deploy_ubuntu_wsl.sh /usr/local/bin/
multipass exec ubuntu-lts -- sudo chmod 755 /usr/local/bin/deploy_ubuntu_wsl.sh
multipass exec ubuntu-lts -- deploy_ubuntu_wsl.sh
multipass stop ubuntu-lts

# We will then do the same for the LTS before

multipass launch bionic --name ubuntu-lts-old
multipass exec ubuntu-lts-old -- wget https://www.dropbox.com/s/p5jjsbvuuskeotl/deploy_ubuntu_wsl.sh
multipass exec ubuntu-lts-old -- sudo mv deploy_ubuntu_wsl.sh /usr/local/bin/
multipass exec ubuntu-lts-old -- sudo chmod 755 /usr/local/bin/deploy_ubuntu_wsl.sh
multipass exec ubuntu-lts-old -- deploy_ubuntu_wsl.sh
multipass stop ubuntu-lts-old

# Then we will follow the same process for the latest build of the next version of Ubuntu

multipass launch daily:20.10 --name ubuntu-devel
# TODO: investigate why the devel alias doesn't work for this
multipass exec ubuntu-devel -- wget https://www.dropbox.com/s/p5jjsbvuuskeotl/deploy_ubuntu_wsl.sh
multipass exec ubuntu-devel -- sudo mv deploy_ubuntu_wsl.sh /usr/local/bin/
multipass exec ubuntu-devel -- sudo chmod 755 /usr/local/bin/deploy_ubuntu_wsl.sh
multipass exec ubuntu-devel -- deploy_ubuntu_wsl.sh
multipass stop ubuntu-devel

# Do the same for any other versions of Ubuntu you want but this is probably enough for a POC

# Next up let's try a snapcraft development and test environment. This bit needs work once I know more about it

multipass launch snapcraft:core18  --name snapcraft-build
multipass stop snapcraft-build
multipass launch core18 --name snapcraft-test
multipass stop snapcraft-test

# Finally let's see what we now have:

multipass list

Using the i3 window manager

i3 is a window manager for Linux that I’ve been using for the last few weeks. It’s a fairly steep learning curve, but definitely brings some productivity gains. i3 is a tiling window manager, and by default will fill up the whole screen with applications. So if you have one application open it’s full screen, if you have two open then they each take up 50% of the screen, etc.

Installing i3

A excerpt from my installation script:

# Install the i3 window manager and some basic utilities

sudo apt install -y i3 feh arandr byobu htop

# Download some wallpaper and set it as default when using i3

wget https://www.dropbox.com/s/n5o7jjg4qpuebjn/2017-12-27-13.38.44.jpg
mv 2017-12-27-13.38.44.jpg  default_wallpaper.jpg
echo "feh --bg-scale default_wallpaper.jpg" >> .profile

## Add some aliases

echo alias ls="ls -l" >> .bashrc
echo alias top="htop" >> .bashrc

Using i3

When you log in for the first time you’ll be asked to choose a modifier key (I chose ALT). The keyboard shortcuts below use $mod to refer to that modifier.

  • Open a terminal window – $mod + Enter
  • Open a different application – $mod + d then type the application name (eg firefox)
  • Open (or go to) a second desktop – $mod + 2
  • Send the focused application to that desktop – $mod + Shift + 2
  • Split a container vertically – $mod + v
  • Split a container horizontally – $mod + h
  • Move between containers – $mod + arrow keys
  • Switch to a tabbed layout – $mod + w
  • Switch to a stacked layout – $mod + s
  • Close a window – $mod + Shift + q
  • Exit i3 – $mod + Shift + e

For multiple monitors it’s possible to enable/define them using xrandr. The sysntax is something like:

`xrandr --output HDMI-2 --auto --right-of HDMI-1`

As I have three monitors I find arandr to be a better way to set them up though. It’s a graphical wrapper to xrandr and lets me see the layout of my monitors which I find much more useful.

More information about i3 can be found at https://i3wm.org/docs/userguide.html.

Ubuntu Update Scripts 2020

I’ve maintained my own scripts for updating software on a few Linux distributions for a while. This weekend I decided it was time to consolodate all my installation and update scripts in one place, and amend them to reflect the new ways I work with Linux (both in using i3 as a window manager and relying more on WSL and Multipass).

What follows is largely for my benefit, but I thought it may be of interest to others.

Ubuntu

  wget https://www.dropbox.com/s/hwfvynamcy6bkcs/deploy_ubuntu.sh
  sudo mv deploy_ubuntu.sh /usr/local/bin/
  sudo chmod 755 /usr/local/bin/deploy_ubuntu.sh
  deploy_ubuntu.sh

Windows Subsystem for Linux (WSL)

wget https://www.dropbox.com/s/p5jjsbvuuskeotl/deploy_ubuntu_wsl.sh
sudo mv deploy_ubuntu_wsl.sh /usr/local/bin/
sudo chmod 755 /usr/local/bin/deploy_ubuntu_wsl.sh
deploy_ubuntu_wsl.sh

This one also works with Multipass (which will probably be the subject of a blog post soon).

Installing Ubuntu on a Chromebook

I’ve been experimenting with Chromebooks for a few weeks now to try and come up with a low-power low-cost no-maintenance setup. There are a lot of very good blog posts covering the basics already, but I thought it was at least worth documenting how I got Ubuntu installed on my older Chromebook (which is a bit of a frankenstein that goes against the general ethos of not upgrading or otherwise tinkering with the hardware). This is probably best not attempted on anything with less than 32Gb of storage, and 4Gb of RAM is probably a good idea as well.

Enable developer mode

To enable developer mode, press escape and refresh and hold down the power key. When the scary message appears then press Ctrl+d and wait for the (fairly long) process to complete. This will unlock the full bash shell, and give you enough control over the Chromebook to set up a chroot.

Install Crouton

Crouton is the script that is used to install Ubuntu in a chroot. Download it from here and ensure it’s in your downloads folder. Then press Ctrl+Alt+t to open the chrosh terminal, and type shell at the command prompt. This will get you full shell access to the Chromebook.

To install Ubuntu (at time of writing 16.04) then issue the following command:

sudo sh ~/Downloads/crouton -e -t xfce

This will take a while, but when it’s done then issue the following command to start Ubuntu:

sudo startxfce4

To toggle between ChromeOS and Ubuntu use Ctrl+Alt+Shift+Back and Ctrl+Alt+Shift+Forward. Performance is actually not bad, and productivity is only an apt install firefox away.

Other useful commands

The following commands could be useful (all issued within the ChromeOS shell):

See a list of possible distributions to install:

sh ~/Downloads/crouton -r list

Back up a chroot:

sudo edit-chroot -b name

Restore it:

sudo edit-chroot -r name

Delete a chroot:

sudo delete-chroot name