Shared Dual Boot – Windows 10 and Ubuntu 15.10

Steve S.Uncategorized8 Comments

There’s a few guides online already dealing with setting up a machine to dual boot into Windows 10 and Ubuntu 15.10 but none of them provided a complete solution for me. Primarily, I wanted to share my user directories between both operating systems. I’ll give a quick rundown of my process without getting into complete step-by-step instructions. This guide assumes that you have some experience with installing one or both of these operating systems and possibly a dual boot as well.

I recently started working with a new Dell XPS 13 laptop. I primarily use Windows for daily use largely due to Adobe applications and other support that Linux distros haven’t quite caught up with yet (or at least without spending several hours configuring). For software development, my typical workflow is to work from a Windows client to a remote Linux server or a local VM running on Hyper-V. Although the XPS 13 would probably be able to handle a similar Hyper-V environment to a reasonable degree, I figured I’d give it a bit of a break and have a separate dedicated Linux partition. Plus, it’s been a few years since I last tried to use a Linux OS for daily use and figured this would be a good machine to try it out on again.

Now, the tricky part about this setup, is that I wanted to make the most out of my SSD and not have to duplicate any files. Essentially, I wanted a shared user data partition for Linux and Windows.

Windows Install

Despite this being a brand new computer, my first step is a fresh install of Windows. When I had done this prior with earlier versions of Windows, I installed Ubuntu first and used the Grub bootloader to choose what to boot at startup. This seems to be a more popular use case though for people wanting to resize the Windows partition and add Ubuntu.

Our goal here is to create one partition for the main Windows operating system and another for user data that will ultimately be shared with Ubuntu Linux. You’ll see some guides on hacks to do this following installation that are begging for all sorts of undesired consequences and bugs. This will install Windows from scratch with a directory structure over multiple partitions. If you have separate physical drives (i.e. OS on an SSD and data on a larger HDD), this divisioning is just beautiful.

Newer Windows PCs do not have a product key anymore, as it is registered with the hardware by the OEM. Usually in the BIOS or UEFI. In case you need it though, or want a record of your old key if you want to revert back, run the following script and you’ll get a popup window with your 25 character key.

' productkey.vbs - View Windows product key.
Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionDigitalProductId"))

Function ConvertToKey(Key)
  Const KeyOffset = 52
  i = 28
  Chars = "BCDFGHJKMPQRTVWXY2346789"
  Do
    Cur = 0
    x = 14
    Do
      Cur = Cur * 256
      Cur = Key(x + KeyOffset) + Cur
      Key(x + KeyOffset) = (Cur  24) And 255
      Cur = Cur Mod 24
      x = x -1
    Loop While x >= 0
    i = i -1
    KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
    If (((29 - i) Mod 6) = 0) And (i <> -1) Then
      i = i -1
      KeyOutput = "-" & KeyOutput
    End If
  Loop While i >= 0
  ConvertToKey = KeyOutput
End Function

Use the Microsoft Windows 10 media creation tool to create a bootable USB drive to install Windows with. Backup files, reboot into the USB, and start to follow the instructions to reinstall Windows 10 from scratch.

When prompted which installation to use, choose “Custom: Install Windows only (advanced).” At the window for “Where do you want to install Windows?”, you’ll need to consider the allocation of each partition for the entire disk. It’s important at the very least to make sure that the OS partitions have enough storage for the OS itself. I’ve personally decided to take a fairly simple approach and split the disk in half for OS and data partitions.

A question you’ll need to ask yourself now is how large to make your Linux swap partition. There’s several different schools of thought on this issue. Because I want a general use system with an option to hibernate, I chose to follow Ubuntu’s guidelines for 8GB of RAM and create an 11GB swap. (This is probably overkill, but better safe than sorry for now.) I’ve taken this chunk out of the OS half of the disk and split the remainder evenly between Windows and Linux. For a 256GB drive, I have 238.48GB of usable storage data after flash over-provisioning. My results look like this:

  1. Delete all existing partitions.
  2. Create Windows OS partition. This is measured in MB here, so allocate 55,418.88 MB (54.12 GB)
  3. Windows will divide this as follows:
    1. a. 450MB Recovery
      b. 100MB System
      c. 16MB MSR (Reserved)
      d. 53.6 GB Primary
  4. Create a 5th partition with the remaining unallocated space for 122,102 MB (119.24 GB).
  5. The remaining unallocated space will be used later for Linux and swap.

Let Windows go through its installation but STOP once it gets to the user configuration screen.

This is the fun part.

For a more in depth analysis of what we’re doing here, check out this guide from tenforums.com.

Press CTRL + SHIFT + F3 and Windows will reboot into Audit Mode. It’ll end up at the Windows Desktop with a System Preparation Tool dialog box shown. Go ahead and close this.

Press WIN + R and enter ‘diskmgmt.msc’ in the run dialog. Your data partition will be listed here with a File System type of RAW. Right click and choose format. Apply the following settings with your desired volume label.

Untitled

Now we can right click any available drives and choose “Change Drive Letter and Paths…”. Your USB will likely show up as drive D:, which we want for data. First change this to X:. Then set data to D:. If you have an optical drive or anything else, set these as desired. This guide assumes that these 3 drives are the same or you will have to modify accordingly. You should end up with a setup similar to the following image. (Yes, I was a bit lazy with rounding my drive partitions exactly).

Untitled3

Create a new file called relocate.xml and place at the root of drive D:.

<!--
relocate.xml - Used in Audit mode for Windows 10 as part of the process to relocate user partition.
-->
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FolderLocations>
<ProfilesDirectory>D:Users</ProfilesDirectory>
</FolderLocations>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:X:sourcesinstall.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

The only variable here should be the processorArchitecture. Change this to “x86” if you have a 32-bit version of Windows. Otherwise, if everything was set up properly, this is ready to go.

Press WIN + X, select Command Prompt (Admin) and enter the following commands. Ignore it if Windows Media Player Network Sharing Service throws an error; we just want to make sure this service isn’t running.
   net stop wmpnetworksvc
   %windir%system32sysprepsysprep.exe /oobe /reboot /unattend:d:relocate.xml

You should see Sysprep launch a window to process your script, and Windows will reboot and you can finish your installation of Windows.

When you finally enter your Windows environment for the first time, you will see that all user directories are in your D: data partition.

To properly mount NTFS partitions in Linux, first we’ll need to disable fast startup which was introduced in Windows 8. Otherwise, there will be errors that it can’t mount the filesystem due to hibernation.

  1. Open Power Options.
  2. Click on Choose what the power buttons do.
  3. Click on Change settings that are currently unavailable.
  4. Uncheck Turn on fast startup (recommended).

Linux Installation

Now that all that Windows madness is over, we are ready to install our second operating system.

For this guide, make sure to use the same username you set when installing Windows.

First, Download Ubuntu. I’m happily running 14.04 LTS on some headless servers but wanted to check out the new features in this use case and will be using 15.10. Ubuntu generally has great documentation so follow this guide to create bootable USB media from your shiny, new Windows 10 installation.

Once again, reboot into your USB drive but this time with into an Ubuntu installation. Select “Install Ubuntu” and follow installation instructions until you get to the “Installation type” screen.
ubuntu1510

Select “Something else” and you should see the remaining free space on your drive. Create a partition of your desired size for Use as: “swap area”. Finally, format the rest at Mount point: “/” as “Ext4 journaling file system”. Press Install Now and let the Wily Werewolf do its thing. Note: this guide assumes an unencrypted /home partition. If you do choose to encrypt, follow some of the extra steps in Ubuntu’s guide.

Notice I didn’t create a separate /home partition. This is typically done to ease reinstallation of the Ubuntu operating system without deleting user data in /home. We’ll be using the existing shared data partition for this purpose but you are welcome to create one for dedicated Linux user files outside the shared partition.

When it’s done installing, remove the USB drive, reboot and enter BIOS/UEFI at startup. Pressing F2 at the Dell logo will get you there on the XPS 13. Don’t worry, there will be more Linux configuration after.

Bootloader

This was done on UEFI – Dell XPS 13 9350.

Navigate to Settings->General->Boot Sequence

There should already be an option for Windows Boot Manager. You’ll have to create one for Ubuntu. When you’re done you should have at least the following two boot options.

Boot Option File Name
Linux Grub EFI/ubuntu/grubx64.efi
Windows Boot Manager EFI/Microsoft/Boot/bootmgfw.efi

Setting the grub bootloader first will make it the default bootloader which is recommended for this dual-boot setup. It’s important to leave the Windows Boot Manager enabled so that we can press F12 and choose between the two if necessary.

Linux Configuration

Boot back into Linux and open a terminal window.

First off, I recommend using grub-customizer to manage your boot options. It will provide a nice graphical interface to allow you to rename and reorder your boot options and more importantly, remember the last one you booted and automatically go back into that.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

I’ll be using Emacs as my primary text editor, so replace that with your own if you use something else. Using another editor is your choice and if so, I’m sorry but you’re wrong. You can install this first with:
sudo apt-get install emacs

By default, Linux can’t access the NTFS filesystem we’re using in Windows. We’ll enable that and mount the partition.

sudo apt-get install ntfs-3g
sudo mkdir /media/data

Get a list of the UUID for each partition with
sudo blkid

You should get an output similar to mine. You want to find the data partition and make note of the UUID for the next step.
Example:


/dev/nvme0n1: PTUUID="4e1f4fba-d266-47e9-a288-f81134ce365b" PTTYPE="gpt"
/dev/nvme0n1p1: LABEL="Recovery" UUID="0A6A17E86A17CEF7" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="91695 fed-3cab-4822-bb5d-cf0e0711d72b"
/dev/nvme0n1p2: UUID="2219-1231" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="17652385-293a-4100-ba69-e3563 9fd5ebe"
/dev/nvme0n1p3: PARTLABEL="Microsoft reserved partition" PARTUUID="f951f309-48af-42b4-8b1e-0fdfafe5421f"
/dev/nvme0n1p4: UUID="586A9CBA6A9C95FA" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="19d96477-cc30-4dd6-a16 9-07cd44487fdd"
/dev/nvme0n1p5: LABEL="data" UUID="A47A253D7A250E1C" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="4a80db27- 69e4-4fbf-ad2c-396d4b3cc8ac"
/dev/nvme0n1p6: UUID="8c9955ca-ec8a-4281-8450-7d7f0772e27a" TYPE="swap" PARTUUID="f688dd49-473c-4bd0-a5d0-46b77be3593 8"
/dev/nvme0n1p7: UUID="00d17fca-1146-4c83-8ed2-bc02706d632b" TYPE="ext4" PARTUUID="2d891890-b37c-4c77-b06d-3c29b32e519 d"

Your fstab file will tell Ubuntu which partitions to mount at boot. Make a copy of it, then open it to modify.

sudo emacs /etc/fsab

Add the following line, replacing my UUID with your own.
UUID=A47A253D7A250E1C /media/home ntfs-3g defaults 0 2

Run the following to mount:
sudo mkdir /media/home
mount -a

Add the following line to ~/.bashrc
export WINHOME=/media/home/Users/$USER

Reboot first to be safe.

To play nice with Windows, we first want to tell Nautilus where our new directories are.
Edit ~/.config/user-dirs.dirs

XDG_DESKTOP_DIR="$WINHOME/Desktop"
XDG_DOWNLOAD_DIR="$WINHOME/Downloads"
XDG_TEMPLATES_DIR="$WINHOME/Templates"
XDG_PUBLICSHARE_DIR="$/media/home/users/Public"
XDG_DOCUMENTS_DIR="$WINHOME/Documents"
XDG_MUSIC_DIR="$WINHOME/Music"
XDG_PICTURES_DIR="$WINHOME/Pictures"
XDG_VIDEOS_DIR="$WINHOME/Videos"

Next, create symbolic links for all shared user directories.
Open a terminal and run:

cd ~
rm -rf Desktop Downloads Templates Public Documents Music Pictures Videos
ln -s $WINHOME/Desktop
ln -s $WINHOME/Downloads
ln -s $WINHOME/Templates
ln -s $WINHOME/Public
ln -s $WINHOME/Documents
ln -s $WINHOME/Music
ln -s $WINHOME/Pictures
ln -s $WINHOME/Videos

Reboot again.

Done

If everything was followed correctly, you should have a shared user directory on a separate partition for both Windows and Ubuntu. I kept the permissions the default when doing this, as I was running into various problems on either the Windows end or the Linux end when trying to get fancy.

If you have any issues or know of any improvements, feel free to let me know.

Enjoy!

8 Comments on “Shared Dual Boot – Windows 10 and Ubuntu 15.10”

  1. I don’t even know how I ended up here, but I thought this post was
    good. I don’t know who you are but definitely you’re
    going to a famous blogger if you are not already 😉 Cheers!

  2. Hi, I completed up until the fresh version of Windows 10 was installed. Now it isn’t recognizing a ton of items under the device manager, one of them being my wireless card. Should I just download the driver package on another computer, transfer over to my XPS and update that way?

    1. That sounds odd. This process should not affect the drivers that Windows installs. You say you did this with a fresh install of Windows 10?

      I would try doing what you suggested. Once you have an active connection, Windows should be able to download the rest of the drivers.

      1. Yes I did with fresh install of Windows 10. Not sure what to do now! Is there another way of doing a clean install of windows without affecting linux?

  3. I tried ,no luck. When i run the Dell wireless software , it says it can’t find the device.Then it crashes and some error box appears. I opened the device manager but couldn’t pick out which one was the wireless card ( do you know what i should be looking for?)

    Also Windows seems to be running slowly when i’m using it. Ubuntu works great no problems whatsoever.
    Is there a way to do another clean install of windows?

Leave a Reply to Luke Cancel reply

Your email address will not be published. Required fields are marked *