Dual Boot Ubuntu with Windows on Dell XPS 13

LH Fong
ESTL Lab Notes
Published in
8 min readJul 11, 2019

--

Windows 10 and Ubuntu 19.04

Having received a Dell XPS 13 laptop with Windows installed, I proceeded to dual boot it with Ubuntu. Here are the main steps, a list of challenges faced and where possible, where information was found to solve them.

Create Ubuntu USB Stick

Download Ubuntu and create a bootable USB stick. You can follow the tutorial here, which uses Rufus to write the ISO file to a USB drive and make it bootable.

Resizing the Disk

From Windows Disk Management, shrink the volume. This was as easy as right clicking on it, selecting “Shrink Volume” and putting in a size.

Booting to the Ubuntu USB Stick

On the Dell XPS 13, the button to mash repeatedly until a boot device selection screen comes up is F12. You can also enter BIOS setup from this menu.

After booting from the USB stick, the installer could not see the hard drive at all. From this AskUbuntu post, the solution is to change to AHCI mode in the BIOS. The steps in the answer must be followed exactly.

  1. From Windows, poke through the Settings for the option to reboot into safe mode.
  2. When the computer restarts, press F12 and enter BIOS setup. Change to AHCI mode and let the computer continue booting in Safe Mode.
AHCI Setting

It is crucial that the switch to AHCI occurs during the boot into Safe Mode. If you miss this and reboot normally from Safe Mode, Windows will try to boot normally and the SATA operation mode change will cause Windows to be unable to boot.

If the Windows partition is encrypted, the BitLocker recovery key is required to boot to Safe Mode.

If you messed this up the first time, don’t panic. Go back into the BIOS, revert the SATA Operation setting and Windows should boot normally again. You can then try again.

Installing Ubuntu

The Ubuntu installer can now see the hard drive. There is no need to manually adjust the partitions. The installer automatically does the right thing and uses just the empty space set aside for it.

You do have to select the right option to install Ubuntu alongside the existing installation of Windows.

Various Annoyances

Other than the hiccup from the SATA mode change, installing Ubuntu was quite simple. On the Dell XPS laptop running Ubuntu, most things just worked without additional configuration. The sound was fine, WiFi could connect, Bluetooth was working, even the hardware function buttons worked.

However, the little annoyances are all under the surface. Here’s a list of those I’ve encountered and the solutions I’ve found.

Tiny GRUB Screen

The Dell XPS 13 came with a 4K screen. Unfortunately, the GRUB bootloader does not scale the text so everything was really tiny. It was really hard to see what operating system was selected for boot.

This AskUbuntu page has the solution. Similar to the comment by Bernard Wei, the videoinfo command did not work for me. 1024x768 and 1280x1024 were both okay but not 1920x1080.

Default Volume Level on Startup

It was always 100%, which could be dangerous if using earphones.

Set the volume to the desired level and then run sudo alsactl store from the Terminal. The solution was found in this post.

Using a Bluetooth Mouse when Dual Booting

This one isn’t Ubuntu’s fault. After pairing my Logitech m337 Bluetooth mouse on Windows, I would have to pair it again in Ubuntu. Upon booting back to Windows, it wouldn’t work unless I go through the pairing steps again.

The reason is because each pairing operation resets the shared key between the operating system and the mouse. The good news is that it’s possible to read the key used from one operating system and copy it over to the other one.

Unix StackExchange has the steps. First, pair the mouse individually in each operating system.

With BitLocker enabled, the “easier” method of using chntpw from Linux does not work. It is necessary to download psexec and run it on Windows instead. Simply going to the registry key without opening regedit with psexec as detailed in the given steps will also not work. The key cannot be viewed without using psexec .

  1. Save the Data of the registry key and reboot into Ubuntu. Edit the file at /var/lib/bluetooth/<bluetooth mac address>/<mouse mac address>/info
  2. Edit the link key and restart Bluetooth with sudo /etc/init.d/bluetooth restart

Using a Bluetooth LE Mouse when Dual Booting

Alternatively, both the Logitech MX Anywhere 2S or the Logitech MX Master 2S can be paired with up to 3 systems at the same time. It’s simple to switch between them by pressing a button.

That’s the easy solution, but using 2 out of 3 slots for 1 machine is a bit of a waste. Also, with 1 machine running 2 operating systems, you might really want to connect to more than 3 operating systems at the same time. The main concept outlined above for the M337 works, but with Bluetooth LE devices, some of the things are named differently and there are few more things to copy.

Here’s the Unix StackExchange answer with the steps. It links to a page from console.systems with detailed instructions.

Some things to note:

  1. The mouse MAC address is not the same. The folder in Ubuntu has to be renamed.
  2. The StackExchange answer says not to copy KeyLength to EncSize. I left EncSizealone too.
  3. ERand to Rand : The StackExchange answer has the better description of what to do here. The hex value is reversed byte by byte (2 characters at a time).

Using the Logitech MX Master 2 Mouse

This mouse has a higher DPI sensor. Setting the Mouse Speed setting to the maximum was insufficient in making the pointer move at a useful rate. The easiest suggestion found online was to use xset m <acceleration> <threshold> , but that had no obvious effect even with acceleration set to something like 256.

Unix StackExchange comes to the rescue again with instructions on how to modify the “Coordinate Transformation Matrix” using xinput .

This command only works for the current session. Everything resets upon restart, or if the mouse is reconnected. There are suggestions on how to make this persist over restarts. These consist of making changes to xorg config files.

Trying to persist the setting in /etc and /usr/share both did not work for me. The Xorg log file, which was in ~/.local/share/xorg/Xorg.0.log for me, showed the section being applied, but there was no effect.

In the end, what worked was adding the xinput command to “Startup Applications”. The device and property names were used instead of their ID numbers as the ID numbers would sometimes change between restarts.

Editing Startup Applications to adjust mouse speed

Mapping Caps Lock to Control

Install the gnome-tweak tool by running sudo apt install gnone-tweak-tool. It can be started by pressing the Super key and searching for “Tweaks”. You can also start the tool by running gnome-tweaks from the Terminal.

The option is under “Keyboard and Mouse” -> “Additional Layout Options” -> “Caps Lock behavior”.

Gnome Tweaks

Fighting for Time

The Bluetooth mouse section involved lots of booting to Ubuntu, then Windows, then Ubuntu. Since I use Flux in Windows and Night Light in Ubuntu to reduce blue light after sunset, it was puzzling to keep seeing the screen with the wrong colour temperature for the time of day.

It turns out that Windows assumes the hardware clock is stored in local time, while Ubuntu assumes it’s in UTC. Each time one of them boots, it will get the correct time from a time server and then sync the hardware clock with its own assumptions.

The easiest way to fix this is to tell Linux to use local time by running the following command:

timedatectl set-local-rtc 1 --adjust-system-clock

Here are the links that describe this situation and how to fix it:

Controlling Spotify with the Hardware Media Keys

Sometimes, the hardware media keys would not work on Spotify. It turns out that they were controlling some media in a website on Chrome instead. This can be fixed by opening chrome://flags/#hardware-media-key-handling in Chrome and changing it to “Disabled”.

This solution was found on Dell’s forums.

oh-my-zsh Error Message

After installing oh-my-zsh, there was always an error compdef: unknown command or service: rails . At first I thought this was due to not actually having Rails installed, but it did not go away even after installing Ruby and Rails.

This was brought up in a GitHub issue and the solution in one of the comments worked for me:

rm -f ~/.zcompdump*; compinit

Suspend

The most annoying problem is saved for last. This is also the one for which there is no workaround. EDIT: A workaround has been posted, see the end of this section.

Ubuntu does not sleep properly when the lid is closed. This results in excessive battery drain. More worryingly, it seems to wake up even with the lid closed. This happened even when it was being carried around in a backpack, causing excessive heating.

This AskUbuntu post has an explanation and solution which worked. The laptop was only going into s2idle instead of deep sleep. The permanent fix of editing Grub’s configuration file and regenerating the configuration did work.

However, this resulted in another bug. Sometimes, but not always, the Bluetooth device would fail to revive itself when the system is resumed. Bluetooth settings show that there is no device at all and to plug in a dongle. On rarer occasions, the WiFi radio would not come up too.

A simple reboot does not cause the devices to come back. The computer needs to be completely shutdown and started again. It seems like restarting to Windows and then restarting back to Ubuntu also works, but that is just as unsatisfactory.

It looks like the bug has been reported and confirmed. Perhaps it will be fixed one day.

EDIT: There’s a workaround posted in one of the comments on the bug report thread which has worked for me.

As root, create the following shell script in /lib/systemd/system-sleep/rfkill-bluetooth-workaround :

#!/bin/sh
set -e
if [ "${1}" = "pre" ]; then
rfkill block bluetooth
elif [ "${1}" = "post" ]; then
rfkill unblock bluetooth
fi

Make the script executable with chmod 755 /lib/systemd/systemd-sleep/rfkill-blueooth-workaround .

Conclusion

Ubuntu Linux is a generally a nice distro to use for day to day development. It is nice that most things work and it was not necessary to mess with driver installations or arcane configuration files just to get basic functionality like WiFi and Bluetooth working on the Dell XPS 13.

However, there are still various annoyances. Most of them had relatively simple workarounds, but missing Bluetooth or WiFi radios after resuming from deep sleep might be a deal-breaker for some.

--

--