You are not logged in.
Hello, I'm trying to install Arch Linux on encrypted partition. I created one with cryptsetup and opened it, then I've created 2 partitions on /dev/mapper/cryptoroot as I'm planning to use hibernation (so here goes swap) and btrfs. I have to use partprobe to populate partitions map in kernel with:
partprobe /dev/mapper/cryptoroot
After that everything worked pretty great, Arch was installed, initramfs was generated. But when I'm trying to boot encrypt hook isn't calling partprobe on unlocked container which renders my system unbootable until I've added partprobe command into hook on the very last line of run_hook() function and rebuilt initramfs. After that system booted and everything is working great:
/dev/mapper/cryptoroot2 on /.snapshots type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache=v2,subvolid=260,subvol=/@snapshots)
/dev/mapper/cryptoroot2 on /data type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache=v2,subvolid=261,subvol=/@data)
/dev/mapper/cryptoroot2 on /var/lib/docker type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache=v2,subvolid=259,subvol=/@var_lib_docker)
/dev/mapper/cryptoroot2 on /home type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache=v2,subvolid=257,subvol=/@home)
/dev/mapper/cryptoroot2 on /var/log type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache=v2,subvolid=258,subvol=/@var_log)
(and cryptoroot1 is my swap).
I know that LVM should be (probably) the very proper way, but I'm using btrfs and do not actually want LVM as another layer on my disk. Also I want swap with exact size and also I do not want to play with swapfile on btrfs, I prefer use it as separate partition. How to properly handle such situation without modifying encrypt hook?
Last edited by PoZiTPoH (2021-01-03 17:27:54)
Offline
A partition table on anything other than directly on a disk is very uncommon and typically requires some effort to get it to work. There have been some discussions about GPT to plain dm-crypt: https://wiki.archlinux.org/index.php/Ta … m-crypt%22 and https://lists.archlinux.org/pipermail/a … 45968.html .
Since you want a simple solution that doesn't involve modifying the encrypt hook, I suggest:
Create two separate partitions on the disk, e.g. /dev/sda1 and /dev/sda2.
Create an encrypted container (LUKS or plain dm-crypt) on each of them and open it, e.g. /dev/mapper/cryptoroot and /dev/mapper/cryptswap.
Format /dev/mapper/cryptoroot with mkfs.btrfs and /dev/mapper/cryptswap with mkswap.
Configure mkinitcpio for a systemd-based initramfs and use the sd-encrypt (instead of encrypt) hook. sd-encrypt supports unlocking multiple devices and if any of them are encrypted with the same passphrase you will only need to input it once during boot.
Offline
I prefer use it as separate partition. How to properly handle such situation without modifying encrypt hook?
You should add a new hook that runs directly after the encrypt hook.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
A partition table on anything other than directly on a disk is very uncommon and typically requires some effort to get it to work.
The only effort is to run partprobe on unlocked container. That's it.
While sd-encrypt looks good I prefer much simplier solution that isn't requiring switching to systemd-based initramfs and reformatting my drive, so looks like the only solution is to make a custom hook which will call partprobe on unlocked device if there is gpt/mbr table.
Offline
Here we go, custom hook if someone else need: https://aur.archlinux.org/packages/mkin … partprobe/
Thanks for suggestions!
Offline
also I do not want to play with swapfile on btrfs, I prefer use it as separate partition.
Nowadays it's not playing, it's a proper way. This way you don't need to plain-dm the swap-partition.
Last edited by equalizer876 (2021-01-03 19:19:28)
Offline
PoZiTPoH wrote:also I do not want to play with swapfile on btrfs, I prefer use it as separate partition.
Nowadays it's not playing, it's a proper way. This way you don't need to plain-dm the swap-partition.
Why do I ever need to use plain-dm for swap if I can place it on normal LUKS partition together with other things (like I'm doing it now)? With my configuration I should enter password only once and still have swap and root encrypted. My problem wasn't about encryption at all, and I solve it with custom mkinitcpio hook which does partprobe after container unlocking.
And who told that using swapfile is a proper way to do swap? Can you show some proofs please?
Offline
Why do I ever need to use plain-dm for swap if I can place it on normal LUKS partition together with other things (like I'm doing it now)? With my configuration I should enter password only once and still have swap and root encrypted. My problem wasn't about encryption at all, and I solve it with custom mkinitcpio hook which does partprobe after container unlocking.
Did you create a physical volume (LVM) inside the LUKS container? Otherwise how could you put in 2 filesystems inside 1 LUKS container?
And who told that using swapfile is a proper way to do swap? Can you show some proofs please?
https://git.kernel.org/pub/scm/linux/ke … fdb210a2a7
Last edited by equalizer876 (2021-01-03 21:14:57)
Offline
Did you create a physical volume (LVM) inside the LUKS container? Otherwise how could you put in 2 filesystems inside 1 partition?
Easily fdisk /dev/mapper/cryptoroot and create as many as you want (and partition table would allow). No LVM here.
Well, they can, I'm glad for them. But still looks like windows-ish IMO, we lived with swap on different partition for years, why switch at all? There are no profits except ability to easily change swap size, but why do anyone might need to change swap size too often?
Last edited by PoZiTPoH (2021-01-03 21:17:05)
Offline
I don't know if it is a long term approach. Arch wiki didn't mention such an installation, did it?
Offline
I don't know if it is a long term approach. Arch wiki didn't mention such an installation, did it?
Using swap as partition? Well... https://wiki.archlinux.org/index.php/In … _the_disks .
Good approach is one that worked (eventually), mine works .
Offline
I don't know if it is a long term approach.
Why not? it uses standard kernel functionality. It is just necessary to tell the kernel that a block device appeared that should be scanned for partitions.
Arch wiki didn't mention such an installation, did it?
The arch wiki is community driven and such a setup is uncommon. Here is one discussion about a similar idea (with plain dm-crypt instead of LUKS)
https://wiki.archlinux.org/index.php/Ta … m-crypt%22
and a thread on the dm-crypt mailing list: https://www.saout.de/pipermail/dm-crypt … 05654.html
Last edited by progandy (2021-01-03 22:03:13)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
DEVICES=$(ls /dev/dm-*)
You shouldn't parse the output of ls
add_binary "awk"
busybox's awk works just fine.
add_binary "partprobe"
You may want to check if you can make do with busybox's partprobe.
Offline
Hook was done in "always success" way, so I see no problem in using ls even if it will fail. Anyway thanks for pointing out, will fix when will have time .
busybox's awk works just fine.
Thanks, will fix that, was unsure when was writing.
You may want to check if you can make do with busybox's partprobe.
It will fail:
# /usr/lib/initcpio/busybox partprobe /dev/dm-0
partprobe: /dev/dm-0: Invalid argument
Offline