LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Kernel Installation issues, 11.2, section 10.3.1 (https://www.linuxquestions.org/questions/linux-from-scratch-13/kernel-installation-issues-11-2-section-10-3-1-a-4175717840/)

Don Pedro 10-16-2022 11:12 PM

Kernel Installation issues, 11.2, section 10.3.1
 
Hi out there

It's exciting: I'm getting closer and closer. I've managed two installations, on ThinkPads X200 and X230, and each one works, except ... I've had to improvise (cheat?) by manually moving files into place to get it past GRUB. I'm still a little vague, but if I remember it correctly, I had to move the vmlinuz file out of the boot directory on my boot partition, and then the system would boot. But it was different the first time (X230), where I didn't actually have a 'boot' directory on my Boot Partition at all. Sorry to be imprecise.

Clearly I'm making mistakes, and am probably lucky I could get the system up. HOWEVER, I think I'm zeroing in the problem. At the three 'cp' commands at the end of section 10.3.1 I got the error message "no such file or directory" and frankly I can't work out what's going on here. What's with the "arch" image? Yes, I'm using Archlinux as my host system, but the book doesn't know that! Apologies: I copied the terminal output but lost it. Duh. I'll save it next time, perhaps, unless someone can help me solve the issue first. Nothing else SEEMS to be going wrong.

Once again, apologies for not reporting this properly. If I hear nothing, I'll make a bigger effort to save the output. Somehow, I've managed to **** up my root password on the host system, so don't have proper root access.

But I'm getting so close, it's tantalising. Thanks for all the help you experts dish out for us aspirants :)

Don Pedro

mrmazda 10-17-2022 02:12 AM

Traditionally, kernels and initrds are kept in /boot/, so this is where bootloaders traditionally to look for them. However, when a separate filesystem is employed to keep these and other boot files, they are expected to be in its root in order for the mounted filesystem to show them in a /boot/ directory while they are normally mounted. The traditional solution for this is a symlink of the current directory of a /boot/ filesystem to a subdirectory named boot:
Code:

# ls -l /boot/boot
lrwxrwxrwx 1 root root 1 May 16  2015 /boot/boot -> .
#

Hopefully this will help with your boot files confusion.

Don Pedro 10-17-2022 12:58 PM

Hi Mr Mazda

What you say doesn't immediately solve my problem, and it occurs to me I'd really better make myself clearer. I'll do some thinking and try again. Thank you for your response.

colorpurple21859 10-17-2022 01:26 PM

Quote:

I've had to improvise (cheat?) by manually moving files into place to get it past GRUB
The grub menyentry in lfs is incorrect if using a boot partition. The "set root=(?,?)" will be set to the boot partition and the linux line will be "linux /vmlinuz-5.19.2-lfs-11.2 root=</dev of lfs filesystem root partition>".
Quote:

but if I remember it correctly, I had to move the vmlinuz file out of the boot directory on my boot partition, and then the system would boot
Move it to where? If you moved it to /boot of the root partition, the vmlinuz will not be seen when the boot partition is mounted to /boot

Quote:

I didn't actually have a 'boot' directory on my Boot Partition at all.
Where was the boot partition mounted? A separate boot partition should be mounted to /boot of the lfs filesystem, When mounted to /boot or any other directory, only kernel, grub directory, and a few other files and directories, no boot directory.

Don Pedro 10-18-2022 12:47 AM

Thanks colorpurple

Again, I realise I should have provided more informative details, and I will; I made a pig's breakfast over this post. To exacerbate, 'other life' has taken over the last couple of days which is why I've not had time to replace my original. But briefly, my grub.cfg was correct (I think!) and exactly as you suggested. My partitioning set up, too, was correct I think, though I noted the recent debate about GPT rather then MBR. It was an MBR table, with a 256M ext4 boot partition, a generous swap, and an ext4 root partition.

What I was confused about was getting the 'file or directory not found' for each of the three cp commands on page 10.3.1 and the truth is I didn't really understand those commands, nor why the first one had the term "arch" in it.

More later, and thanks for the response. Back soon.

colorpurple21859 10-18-2022 05:25 AM

The cp commands are done while still in the kernel build directory after doing "make modules_install".

"arch" is a directory in the kernel build directory. The new bzImage will be in arch/x86/boot of the kernel build directory regardless of whether it is a 64bit or 32bit kernel.

Don Pedro 10-18-2022 06:26 AM

A fuller report (Don Pedro)
 
LFS Installation (ThinkPad X200)

Partition Table = Master Boot Record
/dev/sda1 = 268 MB Ext4 Bootable
/dev/sda2 = Swap
/dev/sdae = 16 GB Ext4

After LFS installation:

/dev/sda1
/grub/fonts
/i386-pc
/locale
grub.cfg **
grubenv
vmlinuz-5.19.2-lfs-11.2

I moved the vmlinuz out of the grub directory, after which LFS booted fine.

/dev/sda3 /boot/grub/grub.cfg *


Note that the layouts of the two occurences of 'grub.cfg' differ.

*
# Begin /boot/grub/grub.cfg **
set default=0
set timeout=5
insmod ext2
set root=(ahci0,msdos1)
menuentry "GNU/Linux, Linux 5.19.2-lfs-11.2" {
linux /vmlinuz-5.19.2-lfs-11.2 root=/dev/sda3 ro
}

**
set default=0
set timeout=5

insmod ext2
set root=(ahci0,msdos1)

menuentry "GNU/Linux, Linux 5.19.2-lfs-11.2" {
linux /vmlinuz-5.19.2-lfs-11.2 root=/dev/sda3 ro
}

======

The original question of my post was regard to page 10.3.1 of the 11-2 book. On each of the 3 'cp' commands, terminal output was 'no such file or directory'. I ignored that and pressed ahead, but wondered if doing so was the reason for the initial boot failure, and the grub anomalies. I did/do not understand these commands and hoped someone could explain them. In particular, what is 'arch/x86/boot/bzimage'?

After 'shutdown -r now' booting started but LFS would not progress past the GRUB screen, so I rebooted from the Host System (Archlinux) and moved the vmlinuz file OUT of the grub directory on the boot partition, where I had found it. After that the new system booted fine.

Don Pedro 10-18-2022 06:27 AM

Thanks colorpurple for explaining the 'arch' item.

Don Pedro 10-19-2022 06:56 PM

I'm going to recast aspects of this question as a New Thread. Sorry if I've been confusing.

wiigelec 10-20-2022 08:41 AM

Quote:

In particular, what is 'arch/x86/boot/bzimage'?
this is the compressed kernel image. the three copy (cp) commands copy the kernel image (bzImage), the kernel config file (.config) and the kernel map file (System.map) from the build directory into the system /boot directory. these files are renamed to differentiate them from other kernel files that may be used on the same system

the placement of these files into the /boot directory is arbitrary, as technically they can be placed anywhere accessible to the boot loader (grub) as long as the boot loader is appropriately informed of their location

wiigelec 10-20-2022 10:04 AM

Quote:

On each of the 3 'cp' commands, terminal output was 'no such file or directory'.
please post the output of findnmt when you get the error with cp

eta: also please post output of pwd when you get the cp error

wiigelec 10-20-2022 10:18 AM

Quote:

Note that the layouts of the two occurences of 'grub.cfg' differ.
this is all dependent on whether or not you have /dev/sda1 mounted to /boot when you run the grub-install /dev/sda command

if /dev/sda1 is not mounted to /boot when you run grub-install then the grub files will be installed to /boot on the root file system partition which would be /dev/sda3/boot

if /dev/sda1 is mounted to /boot when you on run grub-install then the grub files will be installed to the root level of /dev/sda1 since the /boot directory is on /dev/sda3 partition but its contents reside on /dev/sda1 partition

eta:

Quote:

After LFS installation:

/dev/sda1
/grub/fonts
/i386-pc
/locale
grub.cfg **
grubenv
vmlinuz-5.19.2-lfs-11.2

I moved the vmlinuz out of the grub directory, after which LFS booted fine.

/dev/sda3 /boot/grub/grub.cfg *
i see what you are saying here with the grub.cfg file not being in the grub directory. hard to say what would cause this to happen. i would delete the contents of the boot directory and the /dev/sda1 partition, mount /dev/sda1 to /boot, and rerun grub-install /dev/sda. better yet, i would forget about the separate /boot partition for now and just run everything off /dev/sda3 until you get that working the way you expect, then add in the additional layer of complexity with the /dev/sda1 /boot partition

colorpurple21859 10-20-2022 12:17 PM

Based on this, it looks like at one point the boot partition was mounted to /boot/grub and not /boot and maybe at one point installed grub without the boot partition mounted /boot.
Quote:

/dev/sda1
/grub/fonts
/i386-pc
/locale
grub.cfg **
grubenv
vmlinuz-5.19.2-lfs-11.2

Don Pedro 10-20-2022 07:46 PM

I've since managed to disentangle this, and (having started 'from scratch'!! again) had a success, which boots fine = doesn't need 'tinkering' with. Thanks to everyone, I've learned a lot in this process.

The 'from scratch' thing isn't really a joke. I've gone back and restarted quite a few times, but by now have evolved a 'script' which works.


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