Warning: THE VOID WIKI IS DEPRECATED. It is no longer being maintained, contains outdated and incorrect information, and will eventually be shut down. Please refer to the Void Handbook, https://docs.voidlinux.org/, for the official documentation. If you can't find the information you're seeking, please raise an issue at https://github.com/void-linux/void-docs/issues

Difference between revisions of "Installation on UEFI, via chroot"

From Void Linux Wiki
Jump to navigation Jump to search
m (Fixed repository URLs to the new location. Fixed typo.)
(Remove contents, direct readers to Handbook.)
Tag: Replaced
Line 1: Line 1:
== First steps ==
As this wiki is deprecated, and will soon disappear, please refer to [https://docs.voidlinux.org/installation/guides/chroot.html the "Installation via chroot (x86/x86_64)" section of the Void Handbook].
To begin, after booting from the Void Live CD, we need to install '''GPTFDisk''' to write our partitions:
<pre>$ sudo su
# xbps-install gptfdisk</pre>
Have a look at the disk we're formatting and installing to, like so:
<pre># lsblk
sda          8:0    0  477G  0 disk</pre>
We'll can use '''fdisk''' to create and write our GPT partition table:
<pre># fdisk /dev/sda
> g
> w</pre>
With our GPT partition table written, we'll can use GPTFDisk's '''cgdisk''' utility to write our partitions.
<pre># cgdisk /dev/sda</pre>
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.
Sometimes, we might be installing "over" previously used drive, that was partitioned in different style (like MBR). In that case it is often easier to use '''cfdisk''' with <code>-z</code> (zero-out) flag that will allow us to combine two previous steps into one:
<pre># cfdisk -z /dev/sda
┌ Select label type ───┐
│ gpt                  │
│ dos                  │
│ sgi                  │
│ sun                  │
By selecting <code>gpt</code> we ensure current scheme is "zapped" and overwritten with proper GPT structures.
What you see below shows separate partitions for <code>/boot</code>, <code>/boot/efi</code>, <code>/</code>, <code>/home</code>, <code>/var</code> and <code>/tmp</code> edited in <code>cgdisk</code>. You might just as well use only three, if you like (for <code>/boot</code>, <code>boot/efi</code>, and <code>/</code>). The sizes are also a matter of discretion; most won't need so much space for <code>/boot</code>, 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.
<pre>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</pre>
Also notice, that <code>cgdisk</code> is only tool that allows us to assign '''GPT partition labels''' (these are very different from filesystem labels) comfortably using TUI interface (<code>fdisk</code> is command oriented and <code>cfdisk</code> is missing this option).
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:
<pre># lsblk</pre>
Your list should now look something akin to this:
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</pre>
Now we need to create the appropriate filesystems on the newly created partitions.
<pre># 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</pre>
Activate our swap partition:
<pre># mkswap /dev/sda3</pre>
We're now ready to mount the volumes, making any necessary mount point directories along the way (the sequence is important, yes):
<pre># 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</pre>
== Installing Void ==
Whenever you perform an installation of an architecture different to the one you are running on right now, export <code>XBPS_ARCH</code> accordingly, so that xbps-install fetches the files for the desired arch, see the manpage for details.
example: <code># export XBPS_ARCH=x86_64-musl</code>
Now, we install Void and GRUB to the mounted filesystem:
* glibc: <pre># xbps-install -S -R http://alpha.de.repo.voidlinux.org/current -r /mnt base-system grub-x86_64-efi</pre>
* musl-libc: <pre># export XBPS_ARCH=x86_64-musl && xbps-install -S -R http://alpha.de.repo.voidlinux.org/current/musl -r /mnt base-system grub-x86_64-efi</pre>
Upon completion of the install, we set up our chroot jail, and chroot into our mounted filesystem:
<pre># 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
# cp -L /etc/resolv.conf /mnt/etc/
# cd /mnt
# chroot /mnt</pre>
In order to verify our install, we can have a look at the directory structure:
<pre># ls -la</pre>
The output should look something akin to the following:
<pre>total 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 -&gt; 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 -&gt; usr/lib
lrwxrwxrwx  1 root root    9 Jan 17 15:26 lib32 -&gt; usr/lib32
lrwxrwxrwx  1 root root    7 Jan 17 15:26 lib64 -&gt; 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 -&gt; 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</pre>
While chrooted, we create the password for the root user, and set root access permissions:
<pre># passwd root
# chown root:root /
# chmod 755 /</pre>
Create the hostname for the new install:
<pre># echo &lt;HOSTNAME&gt; &gt; /etc/hostname</pre>
Edit our rc.conf file, like so:
<pre># vi /etc/rc.conf
# Set RTC to UTC or localtime.
# Set timezone, availables timezones at /usr/share/zoneinfo.
# Keymap to load, see loadkeys(8).
# Console font to load, see setfont(8).
# Console map to load, see setfont(8).
# Font unimap to load, see setfont(8).
# Kernel modules to load, delimited by blanks.
In order to edit our fstab file, we need to grab the UUIDs for our volumes:
<pre># blkid</pre>
Which should return something akin to the following:
<pre>/dev/sda1: UUID=&quot;C071-6887&quot; TYPE=&quot;vfat&quot; PARTLABEL=&quot;EFI&quot; PARTUUID=&quot;b35386b0-30d8-4d9d-9bc1-b02e78a2c708&quot;
/dev/sda2: UUID=&quot;d7d2ddae-cb94-4aea-bc4f-4784d6b3cc8e&quot; TYPE=&quot;xfs&quot; PARTLABEL=&quot;GRUB&quot; PARTUUID=&quot;824a24e5-5795-4a98-9977-1e534e480fa6&quot;
/dev/sda3: UUID=&quot;cfb8be30-1866-44a6-bdf5-60ced2a454f4&quot; PARTLABEL=&quot;swap&quot; PARTUUID=&quot;e4f25f1c-f74b-487b-9413-0f43a1ac1a99&quot;
/dev/sda4: UUID=&quot;97060d6a-039e-469f-b0aa-2fca2e33f464&quot; TYPE=&quot;xfs&quot; PARTLABEL=&quot;tmp&quot; PARTUUID=&quot;12e852ce-79cc-4447-a8a0-d93c41b1967a&quot;
/dev/sda5: UUID=&quot;4fb9395f-42c2-4b27-8545-1e9c1703c94d&quot; TYPE=&quot;xfs&quot; PARTLABEL=&quot;var&quot; PARTUUID=&quot;77a281f8-7c0a-41d0-9a50-91104411bc9e&quot;
/dev/sda6: UUID=&quot;dcdd0c5a-020b-4167-a10d-cb81d71e2ae6&quot; TYPE=&quot;xfs&quot; PARTLABEL=&quot;Void&quot; PARTUUID=&quot;79303ba0-9be9-4905-a382-e90ff908a43f&quot;
/dev/sda7: UUID=&quot;4a24a9e9-3c04-4aa5-826b-da2122347094&quot; TYPE=&quot;xfs&quot; PARTLABEL=&quot;The Big Box&quot; PARTUUID=&quot;3ffd3dd1-0d69-4839-b1ee-320f9d7162c6&quot;</pre>
Once we have our UUIDs , we edit our <code>fstab</code> file, like so (with noatime if we are installing to an SSD):
<pre># vi /etc/fstab
# See fstab(5).
# &lt;file system&gt; &lt;dir&gt;  &lt;type&gt;  &lt;options&gt;              &lt;dump&gt;  &lt;pass&gt;
#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</pre>
Next, we need to set our locale. We do this by uncommenting our locale in <code>/etc/default/libc-locales</code>:
<pre># 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:
<pre># xbps-reconfigure -f glibc-locales</pre>
We now edit our <code>dracut.conf</code> file, enabling hostonly and adding support for our <code>/tmp</code> directory:
<pre># 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
# 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.
# dracut modules to omit
# dracut modules to add to the default
# additional kernel modules to the default
# list of kernel filesystem modules to be included in the generic initramfs
# build initrd only to boot current hardware
# install local /etc/mdadm.conf
# install local /etc/lvm/lvm.conf
# A list of fsck tools to install. If it's not specified, module's hardcoded
# default is used, currently: &quot;umount mount /sbin/fsck* xfs_db xfs_check
# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck&quot;. The installation is
# opportunistic, so non-existing tools are just ignored.
# inhibit installation of any fsck tools
# mount / and /usr read-only by default
# set the directory for temporary files
# default: /var/tmp
We need to have a look at /lib/modules to get our Linux kernel version
<pre># cd /lib/modules
# ls -la</pre>
Which should return something akin to:
<pre>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</pre>
Once <code>dracut.conf</code> has been edited, we can update dracut:
<pre># dracut --force --hostonly --kver 4.0.4_1</pre>
== Final touches ==
We are now ready to install GRUB and configure our install:
<pre># grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --boot-directory=/boot --recheck --debug
# xbps-reconfigure -f linux4.0</pre>
Upon successful install and configure, we can exit both chroot and sudo, unmount our filesystem, and boot into our new Void install.
<pre>$ exit
# exit
# sudo umount -R /mnt
# sudo reboot</pre>
'''Congratulations, you've entered the void!'''
== Troubleshooting ==
=== If GRUB cannot be found (a note about UEFI) ===
Void's Grub install, by default, installs the *.efi file as <code>/boot/efi/EFI/GRUB/grubx64.efi</code>.
However, some UEFI implementations look for the file by a different name, and in a different subdirectory.
Copy <code>grubx64.efi</code> to another location, expected by some implementations:
<pre>mkdir /boot/efi/EFI/BOOT
cp -p /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.efi</pre>
Alternatively, some implementations are case-sensitive, and seek the same file, with a lower-case name:
<pre>mkdir /boot/efi/EFI/BOOT
cp -p /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi</pre>
=== If GRUB is failing to install and (or) dracut is failing to build ramdisk ===
If you are getting <code>dracut</code> failures when building initial ramdisk (like these):
dracut-install: Environment DESTROOTDIR or argument -D is set to '/tmp/dracut.MBFVRU/initramfs': No such file or directory
Or if <code>grub-install</code> fails like this:
Installing for x86_64-efi platform.
grub-install: error: failed to get canonical path of `/boot/grub'.
at final stages of this guide, it means, that you probably forgot to mount <code>/proc</code> and (or)
<code>/sys</code> filesystems into your chroot. Exit chroot, mount these filesystems and try again.
This can sometimes happen, especially if you are assembling chroot by hand.
Ramdisk should now build and Grub should install.

Latest revision as of 08:29, 19 June 2020

As this wiki is deprecated, and will soon disappear, please refer to the "Installation via chroot (x86/x86_64)" section of the Void Handbook.