parted -a optimal /dev/vda
unit mib
mklabel gpt
mkpart primary fat32 11024name 1 boot
set1 BOOT on
mkpart primary 1024 -1
name 2 lvm
set2 LVM on
quit
##
Filesystem stuff
Format the boot partition (which later contains grub and kernel files) as fat32.
1
mkfs.vfat -F32 /dev/vda1
Encrypt the root partition.
Cipher methods or key size can be set with -c <cipher> and/or -s <keysize>, the default settings should be enough for most people ;)
1
2
modprobe dm-crypt
cryptsetup luksFormat /dev/vda2
Open the freshly encrypted partition.
1
cryptsetup luksOpen /dev/vda2 lvm
Create the LVM physical volume group.
1
lvm pvcreate /dev/mapper/lvm
Create a volume group (vg0).
1
vgcreate vg0 /dev/mapper/lvm
Create the home and root logical volume (notice the lowercase -l in the second command).
mkdir /mnt/gentoo
mount /dev/mapper/vg0-root /mnt/gentoo
mkdir /mnt/gentoo/home
mount /dev/mapper/vg0-home /mnt/gentoo/home
Download a stage3 from gentoo.org tarball to /mnt/gentoo.
1
2
3
cd /mnt/gentoo
wget https://distfiles.gentoo.org/releases/amd64/autobuilds/20230917T164636Z/stage3-amd64-desktop-openrc-20230917T164636Z.tar.xz
tar xvJpf stage3-amd64-desktop-openrc-20230917T164636Z.tar.xz --xattrs --numeric-owner
##
Preparing the filesystem(s)
Mount all necessary filesystems.
1
2
3
4
5
6
7
8
mount -t proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
mount -t tmpfs -o nosuid,nodev,noexec shm /dev/shm
chmod 1777 /dev/shm