You are not logged in.

#1 2020-01-03 11:38:48

cypherpunks01
Member
Registered: 2020-01-03
Posts: 6

[SOLVED]Encrypted /boot - invalid magic number error

Hi!
I have installed Arch on LUKS-encrypted LVM: LVM on LUKS

Partitioning:

NAME            MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda               8:0    0 465.8G  0 disk  
├─sda1            8:1    0   100M  0 part  
|
|...
|  
└─sda6            8:6    0 215.7G  0 part  
  └─arch        254:3    0 215.7G  0 crypt 
    ├─arch-root 254:4    0    40G  0 lvm   /
    ├─arch-swap 254:5    0     4G  0 lvm   [SWAP]
    └─arch-home 254:6    0 171.7G  0 lvm   /home
sdb               8:16   1  14.9G  0 disk  
└─sdb1            8:17   1  14.9G  0 part  /boot

It worked.

Then i tried to create an encrypted /boot partition:
1.Formatted /dev/sdb1 to luks1 volume (with saving all files needed for boot, of course, but deleted /boot/grub for its next installation)
2.Mounted it as /boot partition (In decrypted form: /dev/mapper/arch-boot)
3.Edited /etc/defaut/grub:

...
GRUB_PRELOAD_MODULES="part_msdos luks cryptodisk"
...
GRUB_ENABLE_CRYPTODISK=y
...

4.Edited /etc/crypttab and /etc/fstab:
/etc/fstab:

UUID=*/dev/mapper/arch-boot-uuid*       /boot           ext4            rw,relatime     0 2

/etc/crypttab:

arch-boot      UUID=*/dev/sdb1-uuid*    none                    luks

5.Installed grub with:

grub-install --recheck /dev/sdb

After booting from USB (/dev/sdb) it asks for password for /boot, grub menu opens, but after booting "Arch" menuentry it gives me an error:

...
error:Invalid magic number
...
error:you need to load kernel first

As i found out with grub-shell:

>ls
(hd0),(hd0,msdos1)...(crypt0)
>ls (crypt0)/
vmlinuz-linux initrd-ramdisk.img ... grub
>file (crypt0)/vmlinuz-linux
error:no type specified

I tried to do it with another USB-stick but result is same.

How can I fix it? Thanks in advance!

Last edited by cypherpunks01 (2020-01-03 13:49:22)

Offline

#2 2020-01-03 11:49:50

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: [SOLVED]Encrypted /boot - invalid magic number error

Did you re-generate /boot/grub/grub.cfg after editing /etc/defaut/grub?

Offline

#3 2020-01-03 11:54:09

cypherpunks01
Member
Registered: 2020-01-03
Posts: 6

Re: [SOLVED]Encrypted /boot - invalid magic number error

nl6720 wrote:

Did you re-generate /boot/grub/grub.cfg after editing /etc/defaut/grub?

Yeap
Arch' entry looks like:

menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-90dae584-4533-4c0c-bd4d-7ca5e9ba2a83' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod cryptodisk
        insmod luks
        insmod gcry_rijndael
        insmod gcry_rijndael
        insmod gcry_sha256
        insmod ext2
        cryptomount -u 64b9a0932e604e82b6bbda2e598774aa
        set root='cryptouuid/64b9a0932e604e82b6bbda2e598774aa'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='cryptouuid/64b9a0932e604e82b6bbda2e598774aa'  53389add-a0d6-43a7-ac89-a2119ff33347
        else
          search --no-floppy --fs-uuid --set=root 53389add-a0d6-43a7-ac89-a2119ff33347
        fi
        echo    'Loading Linux linux ...'
        linux   /vmlinuz-linux root=/dev/mapper/arch-root rw  cryptdevice=UUID=6591cb78-d1ca-4e25-8d4f-2004a204c7bc:arch root=/dev/arch/root
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-linux.img
}

Where all uuids are valid

Offline

#4 2020-01-03 12:00:58

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: [SOLVED]Encrypted /boot - invalid magic number error

what's the output of:

file /boot/vmlinuz-linux

(adjust the path if you're not chrooted).

If it's not "Linux kernel x86 boot executable bzImage..." then reinstall the "linux" package.

Offline

#5 2020-01-03 12:04:36

cypherpunks01
Member
Registered: 2020-01-03
Posts: 6

Re: [SOLVED]Encrypted /boot - invalid magic number error

nl6720 wrote:

what's the output of:

file /boot/vmlinuz-linux

(adjust the path if you're not chrooted).

If it's not "Linux kernel x86 boot executable bzImage..." then reinstall the "linux" package.

No, it's valid kernel:

>file /boot/vmlinuz-linux
/boot/vmlinuz-linux: gzip compressed data, from Unix, original size modulo 2^32 71536640

I think that the problem is with grub fs-reading (maybe it's associated with luks fs-reading in grub)
But grub sees folders and files on /dev/sdb!

Btw, I tried to create file "test.txt" at /boot:

#touch text.txt
#nano text.txt 
#cat text.txt
test

But grub still gives out an error:

>file (crypt0)/text.txt
error:no type specified

Last edited by cypherpunks01 (2020-01-03 12:07:51)

Offline

#6 2020-01-03 12:13:06

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: [SOLVED]Encrypted /boot - invalid magic number error

cypherpunks01 wrote:

No, it's valid kernel:

>file /boot/vmlinuz-linux
/boot/vmlinuz-linux: gzip compressed data, from Unix, original size modulo 2^32 71536640

That's not the correct output. It should be:

/boot/vmlinuz-linux: Linux kernel x86 boot executable bzImage, version 5.4.7-arch1-1 (linux@archlinux) #1 SMP PREEMPT Tue, 31 Dec 2019 17:20:16 +0000, RO-rootFS, swap_dev 0x6, Normal VGA

Edit:
I can't find any documentation for GRUB's "file" command, so I have no idea what it should even do.

Last edited by nl6720 (2020-01-03 12:16:33)

Offline

#7 2020-01-03 12:16:15

cypherpunks01
Member
Registered: 2020-01-03
Posts: 6

Re: [SOLVED]Encrypted /boot - invalid magic number error

nl6720 wrote:
cypherpunks01 wrote:

No, it's valid kernel:

>file /boot/vmlinuz-linux
/boot/vmlinuz-linux: gzip compressed data, from Unix, original size modulo 2^32 71536640

That's not the correct output. It should be:

/boot/vmlinuz-linux: Linux kernel x86 boot executable bzImage, version 5.4.7-arch1-1 (linux@archlinux) #1 SMP PREEMPT Tue, 31 Dec 2019 17:20:16 +0000, RO-rootFS, swap_dev 0x6, Normal VGA

Ooops...
Thanks, I'll try it!

Offline

#8 2020-01-03 13:17:25

cypherpunks01
Member
Registered: 2020-01-03
Posts: 6

Re: [SOLVED]Encrypted /boot - invalid magic number error

Lol, I'm retard.
I made an mistype when was generating mkinitcpio so my kernel was overwritten.

Thank you very much!

Offline

#9 2020-01-03 13:31:53

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: [SOLVED]Encrypted /boot - invalid magic number error

I'm glad it works now smile
Remember to mark this thread as [SOLVED].

Offline

Board footer

Powered by FluxBB