LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-14-2009, 12:58 PM   #1
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Rep: Reputation: 0
why do i get grub error 21?


I just installed ubuntu on my external hard drive. Now when i start up my pc i get an error 21.
I know that error 21 means that it can't find the external hard disk. but what do i have to do about it?

I searched several forums but i couldn't figure it out.

thanks
 
Old 01-14-2009, 06:06 PM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Version 8.10 of Ubuntu? What else is on the computer? Any other OS's on the internal or external drives? What bootloader are you using, Grub? If you are using Grub, where did you install it? The mbr of the external drive? If that's the case you need to set the external to boot first in your BIOS. Use your installation CD as a Live CD and enter command: sudo fdisk -l, post output (that is a lower case letter L, not a number one in the command).

Last edited by yancek; 01-14-2009 at 06:08 PM.
 
Old 01-15-2009, 03:43 AM   #3
ytd
Member
 
Registered: Jan 2009
Posts: 205

Rep: Reputation: 31
You need to enter in BIOS and chose to boot from the external hard disk drive. In your case i think you should try to boot from USB if the hdd is USB.

Be carefull not to have any other USB sticks / USB memory or whatever in your USB port from the PC, because it will try to boot from USB and if it cannot find an oS on those memory stick / or whatever you have plugged in ur usb port then will can't boot. ;-)

I hope you understand what i'm saying.

Last edited by ytd; 01-15-2009 at 03:50 AM.
 
Old 01-15-2009, 05:27 AM   #4
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
I use ubuntu 8.04 LTS. I tried 8.10 but the installation disk didn't work. I have XP on my internal drive, Ubuntu on my external usb drive. I use grub to boot up. When I boot i get an error 21 so I can't do anything. I tried to change some things with some program for grub before but that didn't work. It just booted windows then. now i reinstalled Ubuntu and i get error 21 again.

output of sudo fdisk -l:

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x17df17de

Device Boot Start End Blocks Id System
/dev/hda1 * 1 9728 78140128+ 7 HPFS/NTFS

Disk /dev/sdb: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000cce6f

Device Boot Start End Blocks Id System
/dev/sdb1 1 4659 37423386 83 Linux
/dev/sdb2 4660 4864 1646662+ 5 Extended
/dev/sdb5 4660 4864 1646631 82 Linux swap / Solaris
 
Old 01-15-2009, 06:40 AM   #5
wificraig
Member
 
Registered: Jan 2008
Location: Southern Oregon
Distribution: Laptop: DesktopBSD1.6, openSuse11, Mandriva, Mepis7, BackTrack3....USB: Mandriva2009, Debian-Lenny,
Posts: 82

Rep: Reputation: 16
How did you configure Grub?

When you installed Ubuntu to the external drive, at some point you were asked where to install Grub. If you used the default (just clicked "Next") then you installed Grub to your internal drive. Now, Grub thinks that your Ubuntu is on the internal drive, unless you changed the configuration for the menu to be on hd1,0 instead of the default hd0,0 which is your internal drive.

If you have a live CD you can re write Grub to the MBR with the correct parameters, or write it to the external drive. If writing to the external drive, set your bios to load the external drive first.

Another option is to create a Grub CD that chain loads the external drive, but you would need to set the menu.lst listings to hd1 where ever hd0 appears for root and kernel. This is because the Grub CD will always associate the internal drive as hd0.
 
Old 01-15-2009, 07:52 AM   #6
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
Hi Zilie, in order to get a clearer picture of your setup, how about booting your Live CD (the Ubuntu install CD), download the Boot Info Script to your Ubuntu desktop, open a terminal (Applications > Accessories > Terminal) and do:
Code:
sudo bash ~/Desktop/boot_info_script*.sh
That will create a "RESULTS.txt" file in the same directory from where the script is run, namely your desktop; please copy/paste the contents of that file to your next post, highlight the copied text, and click the pound sign # graphic in the forum message box so that the text will get "code" tags put around it. The results of that script will help clarify your setup and hopefully what it will take to correct your Grub error 21.

Last edited by CJS; 01-15-2009 at 08:31 AM.
 
Old 01-15-2009, 08:29 AM   #7
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
results.txt

Code:
============================= Boot Info Summary: ==============================

 => Grub0.97 is installed in the MBR of /dev/hda and looks on boot drive #2 in 
    partition #1 for /boot/grub/stage2 and /boot/grub/menu.lst.
 => No boot loader is installed in the MBR of /dev/hdc
 => No boot loader is installed in the MBR of /dev/sdb

hda1: _________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows XP
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  Windows XP
    Boot files/dirs:   /boot.ini /ntldr /NTDETECT.COM

sdb1: _________________________________________________________________________

    File system:       ext3
    Boot sector type:  -
    Boot sector info:  
    Operating System:  Ubuntu 8.04.1
    Boot files/dirs:   /boot/grub/menu.lst /etc/fstab /boot /boot/grub

sdb2: _________________________________________________________________________

    File system:       Extended Partition

sdb5: _________________________________________________________________________

    File system:       swap

=========================== Drive/Partition Info: =============================

Drive hda: _____________________________________________________________________

fdisk -lu /dev/hda:

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x17df17de

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *          63   156280319    78140128+   7  HPFS/NTFS

sfdisk -V /dev/hda:

end of partition 1 has impossible value for head: 254 (should be in 0-15)

Drive hdc: _____________________________________________________________________

fdisk -lu /dev/hdc:
Note: sector size is 2048 (not 512)

Disk /dev/hdc: 728 MB, 728225792 bytes
255 heads, 63 sectors/track, 22 cylinders, total 355579 sectors
Units = sectors of 1 * 2048 = 2048 bytes
Disk identifier: 0x00000000


sfdisk -V /dev/hdc:


sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/hdc: unrecognized partition table type

sfdisk: no partition table present.

Drive sdb: _____________________________________________________________________

fdisk -lu /dev/sdb:

Disk /dev/sdb: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x000cce6f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63    74846834    37423386   83  Linux
/dev/sdb2        74846835    78140159     1646662+   5  Extended
/dev/sdb5        74846898    78140159     1646631   82  Linux swap / Solaris

sfdisk -V /dev/sdb:

Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
/dev/sdb: OK

blkid -c /dev/null: ____________________________________________________________

/dev/hda1: UUID="4A280678280662F5" TYPE="ntfs" 
/dev/loop0: TYPE="squashfs" 
/dev/sdb1: UUID="369c54b1-8a08-4ea9-a78e-cea2a8ee5102" TYPE="ext3" 
/dev/sdb5: TYPE="swap" UUID="9916ad40-06a8-44f8-b1a1-89f3f116ea68" 

=============================== "mount" output: ===============================

proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /lib/modules/2.6.24-19-generic/volatile type tmpfs (rw,mode=0755)
tmpfs on /lib/modules/2.6.24-19-generic/volatile type tmpfs (rw,mode=0755)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
gvfs-fuse-daemon on /home/ubuntu/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ubuntu)
/dev/sdb1 on /media/disk type ext3 (rw,nosuid,nodev,uhelper=hal)

================================ hda1/boot.ini: ================================

[boot loader]

timeout=30

default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS

[operating systems]

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition" /fastdetect /NoExecute=OptIn


=========================== sdb1/boot/grub/menu.lst: ===========================

# menu.lst - See: grub(8), info grub, update-grub(8)
#            grub-install(8), grub-floppy(8),
#            grub-md5-crypt, /usr/share/doc/grub
#            and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default		0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout		10

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line)  and entries protected by the
# command 'lock'
# e.g. password topsecret
#      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title		Windows 95/98/NT/2000
# root		(hd0,0)
# makeactive
# chainloader	+1
#
# title		Linux
# root		(hd0,1)
# kernel	/vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
##      kopt_2_6_8=root=/dev/hdc1 ro
##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=369c54b1-8a08-4ea9-a78e-cea2a8ee5102 ro

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd1,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
##      alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
##      lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
##      lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
##      altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
##      howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
##      memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title		Ubuntu 8.04.1, kernel 2.6.24-19-generic
root		(hd1,0)
kernel		/boot/vmlinuz-2.6.24-19-generic root=UUID=369c54b1-8a08-4ea9-a78e-cea2a8ee5102 ro quiet splash
initrd		/boot/initrd.img-2.6.24-19-generic
quiet

title		Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root		(hd1,0)
kernel		/boot/vmlinuz-2.6.24-19-generic root=UUID=369c54b1-8a08-4ea9-a78e-cea2a8ee5102 ro single
initrd		/boot/initrd.img-2.6.24-19-generic

title		Ubuntu 8.04.1, memtest86+
root		(hd1,0)
kernel		/boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title		Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/hda1
title		Microsoft Windows XP Home Edition
root		(hd0,0)
savedefault
makeactive
chainloader	+1


=============================== sdb1/etc/fstab: ===============================

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# /dev/sda1
UUID=369c54b1-8a08-4ea9-a78e-cea2a8ee5102 /               ext3    relatime,errors=remount-ro 0       1
# /dev/sda5
UUID=9916ad40-06a8-44f8-b1a1-89f3f116ea68 none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0

================================== sdb1/boot: ==================================

total 11104
drwxr-xr-x  3 root root    4096 2009-01-14 21:32 .
drwxr-xr-x 21 root root    4096 2009-01-14 21:31 ..
-rw-r--r--  1 root root  422667 2008-06-18 18:11 abi-2.6.24-19-generic
-rw-r--r--  1 root root   80049 2008-06-18 18:11 config-2.6.24-19-generic
drwxr-xr-x  2 root root    4096 2009-01-14 21:32 grub
-rw-r--r--  1 root root 7881072 2009-01-14 21:31 initrd.img-2.6.24-19-generic
-rw-r--r--  1 root root  103204 2007-09-28 10:06 memtest86+.bin
-rw-r--r--  1 root root  905146 2008-06-18 18:11 System.map-2.6.24-19-generic
-rw-r--r--  1 root root 1920472 2008-06-18 18:11 vmlinuz-2.6.24-19-generic

=============================== sdb1/boot/grub: ===============================

total 204
drwxr-xr-x 2 root root   4096 2009-01-14 21:32 .
drwxr-xr-x 3 root root   4096 2009-01-14 21:32 ..
-rw-r--r-- 1 root root    197 2009-01-14 21:32 default
-rw-r--r-- 1 root root     30 2009-01-14 21:32 device.map
-rw-r--r-- 1 root root   8056 2009-01-14 21:32 e2fs_stage1_5
-rw-r--r-- 1 root root   7904 2009-01-14 21:32 fat_stage1_5
-rw-r--r-- 1 root root     16 2009-01-14 21:32 installed-version
-rw-r--r-- 1 root root   8608 2009-01-14 21:32 jfs_stage1_5
-rw-r--r-- 1 root root   4582 2009-01-14 21:32 menu.lst
-rw-r--r-- 1 root root   7324 2009-01-14 21:32 minix_stage1_5
-rw-r--r-- 1 root root   9632 2009-01-14 21:32 reiserfs_stage1_5
-rw-r--r-- 1 root root    512 2009-01-14 21:32 stage1
-rw-r--r-- 1 root root 108356 2009-01-14 21:32 stage2
-rw-r--r-- 1 root root   9276 2009-01-14 21:32 xfs_stage1_5

=============================== StdErr Messages: ===============================

Disk /dev/hdc doesn't contain a valid partition table
 
Old 01-15-2009, 08:45 AM   #8
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
I think the best solution to your problem would be to install Grub to your external Ubuntu drive, and then set your BIOS to boot the Ubuntu drive on start up. If that works OK, you could restore a Windows MBR to your sda Windows drive, and then your drives will be independent of each other as far as booting goes; that way you shouldn't get a Grub error 21. So if that sounds good, how about first installing Grub to the MBR (Master Boot Record) of your Ubuntu drive:
Code:
sudo grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> makeactive
grub> setup (hd0)
grub> quit
And please post the output of the above commands before doing "quit". Note the "makeactive" command is to set the boot flag on your Ubuntu partition, because even though Grub ignores the boot flag and does not need it to boot a partition, some BIOSes will refuse to boot a drive that doesn't have the boot flag set on one of the primary partitions; that's because those particular BIOSes assume the drive is a data drive if no boot flag is set. Next reboot, set your BIOS to boot the Ubuntu drive, and you should get the Grub menu if all goes well. If you get the Grub menu OK, you'll need to slightly modify the Ubuntu entry in order to boot into Ubuntu; so select the first Ubuntu entry in the Grub menu, press "e" to edit it, select the line that says "root (hd1,0)", press "e" to edit it, change it to "root (hd0,0)", press return to save the change, then press "b" to boot. Based on the info you gave, I think that should be all it takes to boot Ubuntu. Note that the change is not permanent, so you'll need to modify your menu.lst to make it permanent.

So if it works, when you get into Ubuntu, just do:
Code:
gksudo gedit /boot/grub/menu.lst
And change the line that says "# groot=(hd1,0)" to use the (hd0,0) that worked to boot Ubuntu. Save, quit gedit, then run:
Code:
sudo update-grub
And you should be all set. Let me know how it goes or if you run into problems.

Last edited by CJS; 01-15-2009 at 08:46 AM.
 
Old 01-15-2009, 09:00 AM   #9
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
I ran the command lines and i think everything went ok. I am now rebooting and will let you know if it works.

Code:
grub> device (hd0) /dev/sdb

grub> root (hd0,0)

grub> makeactive

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.
 
Old 01-15-2009, 09:04 AM   #10
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
still getting an error 21 :s
 
Old 01-15-2009, 09:05 AM   #11
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
It sounds like you still need to change your BIOS to boot the Ubuntu drive instead of your Windows drive; did you do that?
 
Old 01-15-2009, 09:09 AM   #12
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
my bios is set to cd-rom > floppy > pxe > harddisk
 
Old 01-15-2009, 09:20 AM   #13
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
Yes, but "harddisk" is obviously your Windows drive. Is your external Ubuntu drive SATA or USB? Does your BIOS not give you any other HDDs to choose from to boot? If so, you may not be able to boot your Ubuntu drive from your Windows drive. We will need some more info about which drives your BIOS sees on start up, so how about downloading the Super Grub Disk, boot that, and when you get the first main menu, press "c" to get the Grub command line, and then do:
Code:
grub> geometry (hd0)
That should show your Windows drive, i.e. one partition of type "0x7". Next try:
Code:
grub> geometry (hd1)
And let me know what that returns. If it says drive not found, I don't think there is much hope of getting your Ubuntu drive booting with Grub, because that would mean that Grub does not even see the Ubuntu drive on start up. It might be that using "PLoP" or some other boot manager would work to boot your drive, but that will take some work.
 
Old 01-15-2009, 09:32 AM   #14
zilie
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
when i do geomety (hd0) everything comes like you said. With (hd1) i get error 21: selected disk does not exist. my drive is an usb
 
Old 01-15-2009, 09:43 AM   #15
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
Since Grub can't detect your Ubuntu HDD on start up, that unfortunately means you won't be able to use Grub to boot your Ubuntu drive. There's a good chance you can use the PLoP boot manager to boot your Ubuntu USB drive though, because it comes with its own built in USB drivers; how about downloading the PLoP CD ISO (you'll need to unzip it), burn it to CD, and see if that will boot your Ubuntu drive; you would choose the option to boot the USB drive from the PLoP boot menu. Let me know if that works or not.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
install kubuntu 8.10 with lilo rather than grub (because of grub error 18) dukeinlondon Ubuntu 7 12-27-2008 06:53 PM
Loading Grub 1.5 Please Wait...... Grub Failed Error 18 2words4uready Linux - Newbie 5 06-12-2008 05:37 PM
Grub error 17, and wont reinstall using grub-install! chiefreborn Linux - General 6 06-06-2007 10:29 AM
Grub Error 17: Cannot mount selected partition and other Grub problems Sebastian Naitsabes Linux - General 1 07-05-2005 08:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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