Triple Boot Part 2: Install Windows 10 with a Larger EFI Partition

January 26, 2019 | posted in: nerdliness

This posting is part of a multi-part series on configuring a laptop with three different operating systems using systemd-boot. The series starts with How to Install Three Operating Systems on One Laptop.

Installing Windows is very straight forward; answer a few questions (and mute Cortana) and you’re all set. However if you want to alter the size of the EFI partition to be larger the process is not so straight forward.

I was able to figure it out with the help of this article: How to Change the UEFI System Partiton Size in Windows Setup.

In a nutshell when the partition dialog appears you will open a command line window, and use the diskpart command to delete everything but the Recovery partition. Next you create and format a larger EFI partition. When you leave the command line and return to the graphical dialog and reselect New the installer will create the missing partitions and keep the ones already created.

From the article:

  • Select your installation target and make sure it has no partitions (except unallocated space)
  • Click the New and then the Apply button.

You should now have four partitions: Recovery, System (ESP), MSR, and Primary.

  • Select each of the System, MSR, and Primary partitions in turn and click the Delete button to delete these partitions. Leave the Recovery partition in place.
  • Press Shift+F10 to open the Command Prompt
  • Type diskpart.exe and press Enter to open the disk partitioning tool
  • Type list disk and press Enter to list out your disks
  • Type select disk n where n is the number for the disk you want to install to as identified by the above command and press Enter
  • Type create partition efi size=550 where 550 is the desired size of the ESP in Mebibytes (MiB), and press Enter
  • Type format quick fs=fat32 label=System and press Enter to format the ESP
  • Type exit and press Enter to exit the disk partitioning tool
  • Type exit and press Enter again to exit the Command Prompt

You should now be back in the graphical Windows Setup partitioning tool where nothing has changed since the last time you looked at it.

  • Click the Refresh button to detect your partition changes

You should now have a disk with a default Windows Recovery tools partition, a 500 MiB UEFI System Partition, and some unallocated space for your Windows installation.

Select the unallocated space from the disk list and click the New button to automatically recreate the MSR and System partition in the remaining space.

Proceed with the rest of the install following the prompts. Mute Cortana or suffer the results.

Once the Windows installation is finished you are ready to move on to Triple Boot Part 3: Install Arch Linux and Set Up systemd-boot.

This posting is part of a mulit-part series on installing three operating systems on a single laptop.

Triple Boot Part 1: Create Bootable USB Installers

January 26, 2019 | posted in: nerdliness

This posting is part of a multi-part series on configuring a laptop with three different operating systems using systemd-boot. The series starts with How to Install Three Operating Systems on One Laptop.

Since my primary operating system is macOS I used Boot Camp to create a Windows 10 USB installer. The process is deadly slow - it took 2 1/2 hours for Boot Camp to tell me the Windows image I had selected was too big for the 8GB flash drive I was using. And another 2 1/2 hours to finish the job with a smaller image.

Create Windows 10 Installer

Download a Windows 10 Disk Image (ISO). The October image was too large for my 8GB flash drive, so I used the April image. After the install is finished one of updates will be the October image.

Open up Boot Camp and follow the directions. Be prepared for a very long wait. Since it takes so long to create the USB installer using Boot Camp, I bought two additional USB drives, one each for Arch and Ubuntu. Having each OS on its own USB drive makes starting over much quicker and less painful.

If your base OS is Windows or Linux there are installer creating directions for both on line.

Create a Linux Installer

Download an Arch Linux ISO or Download an Ubuntu 18.04 ISO. The steps for preparing the USB drive and copying the ISO are the same for both Linux distributions.

Prepare the USB Drive

While some of this can be done using GUI tools, not all of it can, so I’ll describe all the steps using the command line.

Find the name of the USB drive

Insert the drive and then run this command:

$ diskutil list

The output will look something like this:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:          Apple_CoreStorage                         399.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   5:                 Apple_Boot Boot OS X               134.2 MB   disk0s5
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS MacOSX                 *399.2 GB   disk1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 GB     disk2
   1:       Microsoft Basic Data UNTITLED 1              2.0 GB     disk2s1

In this case the USB is /dev/disk2.

Format the drive

Format the USB by making it all free space. This will delete all data on the USB drive.

$ diskutil partitionDisk /dev/disk2 1 "Free Space" "unused" "100%"

Substitute the proper /dev/disk# designation for your USB drive.

Copy the ISO

Now we can copy the converted image to the USB drive.

$ dd if=somethingsomething.iso of=/dev/rdisk2 bs=1m

Substitute the name of the ISO you downloaded in the if (in file) parameter. Double check that you have the proper disk specified in the of (out file) parameter, dd is not forgiving. The dd command does not show any output before it has finished the copy process, so be patient and wait for it to complete. When the command does complete macOS will try to mount the drive and fail as it won’t recognize the formatting. Click ignore or eject.

Eject the drive

If you clicked ignore above you can eject the drive from the command line.

$ diskutil eject /dev/disk2

The bootable USB installer is now ready to be used. You are now ready to proceed to Triple Boot Part 2: Installing Windows with a Larger EFI Partition.

This posting is part of a mulit-part series on installing three operating systems on a single laptop.

How to Install Three Operating Systems on One Laptop

January 26, 2019 | posted in: nerdliness

This posting is part of a multi-part series on configuring a laptop with three different operating systems using systemd-boot. The series starts with How to Install Three Operating Systems on One Laptop.

For as long as I have had a personal computer I’ve always wanted to explore different operating systems and their associated ecosystems. My first Gateway 2000 computer (a 486 SX that ran at 33 MHz) came with Windows 3. I promptly formated the drive and installed IBM’s OS 2 Warp. Later that machine would have Windows 3.1 and Windows 2000 installed on it. I also toyed around with BeOS.

For the past 17 years I’ve been a staunch macOS user on my daily driver laptop. And for the past 10 years I’ve been fortunate enough to use macOS in my professional life too. Either through VirtualBox or on a spare computer (when I had one) I’ve toyed around with Linux through a number of different distros. Red Hat, Fedora, Ubuntu, Debian, and Arch. I even went so far as to install Arch Linux on a MacBook Pro. (Note: This how to is very out of date.)

About 18 months ago I bought an ASUS Q325UA 2-in-1 laptop. It has become my Linux test bed. I’ve lost count of how many times I’ve formatted its SSD and installed a different OS or combination of OSes. I’m employed as a Systems Engineer supporting a mixed environment of Linux and Windows servers. Ubuntu Server is the Linux variant the vast majority of our infrastructure runs, with a handful of RedHat machines.

With that in mind I’ve decided to triple boot my Asus, installing Windows 10, Arch Linux, and Ubuntu 18.04 LTS Desktop. And, for no reason other than I haven’t used it before, I wanted to use systemd-boot in place of GRUB2 for the boot loader. The Asus supports UEFI so systemd-boot will work.

The Windows 10 partition is mostly to have a Windows install, I don’t expect to use it very much. The Asus has a 500GB SSD, and I’m going to give Windows 120GB. Both Arch and Ubuntu will have a 60GB root + home partition. The remaining 240-ish GB will be a shared ext4 file system mounted in both Linux installations. That way I can keep distribution specific settings and configurations separately from data, pictures, and documents.

On paper here’s how this breaks down:

  • /dev/sda1 499M Windows Recovery partition
  • /dev/sda2 100M EFI (more on this below)
  • /dev/sda3 16M Microsoft reserved
  • /dev/sda4 116G Windows 10
  • /dev/sda5 60G Arch Linux (root and home) ext4
  • /dev/sda6 60G Ubuntu 18.04 (root and home) ext4
  • /dev/sda7 ~240G Data ext4

Since Windows doesn’t play well with others it is best to install it first and then add the second (and third) operating system. By default the Windows installer creates a 100M EFI partition. This was large enough for the Arch kernals, but not for Arch and Ubuntu. My first attempt at this failed when trying to set up systemd-boot after the Ubuntu install. Had I been content to use Grub the installation of all three systems would have been done. In order to accommodate systemd-boot and two Linux distributions, I started over and increased the size of the EFI partition the Windows installer creates.

The postings linked to below detail the set up processes I followed. I don’t go into personalization or configuration beyond having a working, network attached instance of each operating system.

As always with computer how to articles found on the Internet you should take care in following along. Backup your data. Be prepared for it to not work and to have to search for answers. Be willing to start over. More than once. Have fun.

⇪ Hexyl

A cross-platform command-line hex viewer.

⇪ Gridzzly

gridzzly lets you print out your own graph, grid, or musical staff paper. I’m going to need to buy fresh toner for the laser printer now.

List crontab for Every User on the System

January 03, 2019 | posted in: nerdliness

On your local computer you probably have a good idea of any cron jobs that have been setup. When you are working on a remote machine or server, know what cron jobs are in place can be useful. Here’s a way to find them all.

cat /etc/passwd | cut -f1 -d: | xargs -I '{}' sudo crontab -u '{}' -l

Here is a breakdown of this command.

cat /etc/passwd concatenates the file to standard out. This output is piped to cut -f1 -d: which removes (cuts) sections from each line of the input file. The -f1 flag indicates we only want the first field from each line. The -d: indicates we want to delimit fields using the colon character. The output from this command, a list of user IDs cut from /etc/passwd, is piped to xargs -I '{}' which builds and executes commands (one per input value). The -I '{}' is the replacement string used in the subsequent command, sudo crontab '{}' -l. The command lists the crontab for the user passed in to xargs from the cut command.

The result of all of this is a list of all the crontab entries on the machine.

How to Rename a Git Branch

January 02, 2019 | posted in: nerdliness

Recently at work, after I had started making changes to a Git repository on a branch, I needed to rename that branch to share it with others. When I’m working by myself on something I tend to name branches mhn/topic - my initials followed by some relevant topic. Not wanting to share a branch with multiple other developers that has my initials in it, I needed to rename it.

Step 1. Switch to the local branch you want to rename

git checkout <old_name>

Step 2. Rename the local branch like so

git branch -m <new_name>

Step 3. If the branch has already been pushed to the remote repository, then delete the old_name remote branch

git push origin --delete <old_name>

Step 4. Push the new branch name and reset the upstream branch

git push origin -u <new_name>

You have now successfully renamed your Git branch.

Matomo Vistor Tracking

November 20, 2018 | posted in: nerdliness

After reading Kev Quirk’s series De-Googleing My Life, specifically the posting about Analytics, I decided to investigate Matomo.

For the past 13 years I’ve been using Mint to track visitors and activity on my website. Mint is no longer under development and support has been suspended as well. Fortunately it still works perfectly for my purposes. But the demo for Matomo looked nice and since it was free I decided to give is a try.

Installation was very straightforward and adding in the JavaScript tracking code to my site was simple. After waiting impatiently for some traffic, I was able to start comparing Matomo to Mint. I like that Mint always shows you the total unique visits and page views for all time. Matomo can show you those figures, but you have to change the date range filter to get there. Matomo does have an up-to-date geo-location database, and a real-time map feature, which is nicely geeky.

After running Matomo for a couple of weeks I’ve added codes to my various subdomains and another top-level domain. Adding in new sites to track is very quick and easy. Type in a human friendly name for the site, add its URL and then paste the generated JavaScript code in the <head></head block on the site. Mint had, when it was still for sale, a $30 ($29?) fee per top-level domain. This wasn’t a huge problem for my tiny little corner of the Internet, but it is nice to be able to add multiple sites to one tracking tool.

I’m not going to abandon Mint - at least not while it is still working. It’s tracked the 1,012,936 visitors I’ve had since December 2005 beautifully. I hope to still be using when I reach 2,000,000 visitors. Having Matomo in addition to Mint gives me a second way to slice and dice visitor data. One that is completely under my control.

Using htaccess to Get Rid of &wd=test

February 15, 2018 | posted in: nerdliness

Recently I’ve had a plague of links to my site that end with /&wd=test or /&wd= with four random characters. They were causing a large up tick in 404 errors, as none of my posts or pages has &wd= the end.

A week or so ago I setup a .htaccess RewriteRule to force any incoming link with the &wd business on the end to my 403 page. Here’s the rule:

RewriteRule "wd=test/?$" "-" [L,F]

This worked like a charm. The only problem was now I was seeing 403 errors instead of 404 errors. I realize that in this case the work “error” is a misnomer. The error is on the part of the incoming request, it isn’t an error on my site. Still, having all those 403 hits bothered me.

Time for a new RewriteRule:

RewriteRule (.+?)/\&wd=.*$  https://zanshin.net/$1 [L,R=301]

This one matches &wd= plus any number of characters after the equal sign, and it redirects the incoming link to the incoming link minus the spurious &wd business.

As for what the &wd=test might mean, this is the only English language page I’ve found that talks about it at all: Chinese “Testing” Link Hacking Attempt?. My site is static (i.e., there’s no database or online administration function to exploit. Redirecting the &wd links to the actual link seems like a good solution for me and my site.

Using tcpdump to Debug Database Connection

January 19, 2018 | posted in: nerdliness

This afternoon I had to determine why a particular database connection wasn’t working. One of the tools I ended up using was tcpdump. I don’t pretend to understand even half of what this tool can do. Here’s a nice tcpdump Tutorial and Primer with Examples.

Here’s the command I ended up using to try and figure out what was up with my broken connection:

  sudo tcpdump -s 0 -i em2.1170 dst 10.130.228.99 and port 1521 -w /tmp/library.pcap

Without the sudo you likely won’t be able to run the command. In English this command captures full length packets on the network interface called em2.1170, going to IP address 10.130.228.99 on port 1521. Whatever the command captures is written to a file in /tmp called library.pcap. This output file will be a binary, you’ll need Wireshark to read it.

-s Sets the snaplen or number of bytes from each packet to capture. The default is 65535, and -s 0 also sets it to 65535. Using -s 0 is a backwards compatibility trick, which is useful when hopping from one OS to another.

-i em2.1170 Specifies which network interface to monitor. You may need to do an ifconfig -a to determine which NIC to watch.

dst 10.130.228.99 and port 1521 Tells tcpdump we want to monitor only destination 10.130.228.99 on port 1521. Limiting what tcpdump captures is the only sane way to use it. A typical connection generates lots and lots of packets. Lots.

-w /tmp/library.pcap Specifies that we want the capture to be saved as a pcap file in the /tmp directory.

Using tcpdump can be a bit intimidating. There are lots of options, and it very powerful in that it can do lots of filtering of the packet stream you are watching. The best way to learn it is to use it. In my case today I only captured 11 packets while trying to connect to the database. Turns out the database was no longer at the IP address. Something I could have determined with

nc -v 10.130.228.99 1521

But that’s a posting for another day.