Installation on UEFI, via chroot

From Void Linux Wiki
Jump to: navigation, search

To begin, after booting from the Void Live CD, we need to install GPTFDisk to write our partitions:

$ sudo su
# xbps-install gptfdisk

Have a look at the disk we're formatting and installing to, like so:

# lsblk

NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0   477G  0 disk

We'll use fdisk to write our GPT partition table:

# fdisk /dev/sda
> g
> w

With our partition table written, we'll use GPTFDisk's cgdisk utility to write our partitions.

# cgdisk /dev/sda

For each new partition created, you will be prompted for a start sector (for which you can simply press [enter]), a size (in kibibytes, mebibytes, or gibibytes), and a type (as hex code). Our EFI partition must come first, and should be of type ef00. Swap is 8200, and the rest, 8300.

What you see below shows separate partitions for /boot, /boot/efi, /, /home, /var and /tmp.
You might just as well use only three, if you like (for /boot, boot/efi, and /).
The sizes are also a matter of discretion; most won't need so much space for /boot, but if you plan on rolling your own kernels, the extra space is necessary.

If you decide to partition differently from this example, you will, of course, need to adjust the mounting instructions listed further on.

Part.     #     Size        Partition Type            Partition Name
----------------------------------------------------------------
1               200.0 MiB   EFI System                EFI
2               550.0 MiB   Linux filesystem          GRUB
3               2.0 GiB     Linux swap                swap
4               2.0 GiB     Linux filesystem          tmp
5               6.0 GiB     Linux filesystem          var
6               12.0 GiB    Linux filesystem          Void
7               454.2 GiB   Linux filesystem          The Big Box

After setting up our partitions, we'll select 'Write', then 'Verify', to check for any errors, and, finally, 'Quit'.

Run lsblk to verify the successful creation of our partitions:

# lsblk

Your list should now look something akin to this:

NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 238.5G  0 disk
 sda1         8:1    0   200M  0 part
 sda2         8:2    0   550M  0 part
 sda3         8:3    0     2G  0 part
 sda4         8:4    0     2G  0 part
 sda5         8:5    0     6G  0 part
 sda6         8:6    0    12G  0 part
 sda7         8:7    0 454.2G  0 part

Now we need to create the appropriate filesystems on the newly created partitions.

# mkfs.vfat -F32 /dev/sda1
# mkfs.xfs /dev/sda2
# mkfs.xfs /dev/sda4
# mkfs.xfs /dev/sda5
# mkfs.xfs /dev/sda6
# mkfs.xfs /dev/sda7

Activate our swap partition:

# mkswap /dev/sda3

We're now ready to mount the volumes, making any necessary mount point directories along the way (the sequence is important, yes):

# mount /dev/sda6 /mnt
# mkdir /mnt/boot
# mkdir /mnt/tmp
# mkdir /mnt/var

# mount /dev/sda2 /mnt/boot
# mkdir /mnt/boot/efi 

# mount /dev/sda1 /mnt/boot/efi
# mount /dev/sda4 /mnt/tmp
# mount /dev/sda5 /mnt/var

Now, we install Void and GRUB to the mounted filesystem:

# xbps-install -S -R http://repo3.voidlinux.eu/current -r /mnt base-system grub-x86_64-efi

Upon completion of the install, we set up our chroot jail, and chroot into our mounted filesystem:

# mount -t proc proc /mnt/proc
# mount -t sysfs sys /mnt/sys
# mount -o bind /dev /mnt/dev
# mount -t devpts pts /mnt/dev/pts
# cd /mnt
# chroot /mnt

In order to verify our install, we can have a look at the directory structure:

# ls -la

The output should look something akin to the following:

otal 12
drwxr-xr-x 16 root root 4096 Jan 17 15:27 .
drwxr-xr-x  3 root root 4096 Jan 17 15:16 ..
lrwxrwxrwx  1 root root    7 Jan 17 15:26 bin -> usr/bin
drwxr-xr-x  4 root root  127 Jan 17 15:37 boot
drwxr-xr-x  2 root root   17 Jan 17 15:26 dev
drwxr-xr-x 26 root root 4096 Jan 17 15:27 etc
drwxr-xr-x  2 root root    6 Jan 17 15:26 home
lrwxrwxrwx  1 root root    7 Jan 17 15:26 lib -> usr/lib
lrwxrwxrwx  1 root root    9 Jan 17 15:26 lib32 -> usr/lib32
lrwxrwxrwx  1 root root    7 Jan 17 15:26 lib64 -> usr/lib
drwxr-xr-x  2 root root    6 Jan 17 15:26 media
drwxr-xr-x  2 root root    6 Jan 17 15:26 mnt
drwxr-xr-x  2 root root    6 Jan 17 15:26 opt
drwxr-xr-x  2 root root    6 Jan 17 15:26 proc
drwxr-x---  2 root root   26 Jan 17 15:39 root
drwxr-xr-x  3 root root   17 Jan 17 15:26 run
lrwxrwxrwx  1 root root    8 Jan 17 15:26 sbin -> usr/sbin
drwxr-xr-x  2 root root    6 Jan 17 15:26 sys
drwxrwxrwt  2 root root    6 Jan 17 15:15 tmp
drwxr-xr-x 11 root root  123 Jan 17 15:26 usr
drwxr-xr-x 11 root root  150 Jan 17 15:26 var

While chrooted, we create the password for the root user, and set root access permissions:

# passwd root
# chown root:root /
# chmod 755 /

Create the hostname for the new install:

# echo <HOSTNAME> > /etc/hostname

Edit our rc.conf file, like so:

# vi /etc/rc.conf

HOSTNAME="<HOSTNAME>"

# Set RTC to UTC or localtime.
HARDWARECLOCK="UTC"

# Set timezone, availables timezones at /usr/share/zoneinfo.
TIMEZONE="America/Los_Angeles"

# Keymap to load, see loadkeys(8).
KEYMAP="us"

# Console font to load, see setfont(8).
#FONT="lat9w-16"

# Console map to load, see setfont(8).
#FONT_MAP=

# Font unimap to load, see setfont(8).
#FONT_UNIMAP=

# Kernel modules to load, delimited by blanks.
#MODULES=""

In order to edit our fstab file, we need to grab the UUIDs for our volumes:

# blkid

Which should return something akin to the following:

#/dev/sda1: UUID="C071-6887" TYPE="vfat" PARTLABEL="EFI" PARTUUID="b35386b0-30d8-4d9d-9bc1-b02e78a2c708"
#/dev/sda2: UUID="d7d2ddae-cb94-4aea-bc4f-4784d6b3cc8e" TYPE="xfs" PARTLABEL="GRUB" PARTUUID="824a24e5-5795-4a98-9977-1e534e480fa6"
#/dev/sda3: UUID="cfb8be30-1866-44a6-bdf5-60ced2a454f4" PARTLABEL="swap" PARTUUID="e4f25f1c-f74b-487b-9413-0f43a1ac1a99"
#/dev/sda4: UUID="97060d6a-039e-469f-b0aa-2fca2e33f464" TYPE="xfs" PARTLABEL="tmp" PARTUUID="12e852ce-79cc-4447-a8a0-d93c41b1967a"
#/dev/sda5: UUID="4fb9395f-42c2-4b27-8545-1e9c1703c94d" TYPE="xfs" PARTLABEL="var" PARTUUID="77a281f8-7c0a-41d0-9a50-91104411bc9e"
#/dev/sda6: UUID="dcdd0c5a-020b-4167-a10d-cb81d71e2ae6" TYPE="xfs" PARTLABEL="Void" PARTUUID="79303ba0-9be9-4905-a382-e90ff908a43f"
#/dev/sda7: UUID="4a24a9e9-3c04-4aa5-826b-da2122347094" TYPE="xfs" PARTLABEL="The Big Box" PARTUUID="3ffd3dd1-0d69-4839-b1ee-320f9d7162c6"

Once we have our UUIDs , we edit our fstab file, like so (with noatime if we are installing to an SSD):

# vi /etc/fstab

#
# See fstab(5).
#
# <file system> <dir>   <type>  <options>               <dump>  <pass>
#tmpfs           /tmp    tmpfs   defaults,nosuid,nodev   0       0t
UUID=dcdd0c5a-020b-4167-a10d-cb81d71e2ae6 / xfs rw,noatime,discard 0 1
UUID=d7d2ddae-cb94-4aea-bc4f-4784d6b3cc8e /boot xfs rw,noatime,discard 0 2
UUID=C071-6887 /boot/efi vfat rw,noatime,discard 0 2
UUID=97060d6a-039e-469f-b0aa-2fca2e33f464 /tmp xfs rw,noatime,discard,nosuid,nodev 0 2
UUID=4fb9395f-42c2-4b27-8545-1e9c1703c94d /var xfs rw,noatime,discard,nosuid,nodev 0 2
UUID=4a24a9e9-3c04-4aa5-826b-da2122347094 /home xfs rw,noatime,discard 0 2
UUID=cfb8be30-1866-44a6-bdf5-60ced2a454f4 swap swap rw,noatime,discard 0 0

Next, we need to set our locale.
We do this by uncommenting our locale in /etc/default/libc-locales:

# vi /etc/default/libc-locales
            
#en_NZ ISO-8859-1
#en_PH.UTF-8 UTF-8
#en_PH ISO-8859-1
#en_SG.UTF-8 UTF-8
#en_SG ISO-8859-1

en_US.UTF-8 UTF-8

#en_US ISO-8859-1
#en_ZA.UTF-8 UTF-8
#en_ZA ISO-8859-1
#en_ZM UTF-8
#en_ZW.UTF-8 UTF-8
#en_ZW ISO-8859-1
#es_AR.UTF-8 UTF-8
#es_AR ISO-8859-1
#es_BO.UTF-8 UTF-8
#es_BO ISO-8859-1
#es_CL.UTF-8 UTF-8
#es_CL ISO-8859-1
#es_CO.UTF-8 UTF-8
#es_CO ISO-8859-1
#es_CR.UTF-8 UTF-8
#es_CR ISO-8859-1
#es_CU UTF-8
...

Once we've established our locale, we're ready to configure:

# xbps-reconfigure -f glibc-locales

We now edit our dracut.conf file, enabling hostonly and adding support for our /tmp directory:

# vi /etc/dracut.conf

# PUT YOUR CONFIG HERE OR IN separate files named *.conf
# in /etc/dracut.conf.d
# SEE man dracut.conf(5)

# Sample dracut config file

#logfile=/var/log/dracut.log
#fileloglvl=6

# Exact list of dracut modules to use.  Modules not listed here are not going
# to be included.  If you only want to add some optional modules use
# add_dracutmodules option instead.
#dracutmodules+=""

# dracut modules to omit
#omit_dracutmodules+=""

# dracut modules to add to the default
#add_dracutmodules+=""

# additional kernel modules to the default
#add_drivers+=""

# list of kernel filesystem modules to be included in the generic initramfs
#filesystems+=""

# build initrd only to boot current hardware
hostonly="yes"

# install local /etc/mdadm.conf
#mdadmconf="no"

# install local /etc/lvm/lvm.conf
#lvmconf="no"

# A list of fsck tools to install. If it's not specified, module's hardcoded
# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check
# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is
# opportunistic, so non-existing tools are just ignored.
#fscks=""

# inhibit installation of any fsck tools
#nofscks="yes"

# mount / and /usr read-only by default
#ro_mnt="no"

# set the directory for temporary files
# default: /var/tmp
tmpdir=/tmp

We need to have a look at /lib/modules to get our Linux kernel version

# cd /lib/modules
# ls -la

Which should return something akin to:

drwxr-xr-x  3 root root   21 Jan 31 15:22 .
drwxr-xr-x 23 root root 8192 Jan 31 15:22 ..
drwxr-xr-x  3 root root 4096 Jan 31 15:22 4.0.4_1

Once dracut.conf has been edited, we can update dracut:

# dracut --force --hostonly '' 4.0.4_1

We are now ready to install GRUB and configure our install:

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --boot-directory=/boot --recheck --debug
# xbps-reconfigure -f linux4.0

Upon successful install and configure, we can exit both chroot and sudo, unmount our filesystem, and boot into our new Void install.

$ exit
# exit
# sudo umount -R /mnt
# sudo reboot

Congratulations, you've entered the void.

IF YOUR MACHINE DOES NOT DETECT VOID GRUB AS A BOOTABLE OPTION (A note about UEFI):

Void's Grub install, by default, installs the *.efi file as /boot/efi/EFI/GRUB/grubx64.efi
However, some UEFI implementations look for the file by a different name, and in a different subdirectory.

Copy grubx64.efi to another location, expected by some implementations:

mkdir /boot/efi/EFI/BOOT
cp -p /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.efi

Alternatively, some implementations are case-sensitive, and seek the same file, with a lower-case name:

mkdir /boot/efi/EFI/BOOT
cp -p /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi