You are not logged in.

#1 2020-03-09 07:28:02

pauledd
Member
Registered: 2019-12-14
Posts: 42

[SOLVED] create sleep hook

Hi

Problem1:
besides my root disk I have a storage disk that is in encrypted in plain format without any partitions.
So the disk gets randomly detected as /dev/sdX by the UEFI/Bios and so I cannot assign a consistent drive name to
/etc/crypttab because it changes everytime I reboot leaving me with a broken boot process (Waiting for .....).
Solution1:
I then created an udev rule to detect the disk by "ID_MODEL" and then let udev symlink to an unique name "store2tb"
which I then use in my crypttab.

Problem2:
This works in 2 of 5 boot attemps. If it works not I am again left with an "enter passphrase something...:" request because cryptsetup was not
supplied with the proper drive which is decrypted by an FILE, and not by an user input.

I think I recognized the problem by watching the boot messages.

(so, or something like that...):
:: STARTUNG UDEV
:: Blablabla
:: Blablabla2
:: FOUND disk ST2000LM003blablabla   <----- which is my encrypted disk

So the problem seems to be that the KERNEL detects the disk (sometimes) just AFTER early UDEV hook did its job and consequently failing to rename
my disk.

Solution2: (maybe)
Now I want to introduce some "sleep" just before the udev hook does its job, 2 or 4 seconds...
So I created an "disksleep" hook in

/etc/initcpio/install/disksleep

#!/bin/bash

build() {
    add_binary /usr/bin/sleep

    add_runscript
}

help() {
    cat <<HELPEOF
This Hook is made by Paul
HELPEOF
}

and a
/etc/initcpio/hooks/disksleep

#!/usr/bin/ash

run_earlyhook() {
    msg ":: PAUL earlyhook sleep...4sec"
    /usr/bin/sleep 4
}

run_hook() {
    msg ":: PAUL run_hook..."
}

run_cleanuphook() {
    msg ":: PAUL clean_hook..."
}

Then I add this disksleep hook into /etc/mkinitcpio.conf and rebuild the initramfs.

Will this work so far or do I have a fundamental mistake in my plan leaving me with an
unbootable system?

Last edited by pauledd (2020-03-10 08:57:08)

Offline

#2 2020-03-09 07:33:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,979

Offline

#3 2020-03-09 10:23:11

pauledd
Member
Registered: 2019-12-14
Posts: 42

Re: [SOLVED] create sleep hook

afaik uuid is a partition-thing. No partition on disk no uuid... my encrypted drive is partitionless.

PS. and Labels also wont work here

Last edited by pauledd (2020-03-09 10:33:46)

Offline

#4 2020-03-09 13:43:57

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,979

Re: [SOLVED] create sleep hook

The UUID and label are not related to the partition, but the filesystem.
Check "lsblk -f".

Offline

#5 2020-03-09 19:28:10

pauledd
Member
Registered: 2019-12-14
Posts: 42

Re: [SOLVED] create sleep hook

seth wrote:

... are not related to the partition, but the filesystem.

Yes and as long as my encrypted disk is'nt decrypted the underlying filesystem is not visible to neither
UDEV nor crypttab/cryptsetup

Offline

#6 2020-03-09 19:53:09

loqs
Member
Registered: 2014-03-06
Posts: 19,087

Re: [SOLVED] create sleep hook

Is the /dev/disk/by-path/ or /dev/disk/by-id entry for the disk constant?

Last edited by loqs (2020-03-09 21:10:03)

Offline

#7 2020-03-09 22:04:32

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,979

Re: [SOLVED] create sleep hook

How exactly is the disk setup?
If you created a FS and then encrypted that, the UUID is supposed to be there and intact.
Did you check "lsblk -f" on the un-openend encrypted device? (eg. from a live distro)

Offline

#8 2020-03-10 08:56:05

pauledd
Member
Registered: 2019-12-14
Posts: 42

Re: [SOLVED] create sleep hook

loqs wrote:

Is the /dev/disk/by-path/ or /dev/disk/by-id entry for the disk constant?

Yes, thanks a lot, that solves the problem. Using /dev/disk/by-path/ in crypttab seems to work fine.
And just for completeness regarding the topic, yes, my custom sleep hook worked too, but
is not needed anymore as well as my udev renaming rule.

Last edited by pauledd (2020-03-10 08:56:39)

Offline

Board footer

Powered by FluxBB