View previous topic :: View next topic |
Author |
Message |
redwood Guru
Joined: 27 Jan 2006 Posts: 306
|
Posted: Thu May 09, 2019 9:32 pm Post subject: Upgrading System to btrfs + grub2 |
|
|
Hi,
I'm trying to upgrade my harddrives and filesystem on an old desktop computer (M2N4-SLI)
My current setup:
Code: |
Linux axp 4.9.76-gentoo-r1 #1 SMP Sun Feb 25 12:32:26 EST 2018 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ AuthenticAMD GNU/Linux
gcc-i686-pc-linux-gnu-8.2.0
booting with grub(1): /boot/grub/grub.conf:
title=Gentoo Linux (4.9.76-gentoo-r1)
root (hd0,0)
kernel /boot/kernel-genkernel-x86-4.9.76-gentoo-r1 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/md3 rootfstype=ext4 dolvm vga=0x318 video=v86d:ywrap,mtrr,1024x768-32@72 splash=silent,fadein,theme:livecd-2006.0,tty:12 quiet CONSOLE=/dev/tty1
initrd /boot/initramfs-genkernel-x86-4.9.76-gentoo-r1
Pair of 2 2T harddrives in mirror raid (mdadm):
sfdisk -l /dev/sd{c,e}
Device Boot Start End Sectors Size Id Type Mount Point
/dev/sd{c,e}1 * 20480 225279 204800 100M fd Linux raid autodetect /boot
/dev/sd{c,e}2 225280 2273279 2048000 1000M fd Linux raid autodetect swap
/dev/sd{c,e}3 2273280 12820479 10547200 5G fd Linux raid autodetect /
/dev/sd{c,e}4 12820480 3907008511 3894188032 1.8T 8e Linux LVM home,opt,usr,tmp,vartmp,distfiles
|
There is another stable version of sys-kernel/gentoo-sources-4.9.162-r1 which I've not updated to. I did try to update to the latest stable kernel 4.19.27-r1 but it seems like all kernels past the "9" series are broken on my hardware, specifically I get a kernel panic on boot with IO-APIC message. None of the workarounds fix the problem. Appending to kernel cmd line "acpi=off" results in a segfault with unable to read /dev/md (no enumerated md's). Appending "noapic" results in endless failed harddrive fails "AMD DMA Read error ... ready {} reset ... "
So for now I'm stuck on 4.9.76-r1
I need to replace my harddrives as they're old and iostat is reporting IO waiting whenever akonadi is running which kills KDE performance.
So I bought a new pair of 2T harddrives:
Code: |
gdisk -l /dev/sd{a,b}
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 3907029168 sectors, 1.8 TiB
Model: WDC WD2003FYYS-0
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 61B8789A-E0A0-46AF-887E-4409EF769B97
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 8191 3.0 MiB EF02 grub2biosboot
2 8192 6299647 3.0 GiB 8200 swap
3 6299648 3907029134 1.8 TiB 8300 Linux BTRFS raid1
|
As I've been using btrfs on my laptop for a number of years now without problems, I decided to
My plan was to transfer my filesystem from the old pair of harddrives over to the new pair of harddrives formatted with btrfs using subvolumes "activeroot" and "home" roughly following these 2 gentoo guides:
https://wiki.gentoo.org/wiki/Btrfs/System_Root_Guide (uses grub1, custom init, openrc)
https://wiki.gentoo.org/wiki/Btrfs/Native_System_Root_Guide (uses grub2, dracut, full luks encryption, systemd)
So I've now managed to transfer my old filesystem over to the new btrfs raid1 harddrives.
When booting using grub2, I get asked for my password for my two harddrives and they get unencrypted
then grub2 displays its menu of kernels and recovery kernels.
but I get a kernel panic with unrecognized block device.
FWI, I do have "btrfs" built into the kernel.
My grub2 configuration /etc/grub/grub.cfg:
Code: |
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-5487d18b-bd2f-45c9-b2c7-893d269977c9' {
load_video
insmod gzio
insmod part_gpt
insmod part_gpt
insmod cryptodisk
insmod luks
insmod gcry_rijndael
insmod gcry_rijndael
insmod gcry_sha256
insmod cryptodisk
insmod luks
insmod gcry_rijndael
insmod gcry_rijndael
insmod gcry_sha256
insmod btrfs
cryptomount -u 907455981d1042cd9944be3d6a763b21
cryptomount -u 2111d05092094956a835a803bcef6aa6
set root='cryptouuid/907455981d1042cd9944be3d6a763b21'
set root='cryptouuid/2111d05092094956a835a803bcef6aa6'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint='cryptouuid/907455981d1042cd9944be3d6a763b21' --hint='cryptouuid/2111d05092094956a835a803bcef6aa6' 5487d18b-bd2f-45c9-b2c7-893d269977c9
else
search --no-floppy --fs-uuid --set=root 5487d18b-bd2f-45c9-b2c7-893d269977c9
fi
echo 'Loading Linux x86-4.9.76-gentoo-r1 ...'
linux /boot/kernel-genkernel-x86-4.9.76-gentoo-r1 root=UUID=5487d18b-bd2f-45c9-b2c7-893d269977c9 ro rootflags=subvol=activeroot cryptdevice=/dev/disk/by-uuid/90745598-1d10-42cd-9944-be3d6a763b21:cryptroot:allow-discards cryptdevice2=/dev/disk/by-uuid/2111d050-9209-4956-a835-a803bcef6aa6:cryptroot2:allow-discards init=/init
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-genkernel-x86-4.9.76-gentoo-r1
}
|
The cryptouuid's are correct as reported by blkid and grub2 successfully decrypts them on bootup
Code: |
blkid /dev/sd{a,b}3
/dev/sda3: UUID="90745598-1d10-42cd-9944-be3d6a763b21" TYPE="crypto_LUKS" PARTLABEL="Linux" PARTUUID="379223ed-e92c-45d0-bf37-64baab99afa6"
/dev/sdb3: UUID="2111d050-9209-4956-a835-a803bcef6aa6" TYPE="crypto_LUKS" PARTLABEL="Linux" PARTUUID="379223ed-e92c-45d0-bf37-64baab99afa6"
|
Also, the UUID "5487d18b-..." for the unencrypted luks btrfs partitions is correct:
Code: |
# blkid /dev/mapper/luks-?
/dev/mapper/luks-1: LABEL="BTROOT" UUID="5487d18b-bd2f-45c9-b2c7-893d269977c9" UUID_SUB="48cd26c0-741f-4370-845b-5d000cda96a4" TYPE="btrfs"
/dev/mapper/luks-2: LABEL="BTROOT" UUID="5487d18b-bd2f-45c9-b2c7-893d269977c9" UUID_SUB="cbdb050b-8ad5-41f5-a851-9547855dcadb" TYPE="btrfs"
|
Rather than use dracut, I used genkernel to create an initramfs which I unpacked
Code: |
mkdir myinitramfs; cd myinitramfs
xzcat /boot/initramfs-genkernel-4.9.76-gentoo-r1 | cpio -i
|
I then replaced the genkernel init with that from System_Root_Guide using a busybox script. I also added all /sbin/btrfs* to the initramfs
and added a minimal /etc/fstab
Code: | /INITRAMSf/etc/fstab
LABEL=BTROOT /boot btrfs defaults,noatime,subvol=boot 0 0
LABEL=BTROOT /mnt/root btrfs defaults,noatime,compress=lzo,autodefrag,subvol=activeroot 0 0
|
Code: | UUID's for unencrypted btrfs partitions /dev/sd{a3,b3}
blkid /dev/mapper/luks-?
/dev/mapper/luks-1: LABEL="BTROOT" UUID="5487d18b-bd2f-45c9-b2c7-893d269977c9" UUID_SUB="48cd26c0-741f-4370-845b-5d000cda96a4" TYPE="btrfs"
/dev/mapper/luks-2: LABEL="BTROOT" UUID="5487d18b-bd2f-45c9-b2c7-893d269977c9" UUID_SUB="cbdb050b-8ad5-41f5-a851-9547855dcadb" TYPE="btrfs"
|
then repacked the modified initramfs
Code: |
find . | cpio -H newc -o | xz -9 > /boot/initramfs-genkernel-4.9.76-gentoo-r1
|
My goal right now is just to be able to boot using grub2 and a btrfs root filesystem (after decripting the raw harddrives).
The mount_root() function from the busybox custom init is straight forward:
Code: |
mount_root() {
echo "scanning for btrfs filesystems.... will take about 5-10 seconds"
#
# earlier versions of btrfs required devices on scan. As of around 0.19.11 or so this now is a syntax error
#
# btrfs device scan /dev/sda /dev/sdb
btrfs device scan
echo "mounting /mnt/root"
busybox mount /mnt/root
}
|
Thanks in advance for any ideas on getting grub2+btrfs root booting with 4-9 series kernel.
I'd like to get rid of my old mdadm+LVM raid1 pair and use my new disks.
Currently am mounting my home btrfs subvolume from the new disks and that has solved the IO-wait issues with akonadi/KDE, so I think that portion of my old harddrives is pretty worn out.
Guess I could go back to tried and true mdadm+LVM+ext4 but was hoping to get gentoo booting with btrfs raid1.
======
I'll leave updating to a newer stable kernel till later. I've tried up to 5.1.0 but still get IO-APIC kernel panic on my old filesystem.
Not tried looking to see if there's a newer BIOS update to this old motherboard.
There is a recent kernel issue reported with latest kernels and IO-APIC kernel panics on old and newer hardware
but I can't remember the last time I've ever had any issues updating to a newer kernel.
https://lkml.org/lkml/2019/4/3/163 |
|
Back to top |
|
|
LIsLinuxIsSogood Veteran
Joined: 13 Feb 2016 Posts: 1179
|
Posted: Fri May 10, 2019 7:17 am Post subject: |
|
|
Hey there, I am just gong to comment on the general nature of your issue. It seems like you are trying to do a lot at the same time. Maybe focus on one issue at a time. If I had a working kernel, and I was trying to replace hard disks I would not bother with most recent kernel upgrade until the disks were first managed. I am basing this off of many different installations of linux some of them are running older kernels and no problems there. Stable is just another way of saying "ahead of the curve" in gentoo speak so I wouldn't be too concerned about it if you have a working kernel just stick with that one. Maybe you can go to kernel.org and download some other versions of it and get a few trials going for that, but if your problem exists with the access to your operating system now that you've moved the disk then I don't know what to say. Have you attempted a live boot rescue CD and see if that will "mount" or even replacing the grub configuration entry on it to try booting directly into it. Sometimes the kernels on live cd are a bit better and provide lots of functionality. Give it a try if it seems like it could work.
Otherwise it sounds like you may be stressing about a kernel that doesn't need to be upgraded. I've been there but it usually will just catch up later to the downstream stable builds. Hope that you find this information refreshing since your doing so much to test the nature of it, but not necessarily your fault. Could be that there is a very narrow window for error with bootloader and kernel here. |
|
Back to top |
|
|
redwood Guru
Joined: 27 Jan 2006 Posts: 306
|
Posted: Fri May 10, 2019 2:15 pm Post subject: |
|
|
Thanks, LIsLinuxIsSogood.
I think I need to read up on full disk encryption and genkernel's configuration, then generate a new initramfs with genkernel.
I played around with grub2 configuration and concluded that the grub2 menu entry is OK. It's unencrypting my dmcrypted luks volumes, From the grub cmd line I can see all my drives and filesystems. Once I boot a kernel, grub loads the proper kernel but my initramfs can't find the root block so get kernel panic.
I was a little confused about the boot loader. I thought that once grub2 had decrypted my volumes that the loaded kernel would have access to the unencrypted system, but what actually happens is that the bootloader replaces itself with the kernel and whatever grub knew about the system is gone when grub is replaced. So I need an init that decrypt my drives. I just need to configure genkernel so that it knows where to find my keyfile and tell it which drives to decrypt. There's a lot of configuration options, eg. usb keys, detatched luks headers, etc. I think once I sort this out it should be easy....
The Full Encrypted Btrfs/Native System Root Guide https://wiki.gentoo.org/wiki/Btrfs/Native_System_Root_Guide I was following didn't go into detail about its configuration of dracut. It just said to use Code: | dracut -f -I /root/secretkey | to generate a new initramfs. Presumably the guide's author already had a working dracut configuration (which I don't).
I only started using an initramfs because I had a separate /usr partition and the udev/systemd changes a few years back needed access to /usr. Before that I always just let the bootloader directly load the kernel with the root device and an init. So I haven't played around much with genkernel's configuration file. Hopefully, just specifying the keyfile and encrypted devices should work.
Took a looks at some other custom init scripts, and I see there are a lot of gotchas to be aware of, eg. how to find devices by UUID when udev not functional, etc. Genkernel should already have all that code in there. So I'm going to give genkernel another go. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|