LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   My LFS system won't boot up after accidentally setting grub to hd1 instead of hd0 (https://www.linuxquestions.org/questions/linux-from-scratch-13/my-lfs-system-wont-boot-up-after-accidentally-setting-grub-to-hd1-instead-of-hd0-4175695221/)

George528 05-17-2021 11:31 AM

My LFS system won't boot up after accidentally setting grub to hd1 instead of hd0
 
I just finished my LFS build but after rebooting i see this:

https://i.imgur.com/8boZJxL.png

https://i.imgur.com/QqMKlec.png

then I remembered that when configuring grub.cfg file i put
set root=(hd1,6) instead of set root=(hd0,6).


also i have to point out that when i booted up from my live cd, the /boot directory was empty

https://i.imgur.com/4WO3KZP.png

and all partitions where unmounted , only the host partition ans swap was mounted.

how do i change fix this? do i have to enter chroot enviroment from live cd to install grub again?

hendrickxm 05-17-2021 12:31 PM

Yes, just chroot and change what is wrong.

hazel 05-17-2021 12:36 PM

I don't think you need to chroot. Just mount the LFS root partition somewhere convenient and edit grub.cfg by hand. You aren't reinstalling grub, after all, just changing the location information you give grub once it's loaded.

btw if you boot from a live disc, the /boot partition you see will be the one on the disc, so it may well be empty. To see the boot partition on your hard drive, you need to mount your root (say on /mnt) and then look at /mnt/boot.

George528 05-17-2021 12:36 PM

Quote:

Originally Posted by hendrickxm (Post 6251502)
Yes, just chroot and change what is wrong.

ok i will chroot, but can you explain why my /boot directory in LFS hierarchy is empty? i am sure i installed installed grub in /boot (/boot is a separate directory)

hendrickxm 05-17-2021 01:04 PM

You install grub as a piece of software but you install grub as bootloader as well. Those are two different things.
If you boot and see a grub command, the bootloader part is done but you messed up the config.
You can change the config without chroot but you would need to mount the LFS-partition and edit the grub config file.

themightydill 05-17-2021 01:49 PM

Well.
Press E in GRUB and edit (hd1) to (hd0)??

George528 05-17-2021 01:50 PM

Quote:

Originally Posted by hazel (Post 6251506)
I don't think you need to chroot. Just mount the LFS root partition somewhere convenient and edit grub.cfg by hand. You aren't reinstalling grub, after all, just changing the location information you give grub once it's loaded.

btw if you boot from a live disc, the /boot partition you see will be the one on the disc, so it may well be empty. To see the boot partition on your hard drive, you need to mount your root (say on /mnt) and then look at /mnt/boot.

I mounted /boot on /mnt/boot, but its still empty, i can't find my config file there

was i supposed to move/copy the linux kernel dir in /boot? i did't do it

colorpurple21859 05-17-2021 02:01 PM

Quote:

I mounted /boot on /mnt/boot
what command did you run to mount /boot on /mnt/boot? Do you have a separate boot partition? Post the output of
Code:

parted -l

George528 05-17-2021 02:06 PM

Quote:

Originally Posted by colorpurple21859 (Post 6251529)
what command did you run to mount /boot on /mnt/boot? Do you have a separate boot partition? Post the output of
Code:

parted -l

i used the command
Code:

mount /dev/sdb9 /mnt/boot
yes /boot is a separate partition

here is the output

Code:

root@ubuntu:/# parted -l
Model: ATA Patriot Burst (scsi)
Disk /dev/sdb: 240GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End    Size    Type      File system    Flags
 1      1049kB  10.2GB  10.2GB  primary  ext4            boot
 2      10.2GB  240GB  230GB  extended
 5      10.2GB  134GB  124GB  logical  ext4
 6      134GB  220GB  85.9GB  logical  ext4
 7      220GB  225GB  5368MB  logical  ext4
 8      225GB  230GB  5368MB  logical  ext4
 9      230GB  231GB  1074MB  logical  ext4
10      231GB  240GB  8590MB  logical  linux-swap(v1)


Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Model: HL-DT-ST DVDRAM GT51N (scsi)                                     
Disk /dev/sr0: 2877MB
Sector size (logical/physical): 2048B/2048B
Partition Table: mac
Disk Flags:

Number  Start  End    Size    File system  Name  Flags
 1      2048B  6143B  4096B                Apple
 2      870kB  4966kB  4096kB              EFI


George528 05-17-2021 02:08 PM

Quote:

Originally Posted by themightydill (Post 6251526)
Well.
Press E in GRUB and edit (hd1) to (hd0)??

what exactly is this GRUB, a software? how do i get it?

colorpurple21859 05-17-2021 02:10 PM

If it isn't in the boot partition /dev/sdb9 check your / partition and/or other partitions, maybe the boot partition didn't get mounted when grub was installed and/or the wrong partition was mounted at /boot.

George528 05-17-2021 02:24 PM

Quote:

Originally Posted by George528 (Post 6251532)
what exactly is this GRUB, a software? how do i get it?

still empty in root

i followed the instruction closely https://www.linuxfromscratch.org/lfs...er10/grub.html

but i didn't do this

Code:

If you choose to do this, you will need to mount the separate partition, move all files in the current /boot directory
 (e.g. the linux kernel you just built in the previous section) to the new partition.


i also followed this instruction:
From GRUB's perspective, the kernel files are relative to the partition used. If you used a separate /boot partition, remove /boot from the above linux line. You will also need to change the set root line to point to the boot partition.
so i deleted the /boot from code like this:
Code:

cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd0,2)

menuentry "GNU/Linux, Linux 5.10.17-lfs-10.1" {
        linux  /vmlinuz-5.10.17-lfs-10.1 root=/dev/sda2 ro
}
EOF


themightydill 05-17-2021 04:21 PM

Quote:

Originally Posted by George528 (Post 6251532)
what exactly is this GRUB, a software? how do i get it?

GRUB is the bootloader: the menu that comes up at boot saying "which OS to boot from?"

themightydill 05-17-2021 04:22 PM

Quote:

Originally Posted by George528 (Post 6251532)
what exactly is this GRUB, a software? how do i get it?

GRUB is the menu that comes up when you boot.

colorpurple21859 05-17-2021 05:18 PM

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?


All times are GMT -5. The time now is 09:56 AM.