JA

Farewell, Gates OS!! Installing Ubuntu on a dynabook!?

Here is what this post covers:

Introduction

Lately, carrying my MacBook Air around for work study and side projects has started to feel like a chore. It weighs about 1.23 kg, which doesn’t sound like much, but it wears me out after a day in my backpack.

So I looked for a lighter machine and decided to use an 845 g dynabook instead. dynabook is a Japanese laptop brand that used to belong to Toshiba.

The catch is that developing on Windows means going into Ubuntu inside WSL (Windows Subsystem for Linux) every single time. That got old fast, so I decided to wipe Windows and put Ubuntu on the whole machine.

This post covers the steps I took and, with diagrams, what was going on underneath.

Why I dropped WSL for native Ubuntu

Ubuntu on WSL2 is a lightweight virtual machine (VM) running next to Windows. Every time you use Linux, you cross the boundary between the two.

With WSL2, Windows and a lightweight VM sit side by side on the hypervisor, and Ubuntu runs inside the VM. Natively, Ubuntu's Linux kernel uses the hardware directly. Windows + WSL2 Windows Ubuntu inside a light VM Hyper-V (hypervisor) Hardware Native Ubuntu Ubuntu GNOME, dev tools Linux kernel Hardware
ItemWSL2Native
MemoryShared with Windows (the VM gets up to half by default)All of it
Windows filesSlow to access through /mnt/cNo boundary
Getting startedEnter WSL every timeIt’s Linux from boot

If I have to cross that boundary every time anyway, running Linux directly on the hardware is simpler.

The players and the overall flow

NameRole
ISOA single file containing Ubuntu and its installer
RufusA free Windows tool that turns the ISO into a bootable USB stick
USB stickHolds the installer and is what the PC boots from
UEFIThe firmware that runs first when you power on
InstallerThe program that wipes the SSD and writes Ubuntu to it
SSDWhere Ubuntu ends up. The PC boots from it afterwards

UEFI stands for Unified Extensible Firmware Interface. It replaced the older BIOS (Basic Input/Output System), which is why people still call the firmware settings screen “the BIOS”.

Along the way, the OS doing the work changes from Windows to Ubuntu on the USB stick and then to Ubuntu on the SSD.

Five stages: get the ISO, write it to USB with Rufus, UEFI boots from USB, the installer writes Ubuntu to the SSD, and from then on the PC boots from the SSD. The OS doing the work changes from Windows to UEFI to Ubuntu on USB to Ubuntu on the SSD. Running on What happens Windows 1. Get the ISO Download from ubuntu.com Windows 2. Write to USB Using Rufus UEFI 3. Boot from USB UEFI starts the installer Ubuntu on USB 4. Install Wipe the SSD, write Ubuntu Ubuntu on SSD 5. Set up Boots from the SSD now

Steps

1. What you need

ItemWhere to get it
USB stick12 GB or more. Everything on it will be erased
Ubuntu ISOThe Desktop LTS image from ubuntu.com
Rufusrufus-4.xx.exe from rufus.ie. No install needed

2. Make the USB stick with Rufus

  1. Plug in the USB stick, start Rufus and check that it shows up under “Device”
  2. Pick the ISO with “SELECT”
  3. Set “Partition scheme” to GPT and “Target system” to UEFI (non CSM)
  4. Press “START”. If it says “ISOHybrid image detected”, keep the recommended “ISO Image mode”

GPT stands for GUID Partition Table, the format of the table that records how a disk is divided up. CSM (Compatibility Support Module) lets a PC boot the old BIOS way; with it disabled, the USB stick boots through UEFI only.

3. Boot from the USB stick

  1. Hold Shift and click Shut down
  2. Right after powering on, tap F2 to enter the BIOS (Setup Utility). On some models F12 opens a boot menu instead
  3. Put the USB stick first in the boot order and restart
  4. If it won’t boot, try setting Secure Boot to Disabled for now

Holding Shift avoids Windows Fast Startup. A normal shutdown saves the state of Windows to a file and the next boot resumes from it, so F2 sometimes doesn’t work.

A normal shutdown saves state to hiberfil.sys and the next boot resumes from it, so F2 may not work. Shutting down while holding Shift turns the PC fully off, so the next boot starts from power-on and F2 opens the settings. Normal shutdown Shift + Shut down Shut down Save state to file hiberfil.sys Resume saved state F2 may not work Shut down Fully off Boot from power-on F2 opens settings

4. Install

  1. Choose “Try or Install Ubuntu”
  2. Pick the language and keyboard layout directly (I picked Japanese for both)
  3. Connect to Wi-Fi
  4. Choose “Erase disk and install Ubuntu” (Windows is gone for good)
  5. Set the user name, password and time zone, then install
  6. When it’s done, remove the USB stick and restart

5. Initial setup

sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl build-essential

For Japanese input, I added “Japanese (Mozc)” under Settings > Keyboard.

A closer look at what happens underneath

Here I go through the parts of the steps that caught my interest. First, a quick look at the file system terms that come up. A file system is the set of rules for how files are laid out and recorded on a disk.

TermIn short
FAT32An old, simple file system also used by Windows. UEFI can read it
EFI System Partition (ESP)A dedicated FAT32 partition UEFI reads at boot. Boot loaders live here
squashfsA compressed, read-only file system. The OS inside the ISO uses it
tmpfsA file system kept in memory. It’s gone after a reboot
overlayfsStacks two directories so they look like one

Why you boot from USB

A running OS can’t wipe the SSD it is running from. Windows keeps using files on the SSD the whole time it’s up.

Working from inside Windows, the SSD Windows is using cannot be wiped. After booting from USB, the installer runs from USB and memory alone and can wipe the unused SSD and write Ubuntu. Working inside Windows Windows running SSD in use × An SSD in use can't be wiped Working after booting from USB USB stick Holds the installer boot Installer Runs from USB and memory only wipe and install SSD Nothing is using it, so it can be wiped

So you boot from a USB stick, which doesn’t use the SSD, and let the installer, running from USB and memory alone, wipe the SSD and write to it. The USB stick only holds the installer, so once the install is done you no longer need it.

Copying versus writing

If you just copy the ISO onto a USB stick, it won’t boot. UEFI looks for \EFI\BOOT\BOOTX64.EFI at a fixed place on a FAT32 partition, and it doesn’t look inside an .iso file.

Copying the ISO puts one file on the USB stick and it does not boot. Rufus ISO Image mode extracts the contents and puts the boot file in the expected place; DD Image mode copies the ISO as is. Both boot. Plain copy One .iso file, nothing else UEFI can't see inside it No boot Rufus (ISO Image mode) Contents extracted \EFI\BOOT\BOOTX64.EFI exists Boots Rufus (DD Image mode) ISO copied byte for byte The ISO has a boot area Boots

Rufus’s ISO Image mode extracts the contents of the ISO and puts that file where UEFI expects it. DD Image mode just copies the ISO as is, but the Ubuntu ISO is a “hybrid ISO”: read as a disk, it already contains a partition table and a boot area. That’s why either mode boots.

UEFI and GPT

Older PCs boot with BIOS plus MBR (Master Boot Record); current PCs boot with UEFI plus GPT.

BIOS runs a 446-byte program in the MBR, the first 512 bytes of the disk, which then loads the boot loader. UEFI finds the FAT32 ESP through GPT and runs an .efi file inside it by name. BIOS + MBR (old) UEFI + GPT (current) BIOS MBR First 512 bytes of disk Boot program Only 446 bytes Boot loader UEFI Find ESP via GPT A FAT32 partition Run an .efi file Chosen by file name Boot loader

BIOS can’t read files. It runs the boot program stored in the first 512 bytes of the disk (the MBR), and that program loads the boot loader. UEFI, on the other hand, can read FAT32, so it can run an .efi file inside the EFI System Partition (ESP) by its file name.

ItemMBRGPT
Disk sizeUp to 2 TiBEffectively unlimited
Number of partitionsUp to 4 primary128 by default
If the table breaksNo backupA backup at the end of the disk

How the live session works

In short, the live session is Ubuntu running from the USB stick and memory alone, without being installed on the SSD. The installer is just one of the apps running in it.

When you boot from the USB stick, the GRUB menu shows these four options. The last two only appear when you boot through UEFI.

OptionWhat it does
Try or Install UbuntuStarts the live session
Ubuntu (safe graphics)Boots with nomodeset. For when the screen stays blank
Boot from next volumeSkips the USB stick and moves on to the next boot device
UEFI Firmware SettingsOpens the UEFI settings screen

nomodeset tells the kernel not to let graphics drivers switch display modes (KMS). It helps when a GPU driver leaves the screen black.

Choosing “Try or Install Ubuntu” starts the live session without writing anything to the SSD.

In the live session, tmpfs in memory is layered with overlayfs on top of the read-only squashfs on the USB stick, so they look like one root file system. Writes go to tmpfs and vanish on reboot; the SSD is never touched. / (files seen in the live session) stacked with overlayfs Upper: tmpfs (memory) Writes land here and vanish on reboot Lower: squashfs (USB) Compressed OS, read-only SSD Not touched until you install

The OS on the USB stick is squashfs, a compressed, read-only file system. tmpfs in memory is stacked on top of it with overlayfs, so every write goes to memory. That’s why your changes disappear when you reboot, and why the SSD is never touched.

What’s on the SSD after installing

The installer deletes all the Windows partitions and creates two: the ESP and an ext4 root.

Before installing, the SSD holds the ESP, MSR, Windows and a recovery partition. Afterwards it holds only the ESP and an ext4 root, and the ubuntu boot entry in the motherboard's NVRAM points to shimx64.efi in the ESP. Before (standard Windows layout) ESP FAT32 MSR C: (Windows) NTFS Recovery NTFS After (Ubuntu) ESP FAT32, /boot/efi / (root) ext4, Ubuntu and home boots \EFI\ubuntu\shimx64.efi UEFI NVRAM Boot entry "ubuntu" On the motherboard, not the SSD

Which file to boot is recorded in the NVRAM on the motherboard, not on the SSD. The installer registers a boot entry called “ubuntu” that points to \EFI\ubuntu\shimx64.efi, so Ubuntu starts even after you remove the USB stick. You can check all this with these commands.

lsblk -f              # partitions and file systems
sudo efibootmgr -v    # boot entries and boot order in NVRAM
mokutil --sb-state    # whether Secure Boot is on

From power-on to the login screen

An OS is made of three parts: the boot loader, the kernel and the root file system. When you power on, they start in this order.

From power-on to the login screen. UEFI checks Microsoft's signature and starts shim, shim checks Canonical's signature and starts GRUB, and GRUB checks the kernel's signature and loads it. The kernel mounts the root file system and starts systemd, and GDM shows the login screen. They live on the motherboard, the ESP, /boot and the root. Boot order Lives in UEFI Holds Microsoft's cert checks Microsoft's signature shimx64.efi Holds Canonical's cert checks Canonical's signature grubx64.efi (GRUB) Shows the boot menu checks the kernel's signature vmlinuz + initrd.img initrd is only for early boot mounts the root systemd (PID 1) The first process GDM → GNOME Login screen and desktop Motherboard ESP /boot / (root)

Secure Boot is a UEFI feature that only starts programs whose signatures it can verify. Most PCs’ UEFI trusts Microsoft’s certificates, so Ubuntu starts from “shim”, a boot loader signed by Microsoft. shim carries Canonical’s (Ubuntu’s publisher) certificate and uses it to check GRUB’s signature and then the kernel’s.

That’s why Ubuntu usually boots with Secure Boot left on. If you turned it off during the steps, you can turn it back on after installing. Kernel modules you build on your own PC with DKMS, such as VirtualBox’s drivers, are the exception: you have to enroll your own key, a MOK (Machine Owner Key), and sign them with it.

What this teaches a software engineer

You can find the steps with a quick search, but following the mechanics teaches ways of thinking that carry over to everyday development.

First, you learn to narrow down a failure layer by layer. Whether it’s a PC that won’t boot or a web page that won’t load, checking one level at a time (firmware, boot loader, kernel, app) shows you where it stops.

Second, you get the habit of preparing the replacement somewhere else and then switching over. Just as a running OS can’t wipe its own SSD, it’s safer to bring up a new production environment next to the old one and then switch. That’s the idea behind blue-green deployment.

Third, containers start to make sense. Docker images and containers are stacked with overlayfs the same way as the live session. The image layers are the read-only lower layers, and changes made in the container go only into the upper layer. Deleting a container loses your changes for the same reason that rebooting the live session does.

Fourth, you become aware of where trust starts. Secure Boot’s signature checks follow the same idea as the HTTPS certificate chain and apt’s package signature checks. Once you know what is trusted first, you have a good idea of what to suspect when a certificate warning shows up.

Fifth, you get in the habit of checking where state is stored. The boot order turned out to live in the motherboard’s NVRAM rather than on the SSD, and settings often live somewhere you wouldn’t expect.

Distros other than Ubuntu

DistroNotes
Ubuntu LTSThe most information out there. Pick this if unsure
FedoraNewer packages. Leads into the RHEL family
DebianWhat Ubuntu is based on. Focused on stability
Pop!_OSStrong support for NVIDIA GPUs
Linux MintBeginner-friendly and stable

For cloud-centered development you don’t need GPU support, so Ubuntu LTS is the safe choice.

Wrapping up

Rufus (the tool) writes the ISO (the materials) to the USB stick (the workbench), and the installer that UEFI starts (the worker) puts Ubuntu on the SSD. Thinking of it that way makes the whole process easier to follow.

And with that, Ubuntu was up and running on my 845 g dynabook.

The Ubuntu desktop running on the dynabook

Amazing! So cool!

A manga panel of a character shouting "Amazing! So cool!!"

References