Dual Boot Arch Linux and Windows 8

Dual Boot Arch Linux and Windows 8

I have a Toshiba Ultra Book U840W-x0110 that comes with WIndows 8 pre-installed.

Dual booting Linux with Windows has some risk associated. You might end up losing the Windows installation. Hence ensure that you have backed up all the data and have the recovery disk of Windows 8. If you don’t have the recovery disk then create one. (A good guide can be found here).

Prerequisite: A wired internet connection makes the Arch Linux installation easier.

This Ultra book does not have an optical drive. Hence I connected an external optical drive (ASUS DVD writer).

Setup

So here are the steps I followed to have a dual-boot configuration of Windows 8 and Arch Linux.

Steps to create Boot Media for Arch Linux :

    1. Download the Live Media for Arch Linux from here.
    2. Insert a blank DVD into the optical drive.
    3. Right click on the downloaded file and select “Burn to Disk” .
    4. The burn process takes about 5 minutes.
    5. The DVD ejects once the burn process is done.

Create an empty partition on the drive for installing Arch Linux:

    1. Press [Win-Logo]+[R] and type in “diskmgmt.msc” and press [ENTER] to open the Disk-Management in Windows-8.
    2. For my installation  I shrank the C drive to half its size. So that I could install the Arch Linux on a 250 GB (approximate) partition. Select the C drive in the Disk-Management, right-click and select “Shrink volume”.

Steps to change to boot order so that Arch Linux Live Media in the Optical Drive is booted after restart.

  1. Restart the Ultra Book with the shift key pressed. IMG_1664
  2. In the following screen select the troubleshoot option.IMG_1665
  3. In the following screen select the Advanced option.IMG_1666
  4. In the following screen select the UEFI Firmware settings.IMG_1667
  5. Now the BIOS settings are shown.IMG_1668
  6. Move to the security settings and disable the Secure Boot.IMG_1669
  7. Move to the boot settings and change the boot order so that the optical drive is checked first.IMG_1672
  8. Press F10 to “Save and exit”.IMG_1673
  9. Connect to internet via ethernet cable. See that the Arch Linux Live Media DVD is inserted and then restart the Ultra Book.

Booting of the Arch Linux live media and install on hard disk:

  1. After the restart the first screen should have the option “Arch Linux archiso …”. Select it.IMG_2277
  2. Now Arch Linux should boot from the Live Media DVD.IMG_2276

To find out if there is an Internet connection run the command:

 ping -c 3 www.google.com

If you don’t get the below error then you are doing fine else there is something wrong with your internet connection.

ping: unknown host

Toshiba Ultra Book U840W-x0110 has UEFI boot supported. The steps mentioned in this post are for PCs which are booted with UEFI mode. To confirm this run the following command:

mount -t efivarfs efivarfs /sys/firmware/efi/efivars
efivar -l

This will display a list of UEFI variables without errors confirming that we have booted in UEFI mode. Now we can continue with our installation.

Next run the following command to list the block devices (hard disk).

 lsblk

The output should be similar to this :

 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0  229.8G  0 disk 
├─sda1   8:1    0   450M   0 part 
├─sda2   8:2    0   260M   0 part
├─sda3   8:3    0   128M   0 part 
├─sda4   8:4    0 219.3G   0 part 
├─sda5   8:5    0   8.9G   0 part 
sdb      8:16   0  29.8G  0 disk

Create Linux partitions :

 cgdisk /dev/sda

The sda is the name of the block device got by running the lsblk command.

Now you get a table similar to the one below:

                                 cgdisk 0.8.10

                              Disk Drive: /dev/sda
                           Size: 976773168, 465.8 GiB

Part. #     Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
   1        450.0 MiB   Windows RE                Basic data partition
   2        260.0 MiB   EFI System                Basic data partition
   3        128.0 MiB   Microsoft reserved        Basic data partition
   4        219.3 GiB   Microsoft basic data      Basic data partition
            236.8 GiB   free space
   5        8.9 GiB     Windows RE                Basic data partition
            1.0 MiB     free space
    [ Align  ]  [ Backup ]  [  Help  ]  [  Load  ]  [  New   ]  [  Quit  ]
    [ Verify ]  [ Write  ]

                      Create new partition from free space

Press the down arrow key until you reach the row with a large free space (236.8 GiB in this example).

Press N, followed by Enter (For the line starting with "First Sector ..."), 
Type the size of the sector (230G in my example), 
followed by another Enter (For the line starting with "Hex code ..."), 
followed by another Enter (For the line starting with "Enter new partition name, ....").

This creates a new Linux Filesystem type partition (of size 230G in my example). This will be my root partition.

Next create a Linux Swap partition.

Again press the down (or up) arrow key until you reach the row with the free space(6.8GiB).

Press N, followed by Enter (For the line starting with "First Sector ..."), 
Type the size of the sector (5G in my example), 
followed by 8200 (For the line starting with "Hex code ..."), 
followed by another Enter (For the line starting with "Enter new partition name, ....").

Next create a EFI partition.

Again press the down (or up) arrow key until you reach the row with the free space(1.8GiB).

Press N, followed by Enter (For the line starting with "First Sector ..."), 
Type the size of the sector (512M in my example), 
followed by EF00 (For the line starting with "Hex code ..."), 
followed by another Enter (For the line starting with "Enter new partition name, ....").

Now the partition table will look like:

                                cgdisk 0.8.10

                              Disk Drive: /dev/sda
                           Size: 976773168, 465.8 GiB

Part. #     Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
   1        450.0 MiB   Windows RE                Basic data partition
   2        260.0 MiB   EFI System                Basic data partition
   3        128.0 MiB   Microsoft reserved        Basic data partition
   4        219.3 GiB   Microsoft basic data      Basic data partition
   6        230.0 GiB   Linux filesystem
   7        5.0 GiB     Linux swap
   8        512.0 MiB   EFI System
            1.3 GiB     free space
   5        8.9 GiB     Windows RE                Basic data partition
            1.0 MiB     free space

Now there are 2 EFI partition. One of them (512M) was created by us. The other from the Windows 8 installation. Note down the partition number of the 260M Windows 8 EFI partition. In this example its 2 (i.e sda2).

Create File Systems:
Next steps are for creating the file systems in the partitions that were created in the previous steps.
To review the partitions we created in the previous steps run the below command:

lsblk

The output should be similar to :

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0   450M  0 part 
├─sda2   8:2    0   260M  0 part
├─sda3   8:3    0   128M  0 part 
├─sda4   8:4    0 219.3G  0 part 
├─sda5   8:5    0   8.9G  0 part 
├─sda6   8:6    0   230G  0 part
├─sda7   8:7    0     5G  0 part
└─sda8   8:8    0   512M  0 part
sdb      8:16   0  29.8G  0 disk

In my example the sda6 of size 230G is the first Linux partition created as a root partition, sda7 of 5G as a swap partition, sda8 of 512M as a EFI partition. Also there is a EFI partition created by the Windows 8 installation. This is a 260MB EFI partition (sda2 in this example). Knowing these partition numbers (sda6,sda7,sda8 and sda2) correctly is very important for the following steps. In your situation these partitions numbers may be different. Hence take caution.

Create the ext4 file system in the root partition:

mkfs.ext4 /dev/sda6

Create the swap file system for the swap partition:

mkswap /dev/sda7
swapon /dev/sda7

Create a EFI system partition:

mkfs.fat -F32 /dev/sda8

Mount the partitions:

Mount the root partition (sda6 in this example):

mount /dev/sda6 /mnt

Mount the EFI partition created by us:

mkdir /mnt/boot
mount /dev/sda8 /mnt/boot

Mount the EFI partition from the Windows 8:

mkdir /mnt/MicrosoftBoot
mount /dev/sda2 /mnt/MicrosoftBoot

Install the base system:

pacstrap -i /mnt base

Generate the File System Table:

genfstab -U -p /mnt >> /mnt/etc/fstab
nano /mnt/etc/fstab

change root :

arch-chroot /mnt /bin/bash

Set Locale :

nano /etc/locale.gen

I will generate the locale for US english with UTF-8 encoding.

Remove the # from the line en_US.UTF-8 UTF-8. Press Control + O to save the file. Control + X to exit the nano editor.

locale-gen

Create the /etc/locale.conf file substituting your chosen locale:

echo LANG=en_US.UTF-8 > /etc/locale.conf

Export substituting your chosen locale:

export LANG=en_US.UTF-8

Set the time Zone. For Berlin,Europe :

ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime

To find out available time zones:

ls /usr/share/zoneinfo/

To find the sub-zones for the zones displayed for the previous command. For Europe:

ls /usr/share/zoneinfo/Europe

Set the hardware clock:

hwclock --systohc --utc

Set the host name. oopra in my case:

echo oopra > /etc/hostname

Set the root password and remember it:

passwd

Install and configure the boot loader:

mount -t efivarfs efivarfs /sys/firmware/efi/efivars
pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck

Run the below command and note down the output (MicrosoftBoot is the directory where we mounted the Windows 8 EFI partition):

grub-probe --target=fs_uuid /MicrosoftBoot/EFI/Microsoft/Boot/bootmgfw.efi

In the example the output is :

4252-7460

Also run the below command and note down the output:

grub-probe --target=hints_string /MicrosoftBoot/EFI/Microsoft/Boot/bootmgfw.efi

In the example the output is:

--hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2

With the outputs of the above two commands add a custom entry in the grub menu:

nano /etc/grub.d/40_custom

Add the Windows 8 entry. Now the 40_custom file looks like the one below (The outputs of the commands that we noted down are inserted after “–hint-bios=”):

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
        menuentry "Windows 8" {
                insmod part_gpt
                insmod fat
                insmod search_fs_uuid
                insmod chain
                search --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 4252-7460
                chainloader /EFI/Microsoft/Boot/bootmgfw.efi
        }

Now create the grub configuration :

grub-mkconfig -o /boot/grub/grub.cfg

Exit the Chroot, unmount, reboot. Importantly eject the installation CD before the laptop starts up again :

exit
umount -R /mnt
reboot

Now the laptop will boot into the Arch Linux we have installed with the previous steps.

Now we have logged-in as root user. Working as a root user is not recommended for regular use.

So add a new user ( hackoopra in this example):

useradd -m -s /bin/bash hackoopra

Set a password for the new user:

passwd hackoopra

Add sound driver:

pacman -S alsa-utils

unmute ALSA:

amixer sset Master unmute

Install the Graphical User Interface :

pacman -S xorg-server xorg-server-utils xorg-xinit
pacman -S mesa

Install the Intel Video card driver (The Toshiba Ultra Book U840W-x0110 has a Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
) :

pacman -S xf86-video-intel

Install input drivers :

pacman -S xf86-input-synaptics

Install the default environment for X :

pacman -S xorg-twm xorg-xclock xterm

Check if X is running :

startx

Now there should be few movable windows. Close them by typing exit in every window.

I prefer the KDE Desktop environment. Hence the below steps are for installing KDE.

Run the below command to install KDE. This takes a while.

pacman -S kde

Install the KDE Display manager (KDM):

pacman -S kdebase-workspace

Configure the KDM:

systemctl enable kdm

Now reboot with the “reboot” command and you should be presented with a login screen. Your minimal Arch Linux is ready.

References :

Arch Linux Wiki

Leave a Reply

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