Arch Linux: installing with EFI and Windows dual-boot

By | 02/24/2019
 

The goal is to set up a new Arch Linux and Windows (just for some games) on my new PC and use dual-boot using GRUB.

Disks

Currently disks layout is next:

[simterm]

[root@archiso ~]# lsblk 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0 476.7M  1 loop /run/archiso/sfs/airootfs
sda      8:0    0 223.6G  0 disk 
sdb      8:16   0 931.5G  0 disk 
sdc      8:32   1  28.9G  0 disk 
├─sdc1   8:33   1   588M  0 part /run/archiso/bootmnt
└─sdc2   8:34   1    64M  0 part

[/simterm]

  • /dev/sda – SSD, will be for Windows
  • /dev/sdb – HDD, for Arch Linux

On /dev/sdb have to create next partitions:

  1. sdb1 – EFI, 512,
  2. sdb2 – boot, 1G
  3. sdb3 – swap, 32G
  4. sda4 – LVM, all

fdisk

Run fdisk, and create new partitions table:

[simterm]

[root@archiso ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.33).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: TOSHIBA DT01ACA1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x73c946df
...

[/simterm]

Create new for EFI, 512М:

[simterm]

...
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-1953525167, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1953525167, default 1953525167): +512M

Created a new partition 1 of type 'Linux' and of size 512 MiB.
...

[/simterm]

Set its type to EFI:

[simterm]

...
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): L

...       
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
...        
Hex code (type L to list all codes): ef
Changed type of partition 'Linux' to 'EFI (FAT-12/16/32)'.
...

[/simterm]

Next partition – for /boot, 1G:

[simterm]

...
Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (2-4, default 2): 
First sector (1050624-1953525167, default 1050624): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-1953525167, default 1953525167): +1G

Created a new partition 2 of type 'Linux' and of size 1 GiB.
...

[/simterm]

And next – for swap, 32G:

[simterm]

...
Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (3,4, default 3): 
First sector (3147776-1953525167, default 3147776): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (3147776-1953525167, default 1953525167): +32G

Created a new partition 3 of type 'Linux' and of size 32 GiB.
...

[/simterm]

Set its type to swap:

[simterm]

...
Command (m for help): t
Partition number (1-3, default 3): 
Hex code (type L to list all codes): 82

Changed type of partition 'Linux' to 'Linux swap / Solaris'.
...

[/simterm]

The last one is for LVM (take a note: fdisk will suggest Extended type – I used Primary here):

[simterm]

...
Command (m for help): n
Partition type
   p   primary (3 primary, 0 extended, 1 free)
   e   extended (container for logical partitions)
Select (default e): p

Selected partition 4
First sector (70256640-1953525167, default 70256640): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (70256640-1953525167, default 1953525167): 

Created a new partition 4 of type 'Linux' and of size 898 GiB.
...

[/simterm]

Check it:

[simterm]

...
Command (m for help): p
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: TOSHIBA DT01ACA1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x73c946df

Device     Boot    Start        End    Sectors  Size Id Type
/dev/sdb1           2048    1050623    1048576  512M ef EFI (FAT-12/16/32)
/dev/sdb2        1050624    3147775    2097152    1G 83 Linux
/dev/sdb3        3147776   70256639   67108864   32G 82 Linux swap / Solaris
/dev/sdb4       70256640 1953525167 1883268528  898G 83 Linux
...

[/simterm]

Write new partitions table:

[simterm]

...
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[/simterm]

LVM

Create Physical Volume:

[simterm]

[root@archiso ~]# pvcreate /dev/sdb4 
  Physical volume "/dev/sdb4" successfully created.

[/simterm]

Create Volume Group:

[simterm]

[root@archiso ~]# vgcreate vg_arch /dev/sdb4
  Volume group "vg_arch" successfully created

[/simterm]

Logical Volume with the root name:

[simterm]

[root@archiso ~]# lvcreate -L 100G -n root vg_arch
  Logical volume "root" created.

[/simterm]

Logical Volume with the home name:

[simterm]

[root@archiso ~]# lvcreate -l 100%FREE -n home vg_arch
  Logical volume "home" created.

[/simterm]

Filesystems creation

For the EFI – fat32:

[simterm]

[root@archiso ~]# mkfs.fat -F32 /dev/sdb1 
mkfs.fat 4.1 (2017-01-24)

[/simterm]

ext2 – for /boot:

[simterm]

[root@archiso ~]# mkfs.ext2 /dev/sdb2

[/simterm]

ext4 for root:

[simterm]

[root@archiso ~]# mkfs.ext4 /dev/vg_arch/root

[/simterm]

ext4 for /home

[simterm]

[root@archiso ~]# mkfs.ext4 /dev/vg_arch/home

[/simterm]

Create swap:

[simterm]

[root@archiso ~]# mkswap /dev/sdb3
Setting up swapspace version 1, size = 32 GiB (34359734272 bytes)
no label, UUID=14e18ccc-11f4-4e2b-baf2-c141735b8800

[/simterm]

Turn it on:

[simterm]

[root@archiso ~]# swapon /dev/sdb3

[/simterm]

Mount root into the /mnt directory:

[simterm]

[root@archiso ~]# mount /dev/vg_arch/root /mnt/

[/simterm]

/home:

[simterm]

[root@archiso ~]# mkdir /mnt/home
[root@archiso ~]# mount /dev/vg_arch/home /mnt/home/

[/simterm]

/boot:

[simterm]

[root@archiso ~]# mount /dev/sdb2 /mnt/boot/

[/simterm]

EFI:

[simterm]

[root@archiso ~]# mkdir /mnt/boot/EFI
[root@archiso ~]# mount /dev/sdb1 /mnt/boot/EFI

[/simterm]

Arch Linux install

Install OS, sshd и vim and whatever you want right now:

[simterm]

[root@archiso ~]# pacstrap -i /mnt base base-devel openssh vim

[/simterm]

Generate /etc/fstab:

[simterm]

[root@archiso ~]# genfstab -pU /mnt >> /mnt/etc/fstab

[/simterm]

Chroot to the new system:

[simterm]

[root@archiso ~]# arch-chroot /mnt /bin/bash

[/simterm]

Edit the /etc/mkinitcpio.conf, add the lvm hook:

HOOKS=(base udev autodetect keyboard keymap modconf block lvm2 filesystems fsck)

Build the kernel:

[simterm]

[root@archiso /]# cd /boot/ && mkinitcpio -p linux

[/simterm]

GRUB

Install GRUB and other needed packages:

[simterm]

[root@archiso boot]# pacman -S grub efibootmgr dosfstools os-prober mtools

[/simterm]

Install bootloader with the EFI type and ArchLinux name:

[simterm]

[root@archiso boot]# grub-install --target=x86_64-efi  --bootloader-id=ArchLinux --recheck
Installing for x86_64-efi platform.
GUID Partition Table Header signature is wrong: 0 != 5452415020494645
GUID Partition Table Header signature is wrong: 0 != 5452415020494645
GUID Partition Table Header signature is wrong: 0 != 5452415020494645
GUID Partition Table Header signature is wrong: 0 != 5452415020494645
GUID Partition Table Header signature is wrong: 0 != 5452415020494645
GUID Partition Table Header signature is wrong: 0 != 5452415020494645
Installation finished. No error reported.

[/simterm]

Create GRUB’s config file:

[simterm]

[root@archiso boot]# grub-mkconfig -o /boot/grub/grub.cfg

[/simterm]

Check this post if it hangs –Arch Linux: grub-mkconfig hangs on the /boot/grub/grub.cfg config generation.

[simterm]

[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
done

[/simterm]

And we are done Arch for now.

Windows dual boot

For the obvious reasons – Windows installation process is out of the scope of this blog at all 🙂

Install it on the /dev/sda device and check partitions now:

[simterm]

[root@archlinux /]# lsblk 
NAME             MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                8:0    0 223.6G  0 disk 
|-sda1             8:1    0   499M  0 part 
|-sda2             8:2    0   100M  0 part 
|-sda3             8:3    0    16M  0 part 
`-sda4             8:4    0   223G  0 part 
sdb                8:16   0 931.5G  0 disk 
|-sdb1             8:17   0   512M  0 part /boot/EFI
|-sdb2             8:18   0     1G  0 part /boot
|-sdb3             8:19   0    32G  0 part [SWAP]
`-sdb4             8:20   0   898G  0 part 
  |-vg_arch-root 254:0    0   100G  0 lvm  /
  `-vg_arch-home 254:1    0   798G  0 lvm  /home
sdc                8:32   1  28.9G  0 disk 
|-sdc1             8:33   1   588M  0 part 
`-sdc2             8:34   1    64M  0 part

[/simterm]

Windows-boot can be seen in the UEFI BIOS on the device 1 (/dev/sda):

А Arch – on the device 2 (/dev/sdb).

If os-prober not installed yet – install it:

[simterm]

[root@archlinux /]# pacman -S os-prober

[/simterm]

Check the /dev/sda partitions:

[simterm]

[root@archlinux /]# fdisk -l /dev/sda
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Disk model: KINGSTON SA400S3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 78241A73-6994-4D0B-9FCB-433076B5EC41

Device       Start       End   Sectors  Size Type
/dev/sda1     2048   1023999   1021952  499M Windows recovery environment
/dev/sda2  1024000   1228799    204800  100M EFI System
/dev/sda3  1228800   1261567     32768   16M Microsoft reserved
/dev/sda4  1261568 468860927 467599360  223G Microsoft basic data

[/simterm]

To make os-prober available to find Windows, which is installed on another device – we need to mount its boot-partition which is  204800 100M EFI System. for Windows.

Mount it:

[simterm]

[root@archlinux /]# mount /dev/sda2 /mnt/
[root@archlinux /]# ls -l /mnt/
total 1
drwxr-xr-x 4 root root 1024 Feb 24 10:24 EFI

[/simterm]

Run os-prober:

[simterm]

[root@archlinux /]# os-prober
/dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi

[/simterm]

Backup existing GRUB’s config:

[simterm]

[root@archlinux /]# cp /boot/grub/grub.cfg /boot/grub/grub.cfg-origin

[/simterm]

Re-generate it:

[simterm]

[root@archlinux /]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
done

[/simterm]

Reboot PC:

And we are done.

Similar posts about Arch install (in Russian)