The officially official Devuan Forum!

You are not logged in.

#1 2020-07-05 19:51:08

kuleszdl
Member
Registered: 2018-11-03
Posts: 107  

How to properly unpack and repack initramfs by hand?

Hi,

I am trying to port an encrypted devuan installation from system A (virtual) to system B (physical). I tried many things (e.g. using partlabels) but I can't convince the initramfs tools to generate the proper crypttab file for the initramfs.

To fix this manually, I tried to unpack and repack the initramfs as explained in this article: https://access.redhat.com/solutions/24029

It seems to work, but by just unpacking and repacking the initramfs it grows from ~27M to ~128M and fails to boot (kernel panic).

What is the proper way to unpack and repack the initramfs image if you want to do it by hand (for whatever reason)?

Thanks!

Offline

#2 2020-07-05 19:58:13

rolfie
Member
Registered: 2017-11-25
Posts: 1,045  

Re: How to properly unpack and repack initramfs by hand?

That your image grows tells me that you forgot to recompress again. There should be instructions how to do this.

rolfie

Offline

#3 2020-07-05 20:00:18

kuleszdl
Member
Registered: 2018-11-03
Posts: 107  

Re: How to properly unpack and repack initramfs by hand?

Thanks and yes, this my first guess as well. I tried both including gzip -9 in the pipeline (as explained in the article) and also not doing it but compressing it afterwards by hand (also with gzip -9). However, it went from ~237M uncompressed to the mentioned ~128M compressed but not down to ~27M.

Offline

#4 2020-07-05 20:04:34

rolfie
Member
Registered: 2017-11-25
Posts: 1,045  

Re: How to properly unpack and repack initramfs by hand?

Another approach: boot the hardware with a life media, chroot into the new system, then check crypttab, fstab .... for correct UUIDs. The problem may the there.

rolfie

Note: I have used VMs to explore new distros myself, makes sense to get some experience. I used to take notes what I did to achieve certain results, and then I went an made a fresh install on the real HW based on the notes.

Last edited by rolfie (2020-07-05 20:08:34)

Offline

#5 2020-07-05 20:36:58

kuleszdl
Member
Registered: 2018-11-03
Posts: 107  

Re: How to properly unpack and repack initramfs by hand?

Well, that's basically the same approach I am taking here. The UUIDs are of course not correct since they differ between these two systems. The problem is that even after correcting the UUID (or placing PARTLABEL= there), regenerating the initramfs does not update its crypttab file as the script seems to take these parameters somewhere from the currently running system and ignores the crypttab file.

Eventually I found a way to resolve the issue by using the "cryptopts=source=..." kernel parameter. Yet I would be interested in properly unpacking/repacking the initramfs in case I'd like to manually change something there.

Another workaround is to boot the target once, bail out to initramfs prompt, mount it from there and regenerate the initramfs while booted. However, this does not work nicely if you want to prepare images for headless machines.

Offline

#6 2020-07-05 20:49:45

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: How to properly unpack and repack initramfs by hand?

kuleszdl wrote:

What is the proper way to unpack and repack the initramfs image if you want to do it by hand (for whatever reason)?

See unmkinitramfs(8) & mkinitramfs(8).

EDIT: this sounds like an XY-problem but I don't use encryption so I can't really advise better, sorry.

Last edited by Head_on_a_Stick (2020-07-05 20:51:24)


Brianna Ghey — Rest In Power

Offline

Board footer