User:Sporadiccrash

From ArchWiki
Revision as of 15:47, 10 August 2019 by Sporadiccrash (talk | contribs) (added section how to set up internet with wireless router using WPA supplicant, systemd-networkd and systemd-resolved)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Computer

Had installed Arch Linux once in 2008 on an Athlon XP 2800+ machine. Now using Lubuntu but preparing the laptop for multi-boot for Arch Linux and Lubuntu.

Configuration
item value
computer Dell Latitude E7440
CPU i7-4600U
RAM 8 GB DDR3L
harddisk 256 GB Samsung PM851
UEFI options
item value comment
SecureBoot disabled Arch Linux installation does not support it (see article)
Virtualization enabled not used yet
TPM enabled not used yet
Bluetooth disabled probably won't use

Multi-Boot of Arch Linux with Lubuntu

General

  • Lubuntu was installed first (version 19.04). Arch Linux was installed afterwards (version 2019.08.01). ESP on /dev/sda1 has mountpoint /boot/efi.
  • Lubuntu was installed on /dev/sda5.
  • Arch Linux was installed on /dev/sda6. Lubuntu partition (/dev/sda5 ) and ESP (/dev/sda1) are not mounted in Arch.
  • /boot of Arch Linux is on /dev/sda6. /boot of Lubuntu is on /dev/sda5. Since Lubuntu is not mounted in / on Arch, /boot directories of Lubuntu and Arch cannot conflict.
  • Custom GRUB menu entries were created in /etc/grub.d/ on /dev/sda5 (Lubuntu) so that GRUB installed by Lubuntu can find Arch setups.
Partition Table
Partition filesystem usage
/dev/sda1 FAT32 GRUB EFI boot loader /boot/efi/EFI/ubuntu/shimx64.efi, mountpoint /boot/efi in Lubuntu
/dev/sda2 swap swap for all operating systems
/dev/sda3 unused 8 GB spare for swap or future RAM upgrade to 16 GB
/dev/sda4 ext4 user data directory, disk label=USER_DATA, mentioned in Grub menuentry below
/dev/sda5 btrfs Lubuntu 19.04, /dev/sda1 is mounted in mountpoint /boot/efi
/dev/sda6 btrfs Arch Linux

Deviations from Arch Linux Installation

1.2 Boot the live environment

You don't need to burn ISO on a USB stick. GRUB can boot an ISO image on any partition. In this example, ISO was downloaded in Lubuntu environment. A GRUB menuentry was created in Lubuntu, which can be seen below. ISO was downloaded into /dev/sda4, which corresponds to set root=(hd0,4) in GRUB menuentry.

/etc/grub.d/25_archiso
#!/bin/sh
exec tail -n +3 $0

# https://wiki.archlinux.org/index.php/Multiboot_USB_drive#Manual_configuration
# use device label instead of UUID
set imgdevpath=/dev/disk/by-label/USER_DATA

# https://wiki.archlinux.org/index.php/Multiboot_USB_drive#Arch_Linux_monthly_release
# root to be set to the partition where the ISO is (/dev/sda4 == (hd0,4)), so that GRUB can pass all relative paths correctly

menuentry 'ARCH ISO' --class arch {
  set root=(hd0,4)
  set isofile=/distros/archlinux-2019.08.01-x86_64.iso
  loopback loop $isofile
  linux (loop)/arch/boot/x86_64/vmlinuz img_dev=$imgdevpath img_loop=$isofile earlymodules=loop
  initrd (loop)/arch/boot/intel_ucode.img (loop)/arch/boot/amd_ucode.img (loop)/arch/boot/x86_64/archiso.img
}

According to your needs, you can change the ISO filename to your current one and the partition where your ISO is.

1.7 Partition the disks

Arch is installed after Lubuntu. Lubuntu already uses swap mount, so it can be shared among both operating systems. Just run the command

swapon <swap partition> 

For multi-boot, don't run mkswap otherwise it will change the UUID of the swap partition, which could increase the boot time of Lubuntu.

In order that GRUB can boot the Arch ISO or the installed Arch, you don't need to mount ESP (/dev/sda1) during Arch installation.

2.2 Install the base packages

pacstrap /mnt base does not install Grub, CPU microcode, wireless utilities. Run following command instead:

pacstrap /mnt base base-devel intel-ucode dialog wpa_supplicant wireless-tools iw grub networkmanager dhclient

Systemd-networkd with WPA_supplicant would be sufficient to set up wireless connection. The other wireless packages are installed just in case, they can be uninstalled later on.

3.8 Boot loader

Don't run grub-install, because there is already a GRUB which was installed by Lubuntu on /dev/sda1 and /dev/sda5. Instead, run grub-mkconfig /boot/grub.cfg.

Note: Actually, for a dual-boot computer, in which Arch Linux can be booted from the GRUB installed by the other operating system, you don't need GRUB at all. You can create a simple Grub file by yourself. For the setup above, create the following file /boot/grub.cfg in /dev/sda6 (hd0,gpt6). The <UUID> is the UUID of /dev/sda6. Even the --id option is not needed:
/boot/grub.cfg
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os --id 'gnulinux-simple-<UUID>' {
        insmod btrfs
        set root='hd0,gpt6'
        echo    'Loading Linux linux ...'
        linux   /boot/vmlinuz-linux root=UUID=<UUID> rw  loglevel=3 quiet
        echo    'Loading initial ramdisk ...'
        initrd  /boot/intel-ucode.img /boot/initramfs-linux.img
}
submenu 'Advanced options for Arch Linux' --id 'gnulinux-advanced-<UUID>' {
        menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os --id 'gnulinux-linux-advanced-<UUID>' {
                set root='hd0,gpt6'
                echo    'Loading Linux linux ...'
                linux   /boot/vmlinuz-linux root=UUID=<UUID> rw  loglevel=3 quiet
                echo    'Loading initial ramdisk ...'
                initrd  /boot/intel-ucode.img /boot/initramfs-linux.img
        }
        menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os --id 'gnulinux-linux-fallback-<UUID>' 
{
                set root='hd0,gpt6'
                echo    'Loading Linux linux ...'
                linux   /boot/vmlinuz-linux root=UUID=<UUID> rw  loglevel=3 quiet
                echo    'Loading initial ramdisk ...'                                                          
                initrd  /boot/initramfs-linux-fallback.img                                                     
        }                                                                                                      
}

The GRUB file which is manually created like the above is safer, because the GRUB configuration file created automatically by the GRUB of Arch might not be parsed correctly by the GRUB of other operating system. In the setup which is described here, Lubuntu 19.04 had GRUB 2.02 (which reads the /boot/grub.cfg file of Arch Linux), whereas Arch Linux had GRUB 2.04 (this GRUB generates by its grub-mkconfig script this file). GRUB config file which is manually created is so simply that it must be able to work without any problem in any release of GRUB.

The generated GRUB configuration file above (located in /dev/sda6 - /boot/cfg) is called by the GRUB configuration file installed by the Lubuntu environment (located in /dev/sda5 /boot/grub/grub.cfg). Go back to Lubuntu and create following file:

/etc/grub.d/26_archdisk
#!/bin/sh
exec tail -n +3 $0

menuentry 'Arch Linux' --class arch {
  set root=(hd0,6)
  configfile /boot/grub.cfg
}

Run in Lubuntu sudo update-grub. /boot/grub/grub.cfg will be updated. Now reboot. GRUB will be started, which was installed by Lubuntu. In GRUB menu you will see Arch Linux.

Setting up an internet connection with WPA Supplicant, systemd-networkd and systemd-resolved

Right after the Arch Linux installation, the session will not have a network access. Below a procedure is described how to set up internet connection for the computer with the wireless router using WPA Supplicant, systemd-networkd and systemd-resolved.

Introduction

The services WPA Supplicant, systemd-networkd and systemd-resolved are loaded but they are inactive (dead), i.e. disabled.

Step 1: Create a WPA Supplicant configuration file

The file will have the name /etc/wpa_supplicant/wpa_supplicant-<interface>.conf. There many ways how to find out the wireless interface of your computer. One way is the command ip link:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether ec:f4:bb:60:cc:1c brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether <mac address> brd ff:ff:ff:ff:ff:ff

The wireless interface names start with "wl". In this example it is wlp2s0.

/etc/wpa_supplicant/wpa_supplicant-wlp2s0.conf
ctrl_interface=DIR=/run/wpa_supplicant
ap_scan=1

Now generate the network profile for the SSID (access point) with the name <SSID> and password <password>:

wpa_passphrase <SSID> <password> >> /etc/wpa_supplicant/wpa_supplicant-wlp2s0.conf

Please note the redirection operator >>. The output of the command is appended so that the code part above is not deleted.

Now start the WPA supplicant service:

systemctl start wpa_supplicant@wlp2s0

Run the following command, so that this service is sarted after each reboot:

systemctl enable wpa_supplicant@wlp2s0

Step 2: Create a network file to connect systemd-networkd service to your wireless network

This file serves the settings so that an IP address can be assigned to your computer by the wireless router.

In this example the name 25-wireless.network is chosen. You can use any filename here:

/etc/systemd/network/25-wireless.network
[Match]
Name=wl*

[Network]
DHCP=yes
IPv6PrivacyExtensions=kernel

Step 3: Symbolic link to the DNS stub of the systemd-resolved service for DNS resolution

This step is needed, otherwise your computer will have internet access only using IP addresses. With this step, DNS names can be resolved as well, i.e. http://google.com etc.

ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Step 4: Enable all the remaining services

systemctl start systemd-resolved
systemctl enable systemd-resolved
systemctl start systemd-networkd
systemctl enable systemd-networkd

After this step, you should have a full internet connection. To test it, you can ping any web address:

# ping ieee.org -c 2
PING ieee.org (140.98.193.152) 56(84) bytes of data.
64 bytes from training.ieee.org (140.98.193.152): icmp_seq=1 ttl=241 time=103 ms
64 bytes from training.ieee.org (140.98.193.152): icmp_seq=2 ttl=241 time=103 ms

--- ieee.org ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 102.785/102.857/102.929/0.072 ms

Miscellaneous

  • In Connman Wiki, the advantage of Iwd over WPA_supplicant is mentioned: Advantage of using iwd instead of wpa_supplicant is, that the ping times seem to be much more consistent and the connection seems to be more reliable. . Actually this information belongs to iwd.