mdlbear: (technonerdmonster)
[personal profile] mdlbear

Setting up a computer so that it can boot into one of several different Linux distributions is something of a challenge; I haven't done it in quite a long time, and of course hings have changed. You may remember the previous post in this series, in which I discuss the proposed partitioning scheme for Sable's new terrabyte SSD.

In the end, I decided to use the newer GPT partition table, which supports secure boot (which I'm not planning to use, but still...) and a boot manager called rEFInd that looked useful (and still might be -- we'll see). So I loaded up an 8GB USB stick with Ventoy and the ISO files for Linux Mint, LMDE (Linux Mint Debian Edition), and UbuntuStudio. There's a partition set aside for another one, TBD.

The three distros all have different desktops: MATE, Cinnamon, and Xfce respectively; part of this experiment is to determine whether I prefer one of these, with or without Xmonad. For comparison, the desktop environment I have on my other laptops is Xmonad with Gnome Flashback. I also want to find out whether UbuntuStudio's low-latency kernel and Jack connection manager work better there or on Mint. (Each of these desktop environments can be installed on any of the distributions -- they're all derived from Debian, and in addition Mint is derived from Ubuntu -- but I've found that some of them are mutually exclusive. The time time I tried installing MATE over Gnome I ran into a huge number of conflicts.)

The other large part of this experiment is to make Honu, my configuration management package, work in a multi-boot environment. That's next. For now I want to talk about the initial setup.

Sharing a development environment between multiple distributions is... interesting. First of all, you don't want to make a home partition and mount it in all three roots. (Been there, done that.) Each distro has its own different set of configuration files, which are kept in your home directory. You want to give each distro it own /home, and put your shared working set into a separate large partition (which I conventionally call /vv. The first step is setting up the partitions.

There are two main kinds of partition table in use for PCs -- the old Master Boot Record (MBR), which works with the equally ancient BIOS, and the newer GUID Partition Table (GPT), which works with the Extensible Firmware Environment (EFI). GPT is the way to go these days -- modern PCs don't even have a real BIOS -- the EFI fakes it with a compatibility mode. But to someone who's been using BIOS and MBR since the days when IBM shipped a complete listing of it in the (original) PC's user's manual, it' different. Here's the partition table, slightly edited to add labels and operating systems:

    steve@sable:~$ sudo fdisk -l
    Disk /dev/sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
    Disk model: Samsung SSD 860 
    Disklabel type: gpt
    Disk identifier: 485FEFF2-4524-734A-8B66-12F26BE8FDAF

    Device         Start        End    Sectors   Size Type (label) OS
    /dev/sda1       2048     526335     524288   256M EFI System
    /dev/sda2     526336     788479     262144   128M EFI System
    /dev/sda3     788480   67897343   67108864    32G Linux swap
    /dev/sda4   67897344  166201343   98304000  46.9G Linux (ww) Mint
    /dev/sda5  166201344  264505343   98304000  46.9G Linux (xx) LMDE
    /dev/sda6  264505344  362809343   98304000  46.9G Linux (yy) UStudio
    /dev/sda7  362809344  461113343   98304000  46.9G Linux (zz) (spare)
    /dev/sda8  461113344 1953523711 1492410368 711.7G Linux (vv) (shared)

I set that up with gparted before I installed Mint. I installed UbubtuStudio twice, because the first time my setup script pulled in a lot of Gnome stuff that broke Xfce.

There's a complication with installing Mint and Ubuntu on the same machine -- they both use the same name, ubuntu, to identify themselves to the EFI. As a result their boot information clobbers one another. That's what the second system partition is for. I haven't set that up yet (tried to when I reinstalled Ubuntu, but it wouldn't let me pick one), so I've been relying on the fact that all three OSs use GNU Grub, the GRand Unified Bootloader, and set it up to list all the operating systems on the disk in their menu. I'm not going to worry about it for a while, and if I install the rEFInd Boot Manager I may not bother.

The rEFInd page links to an enormous set of resources on EFI booting, so I'm not going to say much more about it. Where things get interesting (at least for the purposes of this post) is what I do to set up a distro after I've installed it.

One of the first problems you run into is creating a user ("steve", of course) for myself, and giving it (myself?) the correct user and group IDs. Back in the days when Grand Central Starport had lots of users, and their metadata was shared via NFS, steve acquired the user and group IDs 1010. There are a lot of backup disks and so on where I still have those IDs. One of them is Sable's old SSD -- the one I'm replacing. So while I'm installing the OS, I create an administrative user called "starport", belonging to "Starport Administrator".

Having an extra user around is incredibly useful, because there are things you can't (or shouldn't) do while logged in. One of those is changing the ownership of the logged-in user's home directory. I usually use the GUI to create the new user, and sometimes I can tell it what userID it's supposed to have. It isn't always possible to do that with the group. So the next part looks like:

    sudo groupmod -g 1010 steve
    sudo usermod -u 1010 -g 1010 steve
    sudo chgrp -R 1010 ~steve

... because the usermod command changes the userID of the user's home directory and everything in it, but not necessarily the groupID. And it wants the group to exist before you set it.

Next you need to mount the shared partition and the other OSs' root partitions, and make sure they get mounted at boot time. The easy way (assuming we're in the first OS, in the ww partition) is:

    for d in vv xx yy zz; do
         sudo mkdir /$d;
         sudo sh -c "echo LABEL=$d /$d ext4 rw 0 2 >>/etc/fstab"; done
    sudo mount -a

Mount will complain if you got one of the labels wrong, or if the installer "helpfully" changed it out from under you while you weren't looking. Fix that with e2label.

For some reason none of the articles I've seen about multi-booting has talked about ssh keys. Since the purpose of this exercise is to replace an existing computer, we want the new one to have the same host keys as its previous incarnation. What you need to copy, either from the old drive, one of its backups, or one of the other installed partitions, are the host keys, /etc/ssh/ssh_host*, and the users' .ssh directories.

Finally, I log in as myself and create the symlink to /vv, with

    ln -s /vv

The first time, I also need to change /vv's owner and group to steve. With all of those things done, it's easy to either copy the contents of /vv from someplace, or pull them down with Git, and install my personal config files. I'll get into how that works in a future post.

Resources

Another fine post from The Computer Curmudgeon (also at computer-curmudgeon.com).
Donation buttons in profile.

Date: 2020-09-18 05:42 am (UTC)
lilysea: Serious (Default)
From: [personal profile] lilysea
Where is your icon from? ^_^

Most Popular Tags

Style Credit

Page generated 2025-06-29 12:36 am
Powered by Dreamwidth Studios