Skip to content

Commit

Permalink
installation/guides: simplify chroot/fde guides with xgenfstab
Browse files Browse the repository at this point in the history
  • Loading branch information
classabbyamp committed Jan 12, 2025
1 parent 9de4b6b commit 200fa6d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 95 deletions.
98 changes: 26 additions & 72 deletions src/installation/guides/chroot.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ System Partition:
```

Initialize swap space, if desired, using
[mkswap(8)](https://man.voidlinux.org/mkswap.8).
[mkswap(8)](https://man.voidlinux.org/mkswap.8), and enable it with
[swapon(8)](https://man.voidlinux.org/swapon.8).

## Base Installation

Expand Down Expand Up @@ -133,33 +134,40 @@ Unpack the tarball into the newly configured filesystems:
# tar xvf void-<...>-ROOTFS.tar.xz -C /mnt
```

ROOTFS images generally contain out of date software, due to being a snapshot of
the time when they were built, and do not come with a complete `base-system`.
Update the package manager and install `base-system`:

```
# xbps-install -r /mnt -Su xbps
# xbps-install -r /mnt -u
# xbps-install -r /mnt base-system
# xbps-remove -r /mnt -R base-container-full
```

## Configuration

With the exception of the section "Install base-system (ROOTFS method only)",
the remainder of this guide is common to both the XBPS and ROOTFS installation
The remainder of this guide is common to both the XBPS and ROOTFS installation
methods.

### Entering the Chroot
### Configure Filesystems

[xchroot(1)](https://man.voidlinux.org/xchroot.1) (from `xtools`) can be used to
set up and enter the chroot. Alternatively, this can be [done
manually](../../config/containers-and-vms/chroot.md#manual-method).
The [fstab(5)](https://man.voidlinux.org/fstab.5) file can be automatically
generated from currently mounted filesystems using
[xgenfstab(1)](https://man.voidlinux.org/xgenfstab.1) (from `xtools`).

```
# xchroot /mnt /bin/bash
# xgenfstab -U /mnt > /mnt/etc/fstab
```

### Install base-system (ROOTFS method only)
### Entering the Chroot

ROOTFS images generally contain out of date software, due to being a snapshot of
the time when they were built, and do not come with a complete `base-system`.
Update the package manager and install `base-system`:
[xchroot(1)](https://man.voidlinux.org/xchroot.1) (from `xtools`) can be used to
set up and enter the chroot. Alternatively, this can be [done
manually](../../config/containers-and-vms/chroot.md#manual-method).

```
[xchroot /mnt] # xbps-install -Su xbps
[xchroot /mnt] # xbps-install -u
[xchroot /mnt] # xbps-install base-system
[xchroot /mnt] # xbps-remove base-container-full
# xchroot /mnt /bin/bash
```

### Installation Configuration
Expand Down Expand Up @@ -191,60 +199,6 @@ To set a root password, run:
[xchroot /mnt] # passwd
```

### Configure fstab

The [fstab(5)](https://man.voidlinux.org/fstab.5) file can be automatically
generated from currently mounted filesystems by copying the file `/proc/mounts`:

```
[xchroot /mnt] # cp /proc/mounts /etc/fstab
```

Remove lines in `/etc/fstab` that refer to `proc`, `sys`, `devtmpfs` and `pts`.

Replace references to `/dev/sdXX`, `/dev/nvmeXnYpZ`, etc. with their respective
UUID, which can be found by running
[blkid(8)](https://man.voidlinux.org/blkid.8). Referring to filesystems by their
UUID guarantees they will be found even if they are assigned a different name at
a later time. In some situations, such as booting from USB, this is absolutely
essential. In other situations, disks will always have the same name unless
drives are physically added or removed. Therefore, this step may not be strictly
necessary, but is almost always recommended.

Change the last zero of the entry for `/` to `1`, and the last zero of every
other line to `2`. These values configure the behaviour of
[fsck(8)](https://man.voidlinux.org/fsck.8).

For example, the partition scheme used throughout previous examples yields the
following `fstab`:

```
/dev/sda1 /boot/efi vfat rw,relatime,[...] 0 0
/dev/sda2 / ext4 rw,relatime 0 0
```

The information from `blkid` results in the following `/etc/fstab`:

```
UUID=6914[...] /boot/efi vfat rw,relatime,[...] 0 2
UUID=dc1b[...] / ext4 rw,relatime 0 1
```

Note: The output of `/proc/mounts` will have a single space between each field.
The columns are aligned here for readability.

Add an entry to mount `/tmp` in RAM:

```
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
```

If using swap space, add an entry for any swap partitions:

```
UUID=1cb4[...] swap swap rw,noatime,discard 0 0
```

### Enable services

Services can be [enabled](../../config/services/index.md#enabling-services)
Expand All @@ -262,7 +216,7 @@ to install GRUB onto your boot disk.
install GRUB to. For example:

```
[xchroot /mnt] # xbps-install grub
[xchroot /mnt] # xbps-install -S grub
[xchroot /mnt] # grub-install /dev/sda
```

Expand All @@ -272,7 +226,7 @@ optionally specifying a bootloader label (this label may be used by your
computer's firmware when manually selecting a boot device):

```
[xchroot /mnt] # xbps-install grub-x86_64-efi
[xchroot /mnt] # xbps-install -S grub-x86_64-efi
[xchroot /mnt] # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="Void"
```

Expand Down
44 changes: 21 additions & 23 deletions src/installation/guides/fde.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ meta-data=/dev/voidvm/home isize=512 agcount=4, agsize=2359040 blks
...
# mkswap /dev/voidvm/swap
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
# swapon /dev/voidvm/swap
```

## System installation
Expand Down Expand Up @@ -162,9 +163,23 @@ command for a UEFI system will be as follows.
# xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt base-system cryptsetup grub-x86_64-efi lvm2
```

When it's done, we can enter the chroot with
[`xchroot(1)`](https://man.voidlinux.org/xchroot.1) (from `xtools`) and finish
up the configuration. Alternatively, entering the chroot can be [done
## Configuration

### Filesystem Configuration

The [fstab(5)](https://man.voidlinux.org/fstab.5) file can be automatically
generated from currently mounted filesystems using
[xgenfstab(1)](https://man.voidlinux.org/xgenfstab.1) (from `xtools`).

```
# xgenfstab /mnt > /mnt/etc/fstab
```

### Entering the Chroot

We can enter the chroot with [`xchroot(1)`](https://man.voidlinux.org/xchroot.1)
(from `xtools`) and finish up the configuration. Alternatively, entering the
chroot can be [done
manually](../../config/containers-and-vms/chroot.md#manual-method).

```
Expand All @@ -175,33 +190,16 @@ manually](../../config/containers-and-vms/chroot.md#manual-method).
[xchroot /mnt] # echo voidvm > /etc/hostname
```

and, for glibc systems only:
### System Locale (glibc only)

For glibc systems only, generate locale files with:

```
[xchroot /mnt] # echo "LANG=en_US.UTF-8" > /etc/locale.conf
[xchroot /mnt] # echo "en_US.UTF-8 UTF-8" >> /etc/default/libc-locales
[xchroot /mnt] # xbps-reconfigure -f glibc-locales
```

### Filesystem configuration

The next step is editing `/etc/fstab`, which will depend on how you configured
and named your filesystems. For this example, the file should look like this:

```
# <file system> <dir> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
/dev/voidvm/root / xfs defaults 0 0
/dev/voidvm/home /home xfs defaults 0 0
/dev/voidvm/swap swap swap defaults 0 0
```

UEFI systems will also have an entry for the EFI system partition.

```
/dev/sda1 /boot/efi vfat defaults 0 0
```

### GRUB configuration

Next, configure GRUB to be able to unlock the filesystem. Add the following line
Expand Down

0 comments on commit 200fa6d

Please sign in to comment.