LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-25-2007, 12:19 PM   #1
tuse
LQ Newbie
 
Registered: Dec 2007
Location: Surathkal, Mangalore, India
Distribution: Ubuntu 7.10, Fedora 7
Posts: 14

Rep: Reputation: 0
Booting Linux from External Hard Disk


I recently bought an external hard disk and installed Ubuntu on it.
I have Windows Vista on my in-built (single) hard disk.

However when I try to boot without the external hard disk plugged in, it shows Grub Error 21.

When I plug it in, it shows me the option to boot using Vista.

What I want to do is: Whenever I do not plug in the USB hard disk, it should boot Vista, and when I do plug it in, it should boot Ubuntu.


I'm an absolute newbie to Linux, any help would be highly appreciated.
 
Old 12-25-2007, 12:26 PM   #2
deepumnit
Member
 
Registered: Dec 2006
Location: NOIDA, India
Distribution: Debian, SUSE, Fedora
Posts: 334
Blog Entries: 1

Rep: Reputation: 31
Well, it seems that your boot files are on the external HDD. Every time you try to boot, your computer tries to fetch those files from the HDD. Do the installation properly.

Last edited by deepumnit; 12-26-2007 at 07:11 AM.
 
Old 12-26-2007, 03:03 AM   #3
tuse
LQ Newbie
 
Registered: Dec 2007
Location: Surathkal, Mangalore, India
Distribution: Ubuntu 7.10, Fedora 7
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks for the reply.


How do I put the GRUB files on my internal HD during the installation?

Because I'm installing Ubuntu on the external HD. I have only Windows Vista on the Internal Hard Disk.
 
Old 12-26-2007, 07:17 AM   #4
deepumnit
Member
 
Registered: Dec 2006
Location: NOIDA, India
Distribution: Debian, SUSE, Fedora
Posts: 334
Blog Entries: 1

Rep: Reputation: 31
Although I have never done this before, I can suggest to help you. How did you install Ubuntu? I mean, did you connect the USB drive to Windows and install Ubuntu on the USB drive? Also check in the BIOS for boot priority. Here, just set the boot priority in the order:
  1. USB drive - external
  2. HDD
  3. CD etc
 
Old 12-26-2007, 08:18 AM   #5
xavierkress
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
I have a question on this also. I installed Ubuntu on my external drive and get the same message. (Error 21). When I'm installing Ubuntu what do I change the GRUB to in the Advanced tab for Ubuntu 7.10? (/dev/sda) is the current main drive with XP. /dev/sdb is the external hard drive with Linux installed on it.

What are the exact check boxes to choose when I install GRUB and Ubuntu 7.10 to make sure that if I don't have the Linux external drive (USB) hooked up it will run the Windows XP OS?

Thanks!
 
Old 12-26-2007, 08:51 AM   #6
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
tuse & xavierkress,

I think your problem is more serious than many anticipate.

Your internal disk has a Vista. Its boot loader has been overwritten by Grub. That is why you get Grub when there is no Ubuntu around.

You installed Ubuntu as the 2nd disk, Vista as the 1st disk and Grub is part of Ubuntu residing in the 2nd disk.

When the 2nd disk is missing Grub can not function because it can't find the rest of itself. Error 21=selected disk does not exist.

-----------------------------------------------------------------------------------------------------------

Cure for booting Vista when 2nd disk absent and Ubuntu when 2nd disk is attached.

(1) Hook back the 2nd disk and boot up Vista.
(2) In Vista right click "Computer" then left double click "manage", then "storage" and "disk management" to fire up the disk management program.
(3) Highlight the Vista partition, use its function to reduce the partition to obtain 1Gb of free hard disk space at the end.
(4) Reboot vista to make sure everything works correctly in a slightly smaller size.
(5) Boot up Ubuntu, click Application/Accessories/terminal
(6) Use this command to partition the new free space in Vista disk
Code:
sudo su 
cfdisk /dev/sda
If the program shows up the first partition has type 7 for ntfs and there is a free space of 1Gb then highlight the free space, create a primary partition, use "type" to change it to type "c" for fat32, select "write" to write the new partition table, re-confirm with "yes" and click "quit". The new partition should be sda2.

There is a slight possibility that if you have a Pata disk and are using an old version of Ubuntu the Vista disk may be called hda instead of sda. In such a case just change everything from sda to hda in the above and below.

(7) Format the new sda2 partition to fat32 filing system by command
Code:
mkdosfs -F32 /dev/sda2
(8) Make a mounting point and mount this new partition in Ubuntu by command
Code:
mkdir /mnt/sda2
mount /dev/sda2 /mnt/sda2
(9) Copy the Ubuntu /boot directory into the new sda2 partition by command
Code:
mkdir /mnt/sda2/boot
cp -r /boot/* /mnt/boot/
(10) set up Grub in /dev/sda2
Code:
grub
root (hd0,1)
setup (hd0)
quit
(10) Exit Ubuntu, power down, remove the external disk and your will find your wish has been granted.

Explanation -- In the above you duplicate the Grub in Ubuntu and put it in a new partition at the back of the Vista disk. Thus Grub can operate without the external disk attached.

Changing Grub does not help you guys here before the Grub configuration is /boot/grub/menu.lst. It is in the Ubuntu disk. Therefore changing it 1000 times but with it detached is not a cure.

Last edited by saikee; 12-26-2007 at 08:54 AM.
 
Old 12-27-2007, 01:15 AM   #7
tuse
LQ Newbie
 
Registered: Dec 2007
Location: Surathkal, Mangalore, India
Distribution: Ubuntu 7.10, Fedora 7
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you for you reply!

I already have an sda2 but its my recovery drive-windows partition.
So can I duplicate the GRUB onto it?
 
Old 12-27-2007, 04:13 AM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
Grub cannot read a ntfs partition and therefore cannot be duplicated into it.

If your sda2 is a fat partition then you can do it, otherwise you have to created a sda3 in fat as suggested.

Wherever a new primary partition is created in your disk it will be sda3 regardless its location, unless it exists already.

Just resize Vista's end and put one in.
 
Old 12-27-2007, 03:12 PM   #9
xavierkress
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
Slight problem, do not have Vista, only XP. XP doesn't seem to allow you to resize the partition on the fly. Any suggestions or work arounds?
 
Old 12-27-2007, 03:58 PM   #10
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
Download Parted Magic or Gparted Live CD for resizing XP.

For Vista use its internal resizer.
 
Old 01-12-2008, 09:49 AM   #11
tuse
LQ Newbie
 
Registered: Dec 2007
Location: Surathkal, Mangalore, India
Distribution: Ubuntu 7.10, Fedora 7
Posts: 14

Original Poster
Rep: Reputation: 0
I did as you said saikee, the difference being I used sda3 instead of sda2.

I am stuck on step number 10.

GRUB says-

"Error 17: Could not mount the selected partition"

after typing in "setup (hd0)" inside GRUB.
 
Old 01-12-2008, 09:59 AM   #12
tuse
LQ Newbie
 
Registered: Dec 2007
Location: Surathkal, Mangalore, India
Distribution: Ubuntu 7.10, Fedora 7
Posts: 14

Original Poster
Rep: Reputation: 0
To add to my previous post, I do see a new drive created in Vista in FAT32 format.
It also has the "boot" directory created.
However, I still get the same "Error 21" when I do not plug in the External hard disk during boot.
 
Old 01-12-2008, 12:43 PM   #13
tuse
LQ Newbie
 
Registered: Dec 2007
Location: Surathkal, Mangalore, India
Distribution: Ubuntu 7.10, Fedora 7
Posts: 14

Original Poster
Rep: Reputation: 0
Thumbs up

I finally got Grub to load without the external disk attached.

I had to slighty change the code given by saikee (it was meant for duplication on sda2, I needed to duplicate it on sda3)

In general,

Steps 1-6 are the same as given by saikee.

Step 7 onwards:

If duplication is needed on partition 'x' then:

replace 2 by 'x'


Step 10:

Code:
grub
root (hd0,x-1)
setup (hd0)
quit

Thanks a lot saikee for your posts!
 
Old 01-14-2008, 09:08 AM   #14
xavierkress
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
I got the external HD disconnected and the laptop working again loading to XP. I just put an XP CD in the drive and knowing that there was only one partition on the laptop I did a Recovery console and fixMBR from the command prompt. That allowed me to put the MBR back on the laptop.

However I think I would have had major issues with accessing other partitions if there were any others than the single partition. Then I would have had to know the configuration for the other partitions and edit that myself in the boot.ini file for XP.

I think this might help. I was scared to do it but with limited time as my wife needed her laptop back for work over the weekend I needed to risk it. Thanks for all the help!
 
Old 01-22-2008, 08:31 AM   #15
kg0l
LQ Newbie
 
Registered: Jan 2008
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by saikee View Post
Cure for booting Vista when 2nd disk absent and Ubuntu when 2nd disk is attached.

(1) Hook back the 2nd disk and boot up Vista.
(2) In Vista right click "Computer" then left double click "manage", then "storage" and "disk management" to fire up the disk management program.
.
how can i get back to vista if i always get error 21 with no 2nd disk.
with 2nd disk automatically boots Ubuntu
 
  


Reply


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
External hard disk partition becomes hidden after booting from linux to WnndowsXP htarko Linux - Hardware 2 08-11-2006 09:59 AM
Booting Linux from external USB hard disk code_monkey Linux - Hardware 5 03-30-2006 01:54 PM
60GB laptop hard disk & 200GB external USB hard disk linux compatibility powah Linux - Hardware 0 03-07-2006 10:55 AM
booting a Linux distro from an external USB2 disk roger64 Linux - General 3 01-02-2005 07:35 AM
booting linux on a external hard drive servo Linux - General 5 04-15-2004 05:26 AM


All times are GMT -5. The time now is 01:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration