The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Rootfs over encrypted lvm"
m (→Load Funtoo: add dmtab =D) |
m (declutter, add some undead usb services, move the grub configuration much much closer to a known working line.... this SHOULD be the first working configuration since the 2018 edits... now that we have a working system, we can refine the process.) |
||
Line 1: | Line 1: | ||
This howto describes how to setup LVM and | This howto describes how to setup LVM, swap, and root with dmcrypt LUKS. It is a standalone installation walk through, based on the official installations finished product. boot is not encrypted. | ||
== Prepare the hard drive and partitions == | == Prepare the hard drive and partitions == | ||
Line 68: | Line 66: | ||
Unlock the volume: | Unlock the volume: | ||
{{console|body= | {{console|body= | ||
# ##i##cryptsetup luksOpen /dev/sdc3 dmcrypt_root | ###i##cryptsetup luksOpen /dev/sdc3 dmcrypt_root | ||
}} | }} | ||
== Create logical volumes == | == Create logical volumes == | ||
{{console|body= | {{console|body= | ||
# ##i##pvcreate /dev/mapper/dmcrypt_root | ###i## pvcreate /dev/mapper/dmcrypt_root | ||
# ##i##vgcreate vg /dev/mapper/dmcrypt_root | ###i## vgcreate vg /dev/mapper/dmcrypt_root | ||
# ##i##lvcreate -L2G --name swap vg | ###i## lvcreate -L2G --name swap vg | ||
# ##i##lvcreate -l 100%FREE --name root vg | ###i## lvcreate -l 100%FREE --name root vg | ||
}} | }} | ||
=== Create a filesystem on volumes === | === Create a filesystem on volumes === | ||
{{console|body= | {{console|body= | ||
###i## mkfs.vfat -F 32 /dev/sdc2 | ###i## mkfs.vfat -F 32 /dev/sdc2 | ||
###i## fatlabel /dev/sdc2 "BOOT" | ###i## fatlabel /dev/sdc2 "BOOT" | ||
# ##i##mkswap /dev/mapper/vg-swap | ###i## mkswap /dev/mapper/vg-swap | ||
# ##i##mkfs.ext4 /dev/mapper/vg-root | ###i## mkfs.ext4 /dev/mapper/vg-root | ||
}} | }} | ||
=== | === Mount your partitions === | ||
{{console|body= | {{console|body= | ||
# ##i##swapon /dev/mapper/vg-swap | ###i## swapon /dev/mapper/vg-swap | ||
# ##i##mkdir /mnt/funtoo | ###i## mkdir /mnt/funtoo | ||
# ##i##mount /dev/mapper/vg-root /mnt/funtoo | ###i## mount /dev/mapper/vg-root /mnt/funtoo | ||
# ##i##mkdir /mnt/funtoo/boot | ###i## mkdir /mnt/funtoo/boot | ||
# ##i##mount /dev/sdc2 /mnt/funtoo/boot | ###i## mount /dev/sdc2 /mnt/funtoo/boot | ||
}} | }} | ||
Line 128: | Line 128: | ||
*set cloudflare dns resolution for installing: | *set cloudflare dns resolution for installing: | ||
*Set yo time zone: | *Set yo time zone: | ||
{{console|body= | {{console|body= | ||
###i## passwd | ###i## passwd | ||
Line 136: | Line 137: | ||
*Deploy your fstab: | *Deploy your fstab: | ||
{{console|body= | {{console|body= | ||
###i## cat > /etc/fstab << "EOF" | ###i## cat > /etc/fstab << "EOF" | ||
Line 146: | Line 148: | ||
*Deploy your crypttab: | *Deploy your crypttab: | ||
{{console|body= | {{console|body= | ||
###i## echo "dmcrypt_root PARTLABEL=FUNTOO none luks,discard" >> /etc/crypttab | ###i## echo "dmcrypt_root PARTLABEL=FUNTOO none luks,discard" >> /etc/crypttab | ||
Line 184: | Line 187: | ||
*merge stuff: | *merge stuff: | ||
{{console|body= | {{console|body= | ||
###i## emerge grub haveged intel-microcode linux-firmware eix cryptsetup lvm2 debian-sources debian-sources-lts && emerge -vuND @world | ###i## emerge grub haveged intel-microcode linux-firmware eix cryptsetup lvm2 debian-sources debian-sources-lts && emerge -vuND @world | ||
Line 193: | Line 197: | ||
###i## rc-update add dmcrypt sysinit | ###i## rc-update add dmcrypt sysinit | ||
###i## rc-update add lvm sysinit | ###i## rc-update add lvm sysinit | ||
###i## rc-update add haveged && rc-update add gpm && rc-update add busybox-ntpd | |||
}} | }} | ||
Line 202: | Line 207: | ||
== Bootloader Configuration == | == Bootloader Configuration == | ||
=== /etc/boot.conf === | === /etc/boot.conf === | ||
{{warning|the bootloader configuration is | {{warning|the bootloader configuration is untested with partlabel, but known working under uuid.}} | ||
<pre> | <pre> | ||
boot { | boot { | ||
Line 212: | Line 218: | ||
kernel kernel[-v] | kernel kernel[-v] | ||
initrd initramfs[-v] | initrd initramfs[-v] | ||
params += crypt_root=PARTLABEL=FUNTOO dolvm luks=yes real_root=/dev/mapper/vg-root ro rootfstype=ext4 resume=swap:/dev/mapper/vg-swap | |||
params += crypt_root=PARTLABEL=FUNTOO dolvm luks=yes real_root=/dev/mapper/vg-root | |||
} | } | ||
</pre> | </pre> | ||
Line 242: | Line 233: | ||
=== EFI from Legacy === | === EFI from Legacy === | ||
*manually make efi directory: | *manually make efi directory: | ||
*remount /dev/sdc2 to /boot/efi: | *remount /dev/sdc2 to /boot/efi: | ||
Line 250: | Line 242: | ||
###i## grub-install --target=x86_64-efi /boot/efi | ###i## grub-install --target=x86_64-efi /boot/efi | ||
}} | }} | ||
=== EFI from EFI === | === EFI from EFI === | ||
Line 258: | Line 251: | ||
}} | }} | ||
== Final steps == | === Final steps === | ||
exit chroot, unmount | exit chroot, unmount, and close encrypted drive. | ||
{{console|body= | {{console|body= | ||
###i## exit | ###i## exit | ||
###i## swapoff /dev/dm-1 | ###i## swapoff /dev/dm-1 | ||
###i## cd .. | ###i## cd .. | ||
###i## umount -lR funtoo | ###i## umount -lR funtoo | ||
# ##i##vgchange -a n | ###i## vgchange -a n | ||
# ##i##cryptsetup luksClose dmcrypt_root | ###i## cryptsetup luksClose dmcrypt_root | ||
}} | }} | ||
Line 279: | Line 268: | ||
{{console|body= | {{console|body= | ||
# ##i##cryptsetup luksChangeKey /dev/ | # ##i##cryptsetup luksChangeKey /dev/sdx3 | ||
}} | }} | ||
You'll be prompted to enter in the existing passphrase first, then to enter in your new passphrase. | You'll be prompted to enter in the existing passphrase first, then to enter in your new passphrase. | ||
You will not be asked to confirm your new passphrase, so be careful when running this operation. | You will not be asked to confirm your new passphrase, so be careful when running this operation. | ||
== Additional links and information == | == Additional links and information == |
Revision as of 03:24, November 30, 2020
This howto describes how to setup LVM, swap, and root with dmcrypt LUKS. It is a standalone installation walk through, based on the official installations finished product. boot is not encrypted.
Prepare the hard drive and partitions
- List the device to be partitioned, mine is on /dev/sdc
root # lsblk -o name,size,label,partlabel
Partition
root # cgdisk /dev/sdc
delete everything.
Command: new ↵ First sector: ↵ Last sector: +1M ↵ Hex Code: EF02 ↵ Enter name: BIOS Boot ↵
scroll down to large chunk of free space:
Command: new ↵ First sector: ↵ Last sector: +128M ↵ Hex Code: EF00 ↵ Enter name: BOOT ↵
scroll down to large chunk of free space:
Command: new ↵ First sector: ↵ Last sector: ↵ Hex Code: 8304 ↵ Enter name: FUNTOO ↵
Disk Drive: /dev/sdc Size: 62333952, 29.7 GiB Part. # Size Partition Type Partition Name ---------------------------------------------------------------- 1007.0 KiB free space 1 1024.0 KiB BIOS boot partition BIOS Boot 2 256.0 MiB EFI System BOOT 3 29.5 GiB Linux x86-64 root (/) FUNTOO
Command: write ↵ Command: quit ↵
Encrypting the drive
root # cryptsetup luksFormat --label=FUNTOO /dev/sdc3
Unlock the volume
Unlock the volume:
root #cryptsetup luksOpen /dev/sdc3 dmcrypt_root
Create logical volumes
root # pvcreate /dev/mapper/dmcrypt_root root # vgcreate vg /dev/mapper/dmcrypt_root root # lvcreate -L2G --name swap vg root # lvcreate -l 100%FREE --name root vg
Create a filesystem on volumes
root # mkfs.vfat -F 32 /dev/sdc2 root # fatlabel /dev/sdc2 "BOOT" root # mkswap /dev/mapper/vg-swap root # mkfs.ext4 /dev/mapper/vg-root
Mount your partitions
root # swapon /dev/mapper/vg-swap root # mkdir /mnt/funtoo root # mount /dev/mapper/vg-root /mnt/funtoo root # mkdir /mnt/funtoo/boot root # mount /dev/sdc2 /mnt/funtoo/boot
Get Funtoo Gnome
You can pull your Subarches gnome tarball if you wish:
root # cd /mnt/funtoo root # wget https://build.funtoo.org/1.4-release-std/x86-64bit/generic_64/gnome-latest.tar.xz root # tar --numeric-owner --xattrs --xattrs-include='*' -xpf *gnome* && rm -f *gnome*
Load Funtoo
- expand your run tmpfs to be half of your ram:
root # mount -t tmpfs tmpfs /run
- mount up:
root # cd /mnt/funtoo && mount -t proc none proc mount --rbind /sys sys mount --rbind /dev dev mount --rbind /run run
- chroot in:
root # cd /mnt/funtoo && env -i HOME=/root TERM=$TERM chroot . bash -l
- Set yo password:
- set yo hostname:
- set cloudflare dns resolution for installing:
- Set yo time zone:
root # passwd root # echo 'hostname="crypto"' > /etc/conf.d/hostname root # echo "nameserver 1.1.1.1" > /etc/resolv.conf root # ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime
- Deploy your fstab:
root # cat > /etc/fstab << "EOF" LABEL=BOOT /boot vfat noauto,noatime 1 2 /dev/mapper/vg-swap none swap sw 0 0 /dev/mapper/vg-root / ext4 noatime,nodiratime,defaults 0 1 tmpfs /run tmpfs rw,nodev,nosuid 0 0 EOF
- Deploy your crypttab:
root # echo "dmcrypt_root PARTLABEL=FUNTOO none luks,discard" >> /etc/crypttab
- compile in ram:
root # echo 'PORTAGE_TMPDIR="/run"' > /etc/portage/make.conf
- Sync:
root # ego sync
- Deploy your ego profile:
root # ego profile mix-in encrypted-root
- Deploy your package.use file:
root # cat > /etc/portage/package.use << "EOF" sys-kernel/debian-sources lvm luks sys-kernel/debian-sources-lts lvm luks sys-boot/grub device-mapper sys-fs/lvm2 static-libs sys-kernel/genkernel cryptsetup dev-libs/openssl static-libs dev-libs/json-c static-libs app-crypt/argon2 static-libs dev-libs/popt static-libs sys-fs/cryptsetup static dev-libs/libgpg-error static-libs sys-kernel/linux-firmware initramfs EOF
- merge stuff:
root # emerge grub haveged intel-microcode linux-firmware eix cryptsetup lvm2 debian-sources debian-sources-lts && emerge -vuND @world
- add required services:
root # rc-update add device-mapper sysinit root # rc-update add dmcrypt sysinit root # rc-update add lvm sysinit root # rc-update add haveged && rc-update add gpm && rc-update add busybox-ntpd
- deploy dmtab:
root # dmsetup table >> /etc/dmtab
Bootloader Configuration
/etc/boot.conf
the bootloader configuration is untested with partlabel, but known working under uuid.
boot { generate grub default "Funtoo Linux" timeout 3 } "Funtoo Linux" { kernel kernel[-v] initrd initramfs[-v] params += crypt_root=PARTLABEL=FUNTOO dolvm luks=yes real_root=/dev/mapper/vg-root ro rootfstype=ext4 resume=swap:/dev/mapper/vg-swap }
root # ego boot update
GRUB
- Install grub in legacy mode:
root # grub-install --target=i386-pc /dev/sdc root # ego boot update
EFI from Legacy
- manually make efi directory:
- remount /dev/sdc2 to /boot/efi:
- install efi images:
root # mkdir /boot/efi root # mount /dev/sdc2 /boot/efi root # grub-install --target=x86_64-efi /boot/efi
EFI from EFI
root #mount -o remount,rw /sys/firmware/efi/efivars root #grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sdc root #ego boot update
Final steps
exit chroot, unmount, and close encrypted drive.
root # exit root # swapoff /dev/dm-1 root # cd .. root # umount -lR funtoo root # vgchange -a n root # cryptsetup luksClose dmcrypt_root
management
Change your LUKs-encrypted drive's passphrase
You may want to change your encrypted volume’s passphrase or password from time to time. To do so, run the following commands in the console as root:
root # cryptsetup luksChangeKey /dev/sdx3
You'll be prompted to enter in the existing passphrase first, then to enter in your new passphrase. You will not be asked to confirm your new passphrase, so be careful when running this operation.