Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
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.
Last edited by colorpurple21859; 10-17-2022 at 05:39 PM.
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.
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.
Last edited by colorpurple21859; 10-18-2022 at 05:28 AM.
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.
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
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
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.