LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Booting Linux from External Hard Disk (https://www.linuxquestions.org/questions/linux-newbie-8/booting-linux-from-external-hard-disk-609055/)

tuse 12-25-2007 12:19 PM

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.

deepumnit 12-25-2007 12:26 PM

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.

tuse 12-26-2007 03:03 AM

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.

deepumnit 12-26-2007 07:17 AM

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

xavierkress 12-26-2007 08:18 AM

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!

saikee 12-26-2007 08:51 AM

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.

tuse 12-27-2007 01:15 AM

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?

saikee 12-27-2007 04:13 AM

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.

xavierkress 12-27-2007 03:12 PM

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?

saikee 12-27-2007 03:58 PM

Download Parted Magic or Gparted Live CD for resizing XP.

For Vista use its internal resizer.

tuse 01-12-2008 09:49 AM

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.

tuse 01-12-2008 09:59 AM

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.

tuse 01-12-2008 12:43 PM

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!

xavierkress 01-14-2008 09:08 AM

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!

kg0l 01-22-2008 08:31 AM

Quote:

Originally Posted by saikee (Post 3001891)
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:confused:


All times are GMT -5. The time now is 01:34 AM.