LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-15-2023, 02:44 AM   #16
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled

Quote:
LuckyCyborg=how about to take this porting of mkinitcpio to Slackware as your pet project?
That sounds indeed like an interesting project. But I only have rudimentary programming experience. How to tackle this is beyond me.
 
Old 04-15-2023, 04:18 AM   #17
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,611

Rep: Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481
Quote:
Originally Posted by dosensuppe View Post
That sounds indeed like an interesting project. But I only have rudimentary programming experience. How to tackle this is beyond me.
The mkinitcpio is basically a set of bash scripts.

And with all respect, I believe that someone using Slackware without speaking Bash is like moving in Germany without knowing the German language. What could go wrong?
 
2 members found this post helpful.
Old 04-15-2023, 05:07 AM   #18
henca
Senior Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 1,017

Rep: Reputation: 679Reputation: 679Reputation: 679Reputation: 679Reputation: 679Reputation: 679
Quote:
Originally Posted by dosensuppe View Post
I also don't know if something similar could be done with UEFI? Couldn't you install malicious software in the ESP partition as well?
An UEFI capable BIOS is rather powerful and understand things like a file system. It is capable of hosting both malware and bloatware in the BIOS itself, so I would not only worry about the disk contents.

regards Henrik
 
1 members found this post helpful.
Old 04-15-2023, 08:37 AM   #19
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Didier Spaier View Post
Not needed.

Yes, according to this.
This is not working out for me, for some reason. I created a config file according to the instructions in the link:
Quote:
If you have any luks encrypted filesystems you must create a dracut drop-in config for that. Create the file /etc/dracut.conf.d/encryption.conf with the following content:

install_items+=" /etc/crypttab /crypto_keyfile.bin "

If you have an encrypted swap partition you must also add a line that looks like this to the encryption.conf file created above:

add_device+=" /dev/disk/by-uuid/ad44a367-09ec-4f74-bf66-f284438280db "
Indeed crypto_keyfile.bin shows up in the image and manually decrypting the partition using that file also works, but it doesn't want to auto encrypt and always ends up in that rescue mode, trying to boot the system.
Am I missing something here?
Attached Thumbnails
Click image for larger version

Name:	hmmmmmmmmmmmmmmmmmmmmmmmmmmm.jpg
Views:	34
Size:	244.7 KB
ID:	40815  
 
Old 04-15-2023, 12:04 PM   #20
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by LuckyCyborg View Post
The mkinitcpio is basically a set of bash scripts.

And with all respect, I believe that someone using Slackware without speaking Bash is like moving in Germany without knowing the German language. What could go wrong?
Yes. You're right. I have done a bit of scripting before, but for now I just want a working laptop as I replaced the drive and am directly installing it on hardware now.
I'll try getting mkinitcpio running in a virtual machine later. Mark my words. Indeed it could be a great learning experience.

Last edited by dosensuppe; 04-15-2023 at 12:15 PM.
 
Old 04-15-2023, 12:12 PM   #21
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Quote:
Didier Spaier
I also tried doing it via the kernel options according to these docs: https://www.mankier.com/7/dracut.cmd...ption-Standard
Created a file called /etc/dracut.conf.d/cmdline.conf :
Code:
kernel_cmdline="rd.luks.uuid=xxxxx(Blockdevice UUID)
root=UUID=xxxx(ROOT mapper device) 
rd.luks.allow-discards 
rootfstype=btrfs
rd.luks.key=/crypto_keyfile.bin:UUID=xxxxx(ROOT mapper-device)"
Still no luck
 
Old 04-15-2023, 01:02 PM   #22
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Ok. I'm retarded. I forgot to edit the crypttab file. Anyways. Put something like that in there:
Code:
cryptroot      /dev/disk/by-uuid/xxxxx /crypto_keyfile.bin  luks
With mkinitcpio you somehow don't have to use crypttab. I forgot why or I never knew in the first place??
So to make it a bit more coherent.
First edit crypttab to include the root to encrypt, then add kernel options like mentioned before, listing the root drives to be encrypted, create a seperate config file containing this line:
Code:
install_items+=" /etc/crypttab /crypto_keyfile.bin "
and finally generate the image.
Well, that should be it.
Which one is the superior initramfs gen tool is up to personal preference I guess. I guess Dracut might be a bit more true to the Unix philosophy, being very modular.

If someone knows how mkinicpio manages to do without crypttab, please let me know.

Last edited by dosensuppe; 04-15-2023 at 01:06 PM.
 
Old 04-15-2023, 01:49 PM   #23
sstm
LQ Newbie
 
Registered: Apr 2023
Posts: 4

Rep: Reputation: 3
It's all in the scripts. Open up the init file within those images - it's "just some shell script using some variables to run some commands based on your input". In case of an initrd or initramfs it's a shell script that reads files in the root of the image (/) like 'luksdev' and others.
 
Old 04-15-2023, 03:38 PM   #24
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
I can't get hibernation to work.
SWAP automatically mounts like I configured it to, but it won't hibernate.
I set
Code:
resume=UUID=xxx(encrypted blockdevice)
for both grub and dracut cmdoptions.
The menus don't even show up in KDE and XFCE. The command suggested in the wiki doesn't work.
UPower:
Code:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Hibernate

Last edited by dosensuppe; 04-15-2023 at 03:57 PM.
 
Old 04-15-2023, 04:02 PM   #25
sstm
LQ Newbie
 
Registered: Apr 2023
Posts: 4

Rep: Reputation: 3
Quote:
Originally Posted by dosensuppe View Post
I can't get hibernation to work.
SWAP automatically mounts like I configured it to, but it won't hibernate.
I set
Code:
resume=xxx(encrypted blockdevice)
for both grub and dracut cmdoptions.
The menus don't even show up in KDE and XFCE. The command suggested in the wiki doesn't work.
UPower:
Code:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Hibernate
Aha - well, a few questions - apologies if you've checked all of these before:

- Is your swap active? (the 'free' command should yield a line that starts with 'Swap:' - or use 'swapon -s')
- The partition you point to with resume=xxx should be the one that holds your swap - is it the right one?. (i.e. is your swap in lvm? then it needs to point to /dev/myvg/myswap where myvg and myswap being volume group name and swap partition name; if no lvm, it should be something like /dev/sda2 or /dev/nvme0p2 or whatever)
- You can extract the initrd file (zcat initrd | cpio -idmv) (best done in some tempdir) and look at whether or not it knows where to mount which swap partition or drive. (i.e. aside from mkinitrd and whatever else generates an initrd or initramfs image; look at what is actually generated as opposed to 'what the config files say will be generated')
 
1 members found this post helpful.
Old 04-15-2023, 04:20 PM   #26
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sstm View Post
Aha - well, a few questions - apologies if you've checked all of these before:

- Is your swap active? (the 'free' command should yield a line that starts with 'Swap:' - or use 'swapon -s')
- The partition you point to with resume=xxx should be the one that holds your swap - is it the right one?. (i.e. is your swap in lvm? then it needs to point to /dev/myvg/myswap where myvg and myswap being volume group name and swap partition name; if no lvm, it should be something like /dev/sda2 or /dev/nvme0p2 or whatever)
- You can extract the initrd file (zcat initrd | cpio -idmv) (best done in some tempdir) and look at whether or not it knows where to mount which swap partition or drive. (i.e. aside from mkinitrd and whatever else generates an initrd or initramfs image; look at what is actually generated as opposed to 'what the config files say will be generated')
Well, I'm using btrfs, so lvm would be a bit too many layers of abstraction. So I have an encrypted SWAP.
But you mentioning lvm volumes led me on the right track. The resume= paramater has to point to the decrypted partition, not the block device. I made this issue before during my Artix install. Good thing I always take thorough notes.
As the documentation for Dracut is a bit lacking, I'll upload the configs tomorrow. Maybe someone can profit from it and not waste as much time fooling around as me.
 
Old 04-16-2023, 01:15 AM   #27
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
SOLUTION: HERE'S HOW I GOT SLACKWARE FDE WORKING WITH DRACUT

generate keyfile
dd bs=512 count=4 if=/dev/urandom of=/crypto_keyfile.luks
chmod 000 /crypto_keyfile.luks
add key to encrypted root partition
cryptsetup luksAddKey /dev/sda1 /crypto_keyfile.luks
add key to encrypted swap partition
cryptsetup luksAddKey /dev/sda2 /crypto_keyfile.luks


install Dracut
ftp://slackware.uk/slint/x86_64/slin...source/dracut/

lsblk -o FSTYPE,SIZE,LABEL

/etc/dracut.conf.d/ | https://www.mankier.com/7/dracut.cmd...on-crypto_LUKS

cmdline.conf (kernel options - propably some reduntant options that don't need to be specified, but for some reason the luks.uuid definetely NEEDS to be set for the INITRAMFS to find the drive. Why, with grub already having those set, it still needs to be specified, is beyond me.)
kernel_cmdline="
rd.luks.uuid=xxxxx(Blockdevice von ROOT)
rd.luks.uuid=xxxxx(Blockdevice von SWAP)
resume=UUID=xxxxx(Mapper device von entschlüssltem SWAP)
root=UUID=xxxxxx(Mapper device von entschlüssltem ROOT)
rd.luks.allow-discards
rootfstype=btrfs "

include-elements.conf
install_items+=" /etc/crypttab /crypto_keyfile.bin "
add_dracutmodules+=" btrfs crypt dm "
omit_dracutmodules+=" network cifs nfs brltty "
compress="zstd"

CRYPTTAB
/etc/crypttab
cryptroot /dev/disk/by-uuid/xxxxx(Blockdevice) /crypto_keyfile.bin luks
cryptswap /dev/disk/by-uuid/xxxx(Blockdevice) /crypto_keyfile.bin luks


dracut -f --regenerate-all


GRUB
/etc/default/grub
GRUB_CMDLINE_LINUX="cryptdevice=UUID=uuid_von_root(Blockdevice):cryptroot resume=UUID=uuid_von_swap(entschlüsseltes Mapper device)"
GRUB_ENABLE_CRYPTODISK=y

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Last edited by dosensuppe; 04-20-2023 at 03:35 PM.
 
1 members found this post helpful.
Old 04-16-2023, 01:20 AM   #28
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Sure, some things are propably redundant. But I'll leave it at that.
Don't know why I had to define the kernel options twice.
Without specifying the block UUIDs of both to be encrypted disks in cmdline.conf it just wouldn't boot.
Usually the grub kernel options should suffice.
 
Old 04-16-2023, 02:11 AM   #29
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
Just one question: I have read that dracut automatically includes the microcode inside the initramfs. Will it suffice if I just install the intel microcode slackbuild and dracut will do the rest?

Last edited by dosensuppe; 04-16-2023 at 02:14 AM.
 
Old 04-20-2023, 03:31 PM   #30
dosensuppe
Member
 
Registered: Feb 2021
Location: Germany
Distribution: Artix Linux, Slackware, Gentoo
Posts: 83

Original Poster
Rep: Reputation: Disabled
UPDATE:
Unfortunate for us, using an encrypted boot:
https://mjg59.dreamwidth.org/
Quote:
if you're using an encrypted /boot, stop (proceeding with the header conversion) now - very recent versions of grub2 support LUKS2, but they don't support argon2id, and this will render your system unbootable.
Unfortunately having an unencrypted boot also poses a risk to tampering with our system. One has to wager what is more important to ones security.

Let's hope grub2 will support argon2 anytime soon. Fortunately LUKS headers can be easily converted as is the topic of the article. Thanks to Didier Spaier for mentioning that.

Last edited by dosensuppe; 04-20-2023 at 03:33 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to have luks encryption with keyfile OR passphrase (efi full disk encryption including boot)? byroncollege Linux - Security 2 03-30-2017 07:45 AM
[SOLVED] Is there a cli method of running a command twice without having to type it twice? powderburns Linux - Software 4 03-24-2017 09:55 AM
Mint 18 Full disk encryption VS Veracrypt Full Disk encryption: Help a Noob Decide Please ! APeacefulRig Linux - Security 2 11-11-2016 08:10 AM
Can I avoid Having to type in root password over and over again on Fedora 14? WTFsandwich Linux - Newbie 7 12-24-2011 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration