RackPull

Notes on dual booting Arch Linux and Windows 7

I installed Arch Linux and then Windows 7 in partitions on a single disk, booting with the Windows Boot Manager (BOOTMGR). Arch Linux boots from GRUB after being selected in the BOOTMGR menu. I set up a master boot record (MBR) rather than a GPT because I boot in BIOS.

Partition list

Here are my current partitions as shown in GParted.

GParted

In the console, type sudo fdisk -l to list the partition tables.

The home partition is optional. The share partition is accessible from both Windows and Arch Linux. I decided against having separate partitions for boot, swap, etc. For swap, I created a swap file in the root partition.

The ntfs-3g package is needed to create and mount NTFS partitions in Arch Linux: sudo pacman -S ntfs-3g.

Partition labels

Labels are useful for identifying the partitions under /dev/disk/by-label, so there’s no need to remember the numbers. For example, tab complete /dev/disk/by-label/home instead of /dev/sda6.

Partition type

Windows has to be installed on a primary partition. Any attempt to install it on a logical partition produces the error “Setup was unable to create a new system partition…”

Arch Linux doesn’t have to be on a primary partition; it can be in a logical partition inside an extended partition.

Order of partitions

It’s much easier for Windows to be the first partition as /dev/sda1 and be given the boot flag. At first, I installed Windows in a later partition because I already had Arch Linux installed at the front of the disk (which is why the device numbers ended up not sequential). BOOTMGR broke GRUB as expected, and I restored it by doing the following.

  1. Boot with live media and move the boot flag back from the Windows partition to the Linux boot partition. I used GParted to do this.
  2. Reinstall GRUB on the disk.

    mount /dev/disk/by-label/root /mnt
    arch-chroot /mnt /bin/bash
    grub-install --target=i386-pc --recheck --debug /dev/sda
    
  3. Install os-prober for GRUB to automatically detect Windows and add it to the menu.
    pacman -S os-prober

  4. Regenerate the GRUB config (mount the boot partition first if there is one).
    grub-mkconfig -o /boot/grub/grub.cfg

The problem with this was I could boot into Arch Linux but not Windows: it could no longer find BOOTMGR and went to the red GRUB4DOS screen, where none of the boot options worked. I tried using bootrec in the Windows Recovery Environment to fix the master boot record or move BOOTMGR to the first partition to no avail.

So I reordered the partitions using GParted (by resizing them, which took about 2 hours for ~200 GB) to put Windows first and boot with BOOTMGR instead. I followed the instructions on ArchWiki. GRUB now has to be installed on the partition directly and not on the disk, i.e. /dev/disk/by-label/root instead of /dev/sda. Also, os-prober is no longer required.

Shared partition

ext file systems cannot be read by Windows natively. NTFS is the most suitable file system type for a partition to be shared by Windows and Linux. In Linux, mount it as ntfs-3g:

sudo mount -t ntfs-3g -o utf8,uid=1000,gid=1000,dmask=027,fmask=137 \
  /dev/disk/by-label/share /share

The utf8 option is important if there are any Unicode filenames. It’s more convenient to use permission masks rather than -o permissions because setting permissions on the files from Linux messes with Windows’ interpretation of them:

Windows permissions

To mount on boot, add an entry to /etc/fstab:

# <file system>                            <dir>   <type>   <options>                                   <dump>  <pass>
# /dev/sda5 LABEL=root
UUID=cfb7deb4-b167-49c7-b9d3-87d14781c409  /       ext4     rw,relatime,data=ordered                    0       1

# /dev/sda6 LABEL=home
UUID=3f1e0e4b-560a-4da5-bf6f-8584575201f7  /home   ext4     rw,relatime,data=ordered                    0       2

# /dev/sda7 LABEL=share
UUID=1476D3A24D657498                      /share  ntfs-3g  utf8,uid=1000,gid=1000,dmask=027,fmask=137  0       2

# swap
/swapfile                                  none    swap     defaults                                    0       0

Boot menu timeout

To boot into Arch Linux, I now go through both boot loaders in order, BOOTMGR followed by GRUB. Set GRUB_TIMEOUT=0 in /etc/grub/default to skip the latter menu.

Clock

During the Windows install, don’t change the clock from the UTC time. Otherwise, the clock in Linux will be offset in the other direction of the time zone, which then has to be fixed with ntpdNetwork Time Protocol, and then the Windows time will be offset again, and so on. To get Windows to follow UTC, follow the instructions on ArchWiki.

Windows fonts in Linux

To use Windows fonts in Linux, mount Windows and either link the fonts directory or copy them over.

mkdir /mnt/win
sudo mount -t ntfs-3g -o uid=1000,gid=1000,dmask=027,fmask=137 \
  /dev/disk/by-label/win /mnt/win
mkdir -p ~/.local/share/fonts/windows7
rsync -avz /mnt/win/Windows/Fonts/ ~/.local/share/fonts/windows7/
fc-cache