Thursday, October 11, 2007

Installing SuSE on External USB Drive

Introduction

This article provides a guide on installing SuSE to an external USB drive and booting SuSE with existing Windows installation from external USB drive.

Preparation

Things you need:
SuSE Linux installation DVD or CD

And that's all !

Boot

Boot the PC from the installation DVD.

Installation

Follow the setup wizard to the configuration of GRUB, proceed to Installation Summary, select Expert mode, in the Boot Loader Installation tab of Boot Loader Settings dialog, select Boot from Root Partition for the Boot Loader Location option. after the installation, SuSE will reboot automatically. As GRUB is not installed on the MBR, directly booting from HDD will fail. So boot from the installation DVD again, proceed to Installation Mode, select Boot Installed System from Other Options, to complete the installation.

Login as root to the new installation, run grub-install in the terminal:
grub-install /dev/sdb

to install GRUB on the MBR of the external drive.

Notice: Do not install GRUB directly on the MBR of the internal hard disk in the setup wizard, otherwise GRUB will fail to boot when the external drive is removed as it cannot access /boot/grub on the external drive.

Configuring GRUB


If you have one SATA internal HDD and one external USB drive installed, the /boot/grub/device.map would be:
(hd0) /dev/sda
(hd1) /dev/sdb

Notice: When booting from external drive, GRUB will regard the external drive as /dev/sda (hd0) and the internal drive as /dev/sdb (hd1), which is the exact opposite situation when booting from the internal drive.

So edit /boot/grub/menu.lst, replace all hd0 with hd1 and hd1 with hd0.

In case of a future kernel update, /boot/grub/menu.lst will probably be updated by Yast: remember that the same correction (hd0 <-> hd1) will again be necessary.

Additional Steps to Boot Existing Windows Installation from GRUB



As stated before, GURB treat the internal drive as (hd1) and if you directly boot Windows from GRUB, it'll pause after command chainloader (hd1,0)+1 because the Windows boot loader (NTLDR) refuse to boot from a slave hard drive. To fix the problem, add two lines in the Windows entry of /boot/grub/menu.lst:
map (hd0) (hd1)
map (hd1) (hd0)


So the entire entry would be like:
###Don't change this comment - YaST2 identifier: Original name: windows###
title Microsoft Windows XP Professional
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1


Save changes to menu.lst and reboot, the Windows boot loader will work now.

Conclusion

Now the system can boot from SuSE's GRUB when the external drive is pluged and BIOS is configured to boot from external USB device. When the external drive is removed, the system will boot from the internal drive as its original state.

When USB booting fails

Some PCs are not capable of booting from an external USB drive, no matter which BIOS setting you use or what you put into GRUB menu.lst. There are alternative solutions available.

Using internal drive


Another solution is to prepare a small partition in the internal hard drive, format as ext3 and mount /boot at that partition, install GRUB directly to the MBR and configure the BIOS to boot from the internal drive. Remember to plugin the external drive while booting to SuSE. (Remove the external drive won't affect GRUB using this methoed)

Using CD-image of your kernel

It is possible to prepare a bootable CD based on your installed system. The boot-CD will load the kernel and switch over to root-partition on the external USB-drive. However, there is a big gotcha. Default SuSE kernels have USB-drivers as modules making the root-partition unaccessible. You need to compile your own kernel and include USB-drivers in the kernel.

RedHat Linux has a script capable of creating a boot image. Make sure you have mkisofs and syslinux packages installed. Download and save a modified (SuSEfied) version of the bash-script. Check your kernel version (cat /proc/version or ls -l /boot/vmlinuz*) and execute the script:
./mkbootdisk.from.rh4-modified --device boot.iso -v --iso 2.6.18.2-34-default


boot.iso is the filename of ISO image to be created.
2.6.18.2-34-default is the kernel version to be put into the image.

Now burn the ISO-file into a CD and boot from it.

Using the Linux Volume Manager (LVM) for root on the USB disk

If your USB disk uses the Linux Volume Manager (LVM) to contain the root filesystem, the built-in /init script won't find it and will drop to a shell in the initrd environment. To work around this, apply the following patch to /sbin/mkinitrd and re-run it:
--- /root/mkinitrd-orig 2007-03-24 20:54:03.000000000 -0700
+++ mkinitrd 2007-03-24 21:22:26.000000000 -0700
@@ -2445,6 +2445,16 @@
| break;
| fi
| sleep 1
+ EOF
+
+ if [ -n "$root_lvm2" ]; then
+ cat_linuxrc <<-'EOF'
+ | /sbin/lvm vgscan
+ | /sbin/lvm vgchange -ay
+ EOF
+ fi
+
+ cat_linuxrc <<-'EOF'
| echo -n "."
| timeout=$(( $timeout - 1 ))
| done

Reference:Dual Boot Windows with Grub

Labels:

2 Comments:

Blogger domchy said...

Hello,

I allredy installed openSuse on my external usb drive, which have 3 partitions.
As I have some older computer I cannot boot from usb drive. So I made one smaller partition on my internal hard drive (1Gb) and install Grub on it. But when I restart my computer XP (which is on first partition) automatically starts...
How to reach boot loader on small partition to choose, which OS to run?

Many thanks for answer, Domen

October 17, 2007 at 9:51 AM

 
Blogger Unknown said...

Wonderful post! I am highly agree with the publisher's point of view.
Important information corruption situation is always an Inconvenience for the person.
As a way to solve this challenge, the authorities have proposed a lot of personal information restoration solutions.
Just in case of loss of data issue, a user needs to have a knowledge of suitable important information restoration application.
recovering pst files

December 4, 2012 at 11:49 PM

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home