Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
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.


  Search this Thread
Old 12-18-2008, 03:29 PM   #1
Registered: Dec 2008
Location: Hereford, UK
Distribution: LFS (when it's finished)
Posts: 30

Rep: Reputation: 16
Grub error 21 with LFS 6.3 Chapter 8.4

After two past failed attempts with earlier versions I've finally completed LFS 6.3 using the LiveCD - and learnt a great deal along the way! I've followed the book very carefully (I don't know enough to stray anyway!)

I'm now stuck in Chapter 8.4 'Making the LFS System Bootable'. I want to make a dual-boot system for LFS and my Windows XP system, both of which are in separate partitions.

In chapter 8.4, I run the GRUB shell then type: root (hd0,2). But I get the dreaded "Error 21: Selected disk does not exist".

LFS is built on partition sda3 which is of type ext3. Other partitions contain Windows XP (sda1), a 'User' partition for my Windows files (sda6) and a small partition for the Linux swap file (sda5).

I use just a single SATA hard drive (no RAID).

When compiling the Kernel I have ensured that Serial ATA (prod), SCSI and type ext3 have all been enabled.

Although I've found others on this forum with Error 21 problems, they seem to be doing things a bit different to me so have been of little help.
I can't find any hints that address this problem, nor does Google throw up anything useful.

I'm determined not to have to give up yet again and have to snatch defeat from the jaws of success! so any advice would be very much appreciated.

Old 12-19-2008, 12:47 AM   #2
LQ Newbie
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
Congrats! You are almost there!

If I were you I would brute force it. That is, there are only so many partitions, and likely you are only off by one or two. So I would try

root (hd0,1)


root (hd0,3)

NOTE: I didn't say to run setup (hd0)!!

Running the two root commands above, when you hit the correct drive you will see grub say that it found the the stage{1,2} files. Once you see this feedback from grub, you can setup (hd0).

The worst that happens is that grub can't boot linux, and you have to use the livecd and run grub again, trying a different root (hd?,?).

Now if you try all the combinations and don't get grub saying it found the stage files, come on back!
Old 12-19-2008, 01:02 PM   #3
Registered: Dec 2008
Location: Hereford, UK
Distribution: LFS (when it's finished)
Posts: 30

Original Poster
Rep: Reputation: 16
Many thanks ken5an for your reply.

I tried all partition numbers from 0 to 6 in each of drive numbers 0 to 4 but always got that dreaded error 21 message. I couldn't see much future in going any further but it was definitely worth a go.

I've looked in my BIOS to see if there is anything I could conceivably change to do with the SATA drive but couldn't see anything.

I'm going to re-visit those other posts and see if there's anything I have missed. Meanwhile I hope there is someone out there who can shed some light on the problem.

Once again many thanks for your suggestion.
Old 12-19-2008, 02:26 PM   #4
LQ Guru
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 7,796

Rep: Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504
Open a terminal/konsole and login as root, run command 'fdisk -l' without quotes, Lower case Letter L, not a one (1). Post the output so we have your exact partition info as seen by LFS.

Second, again from a terminal as root, type 'grub' at the prompt to get the grub prompt (grub>), when you get this type:

find /boot/grub/stage1
find /boot/vmlinuz
geometry (hd0)

Post results of these commands.
Old 12-20-2008, 01:37 PM   #5
Registered: Dec 2008
Location: Hereford, UK
Distribution: LFS (when it's finished)
Posts: 30

Original Poster
Rep: Reputation: 16
Many thanks Yancek for your reply. Here is the information you requested:

fdisk -l produces the following output:

Disk /dev/sda: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 12748 102398278+ 7 HPFS/NTFS
/dev/sda2 24907 30514 45046260 f W95 Ext’d (LBA)
/dev/sda3 12749 24906 97659135 83 Linux
/dev/sda5 24907 25496 4739143+ 83 Linux
/dev/sda6 25497 30514 40307053+ 7 HPFS/NTFS

I have built my LFS system on sda3 with a small swap file on sda5.
The other partitions are for my existing Windows XP system.

In GRUB: find /boot/grub/stage1 produces: (hd0,2)
find /boot/vmlinuz produces: Error 15: File not found

geometry (hd0) produces the following:

Drive 0x80: C/H/S=30515/255/63, The number of sectors=490234752, /dev/sda
Partition num: 0, Filesystem type unknown, partition type 0x7
Partition num: 2, Filesystem type is ext2fs, partition type 0x83
Partition num: 4, Filesystem type unknown, partition type 0x83
Partition num: 5, Filesystem type unknown, partition type 0x7

I hope this might give some clue to what is going on.

In my BIOS I have set the first boot device to be my DVD R/W drive (because my host is the LFS Live DVD) and the second boot device is my SATA hard drive.

Thanks again for your interest.
Old 12-20-2008, 02:05 PM   #6
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,589

Rep: Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427
I haven't tried LFS, but are you running the grub command as root ?.
Old 12-21-2008, 12:05 AM   #7
LQ Newbie
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
This likely won't solve your problem, but my boot partition is set to bootable (has an *) along with my windows partition, compared to yours which only the windows partition has the * next to it.
Old 12-21-2008, 12:48 AM   #8
Senior Member
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,455
Blog Entries: 3

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
you need a swap file for linux. you can also in the live cd open a terminal and and type grubconf. then tell it where to put grub grub always looks for the /boot folder. so make sure you have one in side the boot folder better be your kernel vmlinuz. ok now tell grub what hard drive to put the grub folder then tell it to put the boot loader on hda1 or sda1.
even if you boot it it will crash you need a linux file type 82 swap file.
so partition one of you drives cfdisk /dev/dev/sda choose a partition like sda5 if you got know data on it the delete it then remake it a little smaller give your self at least a gig of swap area if your hurting for space nothing under 524 mb. cfdisk /dev/sda choose sda5 or what ever resize it then with the left over free space make a linux primary swap partition type 82 any way after your throughputting grub on the go to the /boot/grub/menu.1st file and make sure it point to your /boot/vmlinuz/ root=/dev/sdXXX
keep hacking you will get it but before you do this you might want to down load super grub so if things go bad you can boot your other windows systems I see in there.
Old 12-21-2008, 03:49 AM   #9
Registered: Dec 2008
Location: Hereford, UK
Distribution: LFS (when it's finished)
Posts: 30

Original Poster
Rep: Reputation: 16
Thanks everybody for your valued help. There is a lot to absorb - particularly from Drakeo so I need to go off now and digest it all.

I have got a bit further, syg00 asked if I was logged on as root - I am but it set me to thinking about exactly how I am starting the system from the LiveCD whilst finishing it off. I've been using the excellent hint by Joseph Dupre but realised I didn't fully understand exactly what I'm doing - particularly with regard to populating /dev. I read a line in the LFS book which goes: mount -v --bind /dev/$LFS/dev. When I used this, grub was happy and I continued on. Now I have grub appearing at start-up but it only has my Windows option! LFS is nowhere to be seen on the menu. I can boot into Windows OK.

Unfortunately for me the LFS book does not assume use of the LiveCD so it's not that straightforward for a beginner. Clearly I have more studying to do to fully understand what's required. I am using LFS as an educational project for myself to learn about Linux so that's only to be expected.

I'll post again when I've made progress but meanwhile very many thanks to you all for your most valuable suggestions. I will study them all in detail.

Last edited by bines; 12-21-2008 at 03:50 AM.
Old 12-23-2008, 09:50 PM   #10
LQ Newbie
Registered: Dec 2008
Posts: 13

Rep: Reputation: 0
chapter 6.4 "Entering the chroot environment" basically covers what you need to do after a reboot. there is also a hint that covers starting over from a saved point. I put all my startup stuff in bash script that I run after mounting the root partition.

bring up the livecd environment and run [fdisk /dev/sda] type "m" for help

type "p" to view your partition scheme. type "a" to toggle the bootable flag on /dev/sda3. You're going to want to change the partition type on /dev/sda5 type "t" to do so, it's going to be on a extended partition so select "e" and pick/type in your partition (been a while since I've used extended). the type is going to be 82 for linux/solaris swap, you can hit "l" to see all available partition types. Type "w" to write your changes to the partition table.

At this point you're going to have to run [mkswap /dev/sda5] to format the swap partition (always remember fdisk doesn't format anything).

Make sure your partitions are all listed in /etc/fstab appropriately.

Go back to the chapter on making the system bootable and make sure that you have your menu.lst file configured properly. Oh, and the find /boot/vmlinuz command didn't work because the kernel is named lfskernel- so you'd use find /boot/lfskernel- (for lfs 6.3). That should get you up and running, or at least past the 21 error. have fun
Old 12-24-2008, 03:18 PM   #11
Registered: Dec 2008
Location: Hereford, UK
Distribution: LFS (when it's finished)
Posts: 30

Original Poster
Rep: Reputation: 16
Thanks cyphercell for your reply. I've started over again and am currently half-way through chapter 6. I've noted carefully what you have said however and I will ensure that your advice is taken.

I'm very grateful for your input.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LFS 6 Chapter 6.3 chroot error gatblast45 Linux From Scratch 8 01-01-2008 03:12 AM
LFS 6 Chapter 6.8 mount error gatblast45 Linux From Scratch 20 01-04-2006 05:48 PM
ERROR IN??: lfs 6.0 chapter 5.35. Udev-030 jobesd Linux From Scratch 4 01-31-2005 05:05 PM
now getting error in coreutils test(chapter 6-lfs-5.1.1) linuxbh Linux From Scratch 2 09-16-2004 02:45 AM
LFS 3.3 - chapter 6 - glibc error fend88 Linux From Scratch 5 04-28-2002 11:06 PM > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 04:46 PM.

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