[SOLVED] My LFS system won't boot up after accidentally setting grub to hd1 instead of hd0
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.
at the grub menu press c for a grub prompt grub>
at the grub prompt
Code:
grub>set
post the following line
Code:
prefix=
In post 9 you say your mounting /dev/sda9 to /boot but according to your grub.cfg /dev/sda2 is the partition where your kernel is located not /dev/sda9
Which partition is suppose to be the / partition?
/dev/sdb6 is supposed to be /
do i have to enter grub loader during boot or in live cd terminal
at the grub menu, that come up when you first boot, the picture in your first link.
press e for edit and change these lines to this:
Code:
set root=(hd0,6)
linux /boot/vmlinuz-5.10.17-lfs-10.1 root=/dev/sda6 ro
press ctrl-x to boot
but the book clearly says that i have to remove /boot from linux code if i have a separate boot partition. Where should i remove it then? i think i misunderstood
You can also use the ls command at the grub prompt to seach
ls (hd0,1)/
ls (hd0,5)/boot
i am not sure how this will help me, nor i understand what you are telling me to do
i am trying to boot from LFS's /boot, not initial host's /boot (in my case ubuntu)
You don't know what partition the lfs kernel is on or if it is in / of the partition or /boot of the partition. You will need to search through the partitions sda1 and sda5-sda9 to find out where your kernel is located. You can do this from the grub prompt with the ls command or from the host by mounting each partition and do a search until you find it.
Last edited by colorpurple21859; 05-18-2021 at 11:06 AM.
Look, George, I don't want to belittle you or anything. I think it's really impressive that you finished LFS, but I think you should drop it for a while and read up some more about Linux. You need to learn:
1) about partitioning and how to find out quickly what partitions are on a hard drive;
2) about booting and bootloaders, specifically GRUB and how it works;
3) about having a separate boot partition, what goes on it, why, and where you mount it in your different systems.
The book recommends a separate partition because once you have finished your LFS build, you will have at least two independent Linux OS's on your machine. The writers thought it was easier to boot them if you have all the kernels and initrds in one place, though I must admit that I never did it that way.
You say that your boot partition is empty, which suggests to me that perhaps you didn't have it mounted on /boot when you installed your kernel. That also suggests that you didn't really understand what you were doing and why. So I suggest you read up the background stuff, then redo the LFS build from scratch and it should work the second time around.
Look, George, I don't want to belittle you or anything. I think it's really impressive that you finished LFS, but I think you should drop it for a while and read up some more about Linux. You need to learn:
1) about partitioning and how to find out quickly what partitions are on a hard drive;
2) about booting and bootloaders, specifically GRUB and how it works;
3) about having a separate boot partition, what goes on it, why, and where you mount it in your different systems;
The book recommends a separate partition because once you have finished your LFS build, you will have at least two independent Linux OS's on your machine. The writers thought it was easier to boot them if you have all the kernels and initrds in one place, though I must admit that I never did it that way.
You say that your boot partition is empty, which suggests to me that perhaps you didn't have it mounted on /boot when you installed your kernel. That also suggests that you didn't really understand what you were doing and why. So I suggest you read up the background stuff, then redo the LFS build from scratch and it should work the second time around.
thanks
i understand what you are saying and agree with it, i will read more about linux (linux bible) but for now i want to finish lfs asap. The GNU tools work perfectly so i don't see why i have to recomplie everything again. I think i will eneter chroot eviroment from live cd and install compile linux kernel and install grub again. i will be more careful this time.
but i don't understand this part from here:
Caution
If the host system has a separate /boot partition, the files copied below should go there. The easiest way to do that is to bind /boot on the host (outside chroot) to /mnt/lfs/boot before proceeding. As the root user in the host system:
Code:
mount --bind /boot /mnt/lfs/boot
what i did was open another terminal without chroot and pasted the command there, because the command wasn't working in chroot. I don't understand why i did this, i already mounted the device in chapter 2.6. Then when i opened gparted to see whats going on. sdb1 (host) was mounted on / and /mnt/lfs/boot, and sdb9 (the /boot partition) was giving me a warning. Then i proceeded to unmount sdb1 (so only / remains). Now that i think of this, that was the mistake i made
Your using a live cd, keep it simple, don’t use a boot partition. Mount lfs to /mnt, chroot into lfs, edit the /etc/fstab to only mount the root partition/dev/sda6 and swap partition,re-install your kernel, re-run grub- install, edit the grub.cfg for (hd0,6) /dev/sd6
Last edited by colorpurple21859; 05-18-2021 at 12:16 PM.
Your using a live cd, keep it simple, don’t use a boot partition. Mount lfs to /mnt, chroot into lfs, re-install your kernel, re-run grub- install, edit the grub.cfg for (hd0,6) /dev/sda6
Caution
If the host system has a separate /boot partition, the files copied below should go there. The easiest way to do that is to bind /boot on the host (outside chroot) to /mnt/lfs/boot before proceeding. As the root user in the host system:
Code:
mount --bind /boot /mnt/lfs/boot
A "bind" mount causes a partition that is already mounted to be additionally mounted elsewhere. If you look at the pre-chroot instructions, you will see a number of mounts of this kind to bind virtual filesystems on your host, such as /proc and /sys, to your growing LFS system.
Quote:
what i did was open another terminal without chroot and pasted the command there, because the command wasn't working in chroot. I don't understand why i did this, i already mounted the device in chapter 2.6.
No you didn't! You mounted the new LFS system onto Ubuntu's /mnt/lfs. Now you need to check if Ubuntu is using a separate boot partition and bind that to LFS's /boot directory. Not the same thing at all!
Also don't confuse mounting a system with chrooting into it. They are two different things. When you mount you new system on /mnt/lfs, you are just making it accessible from the host system. When you chroot into it, you are turning it into your new temporary root partition (chroot=change root). From that point on, you are in LFS, not Ubuntu, and have no access to any Ubuntu software except the running kernel. Also any paths will be relative to this new root directory. So any binding mounts must be carried out before chrooting.
Quote:
Then when i opened gparted to see whats going on. sdb1 (host) was mounted on / and /mnt/lfs/boot, and sdb9 (the /boot partition) was giving me a warning.
Then you mounted it wrong. You were not told to bind-mount the host's root partition, but to check if there was a separate boot partition and bind-mount that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.