LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This 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

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 05-13-2007, 04:14 AM   #1
safrout
Member
 
Registered: Mar 2002
Location: egypt
Distribution: Gentoo
Posts: 457
Thanked: 0
Question installing the boatloader on a flash drive instead of hdd's mbr


[Log in to get rid of this advertisement]
Dear All,

i have been away from Linux for a couple of years but i am willing to return now as i missed it soo much

I am currently downloading OpenSuSe 10.2 to install it on my laptop Lenovo 3000 N100,the partition table is as follows

1 20GB for windows
2 20GB for linux
3 30GB NTFS spare drive for storage
4 the lenovo care partition

i want to keep the windows boat loader on the mbr of the hard disk and install Grub or lilo or any boat loader on a small Usb Flash Drive i have , so when i start the laptop when the flash is plugged in the Linux will start, if the UFD is not plugged in it will start windows


is that possible ?

Thanks in advance

Regards,
Ahmad Okda

Last edited by safrout; 05-13-2007 at 04:28 AM..
safrout is offline  
Tag This Post ,
Reply With Quote
Old 05-13-2007, 01:21 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,434
Thanked: 24
Quote:
Originally Posted by safrout
is that possible ?
Yes (is too short an answer).
osor is offline     Reply With Quote
Old 05-13-2007, 01:22 PM   #3
safrout
Member
 
Registered: Mar 2002
Location: egypt
Distribution: Gentoo
Posts: 457
Thanked: 0

Original Poster
thanks for the too short answer

so how can i do it and still be able to use the flash drive for storing files ?
safrout is offline     Reply With Quote
Old 05-13-2007, 02:28 PM   #4
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,012
Blog Entries: 1
Thanked: 20
I have recently just done that.

Here is how.

Your flash pen drive should be in Fat16 format if it is below 2Gb as this is the standard .

You make a /boot/grub partition inside this pen drive.

You then copy the entire content of the /boot/grub from the existing Linux into the /boot/grub of the flash drive. So that you end up with /boot/grub in the flash drive with all the stage1, stage1, fat_stage_1.5, etc inside.

Activate a Grub shell, tell Grub the root is in the current Linux partition 2 and set up Grub in the pen drive's MBR.

I shall give a complete run down of the terminal commands in root with the following assumptions thinking you can adjust for your own circumstance

Say you are running a Pata disk call hda. The second partition will be call hda2. without the pen drive hda is the first bootable disk known to Grub as (hd0) and the partition hda2 will be called (hd0,1) because Grub counts everything from 0.

Now I assume you boot up the Suse Linux, plug the USB flash drive in and discover by root terminal command "fdisk -l" that the flash drive is called sda and there is only one partition sda1 inside.

Commands to get root privilege in Suse terminal
Code:
su
following by root password.

Commands to view every partition of every disk as seen by Linux
Code:
fdisk -l
Commands to mount sda1 if it isn't mounted already
Code:
mount /dev/sda1 /mnt/sda1
Check Suse /media as sda1 may be mount automatically there. I assume the flash drive is in /mnr/sda1.

Command to create /boot/grub in sda1
Code:
mkdir /mnt/sda1/boot
mkdir /mnt/sda1/boot/grub
Commands to copy the content of /boot/grub from the existing Suse to /mnt/sda1
Code:
cd /boot/grub
cp * /mnt/sda1/boot
commands to setup Suse's Grub in the flash drive by a Grub shell
Code:
grub
root (hd0,1)
setup (hd1)
quit
In the above Grub is set up in the MBR of the 2nd disk (hd1) using the root partition information from (hd0,1) or hda2.

Grub will check (hd1) disk to find /boot/grub. If the necessary files are there Grub will report the operation successful. Thereafter your flash drive will be bootable with the same Grub screen as you have now.
-------------------------------------------
The bad news

When you have the flash drive plugged in to boot up the PC the Grub boot loader will be there but your systems will not boot. This is because the flash drive is now regarded by the Bios as (hd0) for being the first bootable disk. The internal hard disk becomes (hd1). The booting instructions from your hard disk assumes hda is (hd0) but now it becomes (hd1) so the booting will fail.

So to boot the two systems successfully you need to edit the /boot/grub/menu.lst in the flash drive to change all "hd0" to "hd1".

-----------------Last word--------------

Suse uses gfxmenu which can rob you the ability to boot the systems "manually". I recommend you to edit the Suse's /boot/grub/menu.lst to put a "#" in front of the line starting with fgxmenu. The "#" will disable the line temporarily and removing it will get you back the original menu. Without gfxmenu you can press "c" at the Grub screen to get a Grub prompt.

In a Grub prompt there is no PC system that Grub cannot boot! but you have to do it manually.

Hope this helps
saikee is offline     Reply With Quote
Old 05-13-2007, 03:10 PM   #5
safrout
Member
 
Registered: Mar 2002
Location: egypt
Distribution: Gentoo
Posts: 457
Thanked: 0

Original Poster
WOW

thanks for the great reply and steps

gonna try it in few minutes and report back

thanks again

EDIT:

well i have a sata hdd which is named /dev/sda and the flash card is called /dev/sdb, guess this won't make any diff in the steps u mentioned , right ?


excuse my noobish question but i always used lilo and have no experience with grub at all

EDIT2:

seems that there is something wrong and i think it si in the part when i type the command "root (hd0,1)"

my hard is set as follows

sda1 windows XP
sda2 lenovo care partition
sda6 swap
sda7 /
sda8 /home

so is (hd0,1) should be changed to anything else ???

now when i try booting from the UFD i get a a black screen with the word "GRUB" keeps appearing one after each other across the whole screen

Last edited by safrout; 05-13-2007 at 03:37 PM..
safrout is offline     Reply With Quote
Old 05-13-2007, 06:04 PM   #6
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,012
Blog Entries: 1
Thanked: 20
sdb for flash drive is expected if your internal hard disk is a Sata.

Unlike Grub Lilo cannot be booted manually and you must validate /etc/lilo.conf every time you edit it. It will be 10 times harder to try with Lilo.

I assume Grub is used as your distro is openSuse which uses Grub by default. The information in Post #5 confirms it is Grub. Grub is easier than Lilo which I also use to multi-boot in USB disks. However I haven't used Lilo in flash drives yet because its 10 times more work.

I actually predict you will have a problem with the partitions because Suse needs a swap which wasn't reported in your Post #1.

Not that I do not trust you but to minimize error why don't you get the information from the horse's mouth by posting here the output of
Code:
fdisk -l
It will tell us every partition in every hard disk you have got and the partition type numbers with which we can identify the filing systems.

I am predicting your sda1 type 7 for ntfs, sda2 type 83 for /boot, sda3 an extended partition, sda6 type 82 for swap, sda7 and sda8 type 83 for Linux. Your sdb1 should be type 6 for fat16 partition.

Your application of root (hd0,1) should be correct but the /boot/grub/menu.lst inside sdb1 needs editing.

You know what, I bet you have not put a "#" in front of the gfxmenu statement as recommended by my last Post #4. You should do it now on sdb1's /boot/grub/menu.lst. That statement asks Grub to load a boot message from (hd0,2) which is now (hd1,2). Therefore Grub is now in trouble because (hd0,2) is in the flash drive which has no 2nd partition. What would you do if you were Mr. Grub?
saikee is offline     Reply With Quote
Old 05-13-2007, 06:41 PM   #7
safrout
Member
 
Registered: Mar 2002
Location: egypt
Distribution: Gentoo
Posts: 457
Thanked: 0

Original Poster
as requested the output of fdisk -l
Code:
Okda-Linux:/home/safrout # fdisk -l

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

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+   7  HPFS/NTFS
/dev/sda2            2551        9099    52604842+   f  W95 Ext'd (LBA)
/dev/sda3            9100        9729     5060475   12  Compaq diagnostics
/dev/sda5            5101        9099    32121936    7  HPFS/NTFS
/dev/sda6            2551        2645      763024+  82  Linux swap / Solaris
/dev/sda7            2646        3646     8040501   83  Linux
/dev/sda8            3647        5100    11679223+  83  Linux

Partition table entries are not in disk order

Disk /dev/sdb: 1000 MB, 1000341504 bytes
16 heads, 32 sectors/track, 3816 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        3816      976880    e  W95 FAT16 (LBA)
Okda-Linux:/home/safrout #
and here it is how my nebu.lst looks like
Code:
## Modified by YaST2. Last modification on Sun May 13 17:23:55 UTC 2007
default 0
timeout 8
#gfxmenu (hd1,6)/boot/message

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 10.2
    root (hd1,6)
    kernel /boot/vmlinuz-2.6.18.2-34-default root=/dev/sda7 vga=0x314    resume=/dev/sda6 splash=silent showopts
    initrd /boot/initrd-2.6.18.2-34-default

###Don't change this comment - YaST2 identifier: Original name: windows###
title Windows
    rootnoverify (hd1,0)
    chainloader (hd1,0)+1

###Don't change this comment - YaST2 identifier: Original name: Vendor diagnostic###
title Vendor diagnostic
    rootnoverify (hd1,0)
    chainloader (hd0,2)+1

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 10.2
    root (hd1,6)
    kernel /boot/vmlinuz-2.6.18.2-34-default root=/dev/sda7 vga=normal showopts ide=nodma apm=off acpi=off noresume nosmp noapic maxcpus=0$
    initrd /boot/initrd-2.6.18.2-34-default
i only mentioned lilo to show u the reason why i a not familiar with the way grub names the partitions but i know that lilo will pita to use in my condition
Thanks for ur help and i really appreciate it

Last edited by safrout; 05-13-2007 at 06:44 PM..
safrout is offline     Reply With Quote
Old 05-13-2007, 07:01 PM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,012
Blog Entries: 1
Thanked: 20
Boot up Suse without the flash drive.

Plug in flash drive. Mount it manually as suggested

Try this in OpenSuse root terminal
Code:
grub
root (hd1,0)
setup (hd1)
quit
reboot
saikee is offline     Reply With Quote
Old 05-14-2007, 09:50 AM   #9
safrout
Member
 
Registered: Mar 2002
Location: egypt
Distribution: Gentoo
Posts: 457
Thanked: 0

Original Poster
IT WORKED

thanks a lot my friend for help
safrout is offline     Reply With Quote
Old 05-14-2007, 07:15 PM   #10
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,012
Blog Entries: 1
Thanked: 20
Glad you got it sorted.

Linux is easy, simple, flexible and powerful to me.

I really see no reason why it can't be the same for you.

Last edited by saikee; 05-14-2007 at 07:18 PM..
saikee is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
LXer: EDGE Tech Corp Announces Portable Flash Drive With Muscle - the New 8GB DiskGO!(TM) Now Available; Swap and Go With This Secure Thumb-Sized Flash Drive LXer Syndicated Linux News 0 12-14-2005 03:16 AM
Installing DSL in a USB Flash Drive GCR DamnSmallLinux 6 11-11-2004 11:40 AM
installing boatloader PlatinumRik Linux - General 2 11-04-2003 10:51 AM
Installing Linux on a USB flash drive!? delphinus Linux - General 4 03-15-2003 07:32 PM
installing Distro onto USB flash drive Tigren Linux - General 1 10-30-2002 08:38 PM


All times are GMT -5. The time now is 08:36 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration