LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This 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


Reply
  Search this Thread
Old 05-17-2021, 11:31 AM   #1
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Rep: Reputation: 2
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?

Last edited by George528; 05-17-2021 at 11:43 AM.
 
Old 05-17-2021, 12:31 PM   #2
hendrickxm
Member
 
Registered: Feb 2014
Posts: 344

Rep: Reputation: Disabled
Yes, just chroot and change what is wrong.
 
Old 05-17-2021, 12:36 PM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,576
Blog Entries: 19

Rep: Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453
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.
 
Old 05-17-2021, 12:36 PM   #4
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by hendrickxm View Post
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)
 
Old 05-17-2021, 01:04 PM   #5
hendrickxm
Member
 
Registered: Feb 2014
Posts: 344

Rep: Reputation: Disabled
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.
 
Old 05-17-2021, 01:49 PM   #6
themightydill
LQ Newbie
 
Registered: Apr 2021
Location: Edmonton, AB
Distribution: Arch and derivatives, Debian, Fedora, LFS 10.1
Posts: 20

Rep: Reputation: 10
Well.
Press E in GRUB and edit (hd1) to (hd0)??
 
Old 05-17-2021, 01:50 PM   #7
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by hazel View Post
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

Last edited by George528; 05-17-2021 at 02:00 PM.
 
Old 05-17-2021, 02:01 PM   #8
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,352

Rep: Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590
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
 
Old 05-17-2021, 02:06 PM   #9
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by colorpurple21859 View Post
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

Last edited by George528; 05-17-2021 at 02:07 PM.
 
Old 05-17-2021, 02:08 PM   #10
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by themightydill View Post
Well.
Press E in GRUB and edit (hd1) to (hd0)??
what exactly is this GRUB, a software? how do i get it?
 
Old 05-17-2021, 02:10 PM   #11
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,352

Rep: Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590
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.
 
Old 05-17-2021, 02:24 PM   #12
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by George528 View Post
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

Last edited by George528; 05-17-2021 at 02:29 PM.
 
Old 05-17-2021, 04:21 PM   #13
themightydill
LQ Newbie
 
Registered: Apr 2021
Location: Edmonton, AB
Distribution: Arch and derivatives, Debian, Fedora, LFS 10.1
Posts: 20

Rep: Reputation: 10
Quote:
Originally Posted by George528 View Post
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?"
 
Old 05-17-2021, 04:22 PM   #14
themightydill
LQ Newbie
 
Registered: Apr 2021
Location: Edmonton, AB
Distribution: Arch and derivatives, Debian, Fedora, LFS 10.1
Posts: 20

Rep: Reputation: 10
Quote:
Originally Posted by George528 View Post
what exactly is this GRUB, a software? how do i get it?
GRUB is the menu that comes up when you boot.
 
Old 05-17-2021, 05:18 PM   #15
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,352

Rep: Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590Reputation: 1590
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?

Last edited by colorpurple21859; 05-17-2021 at 05:41 PM.
 
  


Reply

Tags
grub



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dualboot [HD1: Ubuntu14.04] / [HD2: Win7(truecrypted) ] DexterMorgan Ubuntu 3 04-30-2015 02:30 PM
fixmbr for WinXP killed GRUB-cannot boot into Ubuntu - HD1+HD2 not recognized Mousy Linux - General 9 08-16-2007 05:39 AM
HD1:IDE Suse 10.2 & Windows Xp Pro HD HD2: SATA XP PRO X64 HOW TO MOUNT HD 2 blazintilda2005 Linux - Hardware 1 04-13-2007 08:30 PM
64-bit Suse9.1 on HD1, need WinXP on HD2 sharkcatcher Linux - Newbie 4 01-22-2005 01:16 PM
red hat on hd1 windows on hd2 FireWolf Linux - Newbie 6 02-12-2003 03:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 07:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration