LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 07-16-2010, 09:37 AM   #16
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

I used (hd2) in thinking since your USB disk is sdc so there must be sda and sdb. The corresponding names to Grub2 are therefore (hd0), (hd1) and (hd2).

To solve the mystery can you post here the output of
Code:
sudo fdisk -l
Also after (hd1) and (hd0) in Grub2 "ls" command you should get (hd0,1), (hd0,2)....etc. Can you confirm the number of partitions in both (hd0) and (hd1). This information can then correlated with "fdisk-l" in Linux.

It has been known that for some mobo booting from a USB device is only possible if the Bios function "legacy USB support" is switched on. If the mobo does not have this function then it can either able to do it automatically or technically unable to carry out such a task.

The mkrescue is a system command and might require you to be in root.

Thus you can either prefix the command with "sudo", like "sudo mkrescue ...." or you type "su" once, supply your password and then able to work with the system commands untit you exit the terminal.

Last edited by saikee; 07-16-2010 at 09:40 AM.
 
1 members found this post helpful.
Old 07-16-2010, 10:47 PM   #17
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Sorry, I did not notice that this has jumped to page-2 - hence the delay!

Now, the output as you requested for sudo fdisk -l :

cr@cr-ub10:~$ sudo fdisk -l
[sudo] password for cr:

Disk /dev/sdb: 40.1 GB, 40060403712 bytes
255 heads, 63 sectors/track, 4870 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00049ce0

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 1046 8401963+ b W95 FAT32
/dev/sdb2 1047 4870 30716249+ f W95 Ext'd (LBA)
/dev/sdb5 1047 2092 8401963+ 83 Linux
/dev/sdb6 2093 3138 8401920 83 Linux
/dev/sdb7 3139 4087 7622811 83 Linux
/dev/sdb8 4088 4609 4192933+ b W95 FAT32
/dev/sdb9 4610 4870 2096451 82 Linux swap / Solaris

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00070b56

Device Boot Start End Blocks Id System
/dev/sda1 * 1 3916 31455238+ c W95 FAT32 (LBA)
/dev/sda2 3917 19457 124833082+ 5 Extended
/dev/sda5 3917 7832 31455238+ b W95 FAT32
/dev/sda6 7833 11748 31455238+ b W95 FAT32
/dev/sda7 11749 15664 31455238+ b W95 FAT32
/dev/sda8 15665 19457 30467241 b W95 FAT32

Disk /dev/sdc: 1027 MB, 1027603456 bytes
255 heads, 63 sectors/track, 124 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x01040a50

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 125 1003487+ c W95 FAT32 (LBA)
Partition 1 has different physical/logical endings:
phys=(123, 254, 63) logical=(124, 237, 47)
cr@cr-ub10:~$

Meanwhile, since it was not booting to USB - I tried out another USB (which I had used for booting SLAX, which I formated - to eliminate the possibility of unbootable USB).

Still, it is not booting after grub2 was installed on it.

Moreover, at grub prompt - the command "ls" only shows (hd0) and (hd1) with all their respective partitions.

Thanks s far...
 
Old 07-17-2010, 12:36 AM   #18
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Finally, for the grub rescue cd part, this was generated and a cd was written.
This was the terminal commands, and the output messages :
Quote:
cr@cr-ub10:~$ grub-mkrescue -h
Usage: /usr/bin/grub-mkrescue [OPTION] SOURCE...
Make GRUB rescue image.

-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--output=FILE save output in FILE [required]

/usr/bin/grub-mkrescue generates a bootable rescue image with specified source files or directories.

Report bugs to <bug-grub@gnu.org>.

cr@cr-ub10:~$ sudo grub-mkrescue -v
/usr/bin/grub-mkrescue (GNU GRUB 1.98-1ubuntu6)
---------------------------------------------------------------------------
cr@cr-ub10:~$ grub-mkrescue --output=/tmp/grub-rescue.iso
Enabling BIOS support ...
Unknown file type /tmp/grub-mkrescue.7Ajlcy60JV/.. - ignoring and continuing.
Using SEARCH_F.000;1 for /tmp/grub-mkrescue.7Ajlcy60JV/boot/grub/i386-pc/search_fs_uuid.mod (search_fs_file.mod)
Using MULTIBOO.000;1 for /tmp/grub-mkrescue.7Ajlcy60JV/boot/grub/i386-pc/multiboot.mod (multiboot2.mod)
Using PASSWORD.000;1 for /tmp/grub-mkrescue.7Ajlcy60JV/boot/grub/i386-pc/password_pbkdf2.mod (password.mod)
Using GCRY_SHA.000;1 for /tmp/grub-mkrescue.7Ajlcy60JV/boot/grub/i386-pc/gcry_sha256.mod (gcry_sha512.mod)
Using GCRY_SHA.001;1 for /tmp/grub-mkrescue.7Ajlcy60JV/boot/grub/i386-pc/gcry_sha512.mod (gcry_sha1.mod)

Size of boot image is 48 sectors -> No emulation
Total extents actually written = 640
Total translation table size: 0
Total rockridge attributes bytes: 15574
Total directory bytes: 31200
Path table size(bytes): 64
Max brk space used 23000
640 extents written (1 MiB)
cr@cr-ub10:~$
-----------------------------------------------------------------------------
cr@cr-ub10:~$ wodim /tmp/grub-rescue.iso
wodim: No write mode specified.
wodim: Assuming -tao mode.
wodim: Future versions of wodim may have different drive dependent defaults.
wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK limits.
Device was not specified. Trying to find an appropriate drive...
Looking for a CD-R drive to store 1.25 MiB...
Detected CD-R drive: /dev/sr0
Device type : Removable CD-ROM
Version : 5
Response Format: 2
Capabilities :
Vendor_info : 'HL-DT-ST'
Identification : 'DVD-RAM GH22NP20'
Revision : '1.04'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Using generic SCSI-3/mmc DVD-R(W) driver (mmc_mdvd).
Driver flags : SWABAUDIO BURNFREE
Supported modes: PACKET SAO
Speed set to 22160 KB/s
Starting to write CD/DVD at speed 17.0 in real unknown mode for single session.
Last chance to quit, starting real write in 0 seconds. Operation starts.
Track 01: Total bytes read/written: 1310720/1310720 (640 sectors).
cr@cr-ub10:~$
cr@cr-ub10:~$
-----------------------------------------------------------------------------------
 
Old 07-17-2010, 07:30 AM   #19
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
Can I summarize your current status as follow?

(1) Putting Grub2 into a USB stick still not working according to my suggested commands.

(2) You now managed to create a Grub2 bootable CD but its result has not been reported.


I have tested the commands myself and it seems if you format the USB stick to a Ext2/3 filing system everything will work out alright.

This could be a bug or error as Grub2 does not have a shell and relies exclusively on Linux for its installation by using a Bash terminal command "grub-install". In that the developers may not have expected the user to put Grub2 directly into a fat32 partition. I therefore got a complaint saying the filing system not recognised. If the partition you want Grub2 inside is a Ext2/3 type then everything will be perfect. I have successfully booted up my USB stick using exactly the following commands

(A) First I umount my USB stick by command
Code:
umount /dev/sdc1
I have arranged to test my USB stick in a PC with 2 existing disks so that my USB stick is sdc1 too.

(B) I use "cfdisk /dev/sdc" to alter the partition type to 83 for Linux, select "write" and "quit" cfdisk. Then I check the disk layout to make sure sdc1 has a partition type 83 by command
Code:
fdisk -l
(C) I format the sdc1 in Ext2 by command
Code:
mkfs.ext2 /dev/sdc1
(D) I then create a mounting point in /mnt, mount the sdc1 and check it is indeed empty but with "lost + found" inside by
Code:
mkdir /mnt/sdc1
mount /dev/sdc1 /mnt/sdc1
ls /mnt/sdc1
(E) I put Grub2 inside sdc1 (I was using Ubuntu 10.04 which has been shipped with Grub2) by
Code:
grub-install --root-directory=/mnt/sdc1 /dev/sdc
No error was reported. The USB stick can be booted if I specify it as the booting device. If I boot a Grub1 from existing hard disk I need to have it inserted so that the Bios can tell the boot loader in the MBR there is a 3rd disk (hd2). Then I can jump from Grub1 (off hd0) to Grub2 in (hd2) by Grub1 command
Code:
root (hd2)
chainloader +1
The above USB Grub2 installation only boot up to a Grub prompt. If I need a menu, which is /boot/grub/grub.cfg (and possibly /boot/grub/device.map too), I need to copy one from a Linux that uses Grub2, in my case Ubuntu 10.04, and put it in sdc1.

The above is the quick way to put Grub2 in a empty ext2 partition in a USB stick that will fire to a Grub2 prompt which can be used to boot up any "installed" operating system in a PC. Its use is identical to Grub1 except somecommands are slightly different.

Last edited by saikee; 07-17-2010 at 07:36 AM.
 
1 members found this post helpful.
Old 07-17-2010, 11:08 AM   #20
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Ah, am I glad to see your post!!! (I will try out the USB trick a little later, and I am sure your suggesion could be the solution, since I have tried almost everything else - and somewhere along the way, I think I have made a mess of the MBR of (hd1) - and on booting, now it shows a "read error"!

First - yes, the CD is booting to grub prompt and I have all the grub commands available there.

Is there a way to restore the boot menu of hd1 from the CD?

Meanwhile, I will follow your instruction for the USB - using my live 10.04 Ubuntu cd.

I think I am really testing your patience, and I really appreciate your patience.

Warm regards.
 
Old 07-17-2010, 12:49 PM   #21
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
In a normal application your PC only boot up the first hard disk and that should be your (hd0) or sda.

The MBR in the (hd1) is a spare. This is because the boot loader controlling the MBR should be able to boot every partition in every hard disk. The first partition of (hd1) is (hd1,1) in Grub2 term so (hd1) has no usable purpose at all.

Your sdb or (hd1) has Linux inside, right?

My guess is it is in sdb5 which if true can be checked by your newly made bootable CD by command
Code:
set root=(hd1,5)
ls /boot/grub
if it has the Grub2 files inside, like boot.img, core.img and grub.cfg you can fire it up immediately by command
Code:
configfile /boot/grub/grub.cfg
as you have already declare where is its root.

Once Linux in sdb5 has been booted you can choose it to be linked to the following possibilities

(1) Letting the boot up Linux to control the MBR (that is (hd0) or sda you issue this command in a root terminal
Code:
grub-install /dev/sda
(2) Put Grub2 in sda5
Code:
grub-install -force /dev/sdb5
This makes the Linux "chainloadable" in future by commands
Code:
set root=(hd1,5)
chainloader +1
boot
(3) Put Grub2 in (hd1)
Code:
grub-install /dev/sdb
This makes Linux sdb5 bootable if you chainload (hd1) by command
Code:
set root=(hd1)
chainloader +1
boot
Normally you only need Choice (1) but you can have all three if you want them. With a bootable Grub CD you should be able to kiss most of your booting problems good bye.

Don't worry about my patience. Booting is in fact very easy in Linux. You will eventually be able to put 1 and 1 together to get 2.

Last edited by saikee; 07-17-2010 at 01:05 PM.
 
1 members found this post helpful.
Old 07-17-2010, 03:05 PM   #22
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Saikee,

Wow, done it! The USB is now booting to Grub - and I managed to chainload into (hd1) and lo I got the menu which I thought, I had washed away along with the MBR!!

So, now I have a USB and CD booting to Grub - A big thanks to you. Now please help me with this :


Quote:
The above USB Grub2 installation only boot up to a Grub prompt. If I need a menu, which is /boot/grub/grub.cfg (and possibly /boot/grub/device.map too), I need to copy one from a Linux that uses Grub2, in my case Ubuntu 10.04, and put it in sdc1.
Now, how do I get Ubuntu 10.04 into the sdc1, so that I can also have a menu option! I have the image file of Ubuntu 10.04. Kindly help me put that into "sdc1" and help create a menu in the USB!

I don't want to spoil your week-end, but doing this, I had a gr8 weekend!

Regards.

Thanks, you been wonderful, and I now have some idea about this .. This is some achievement..
 
Old 07-17-2010, 03:12 PM   #23
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Please Note :

In the above, I forgot to tell you that my BIOS is not recognizing this USB as a USB. It has gone into the list of Hard Disks!
 
Old 07-17-2010, 05:18 PM   #24
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
To copy a Grub2 menu into a USB flash drive sdc1

When you boot up a Linux its Grub2 menu is /boot/grub/grub.cfg. So if you want to copy it into device sdc1 you mount it first and use a file copying command to move it across.

However when a USB device is attached to a modern Linux it will get mounted automatically by the kernel. In your previous post the mounting position has been confirmed to be /media/usb0. Thereafter you can use a terminal to copy the file across like
Code:
sudo cp /boot/grub/grub.cfg /media/usb0/boot/grub/
The terminal method will always work.

This is no different to you open up one file manger (click "place" and "Home folder" and navigate to /boot/grub to drag grub.cfg to another file manager opened to the folder of /media/usb0/boot/grub. The GUI method sometimes refuses to work if you as a user does not own the files.

To put Ubuntu onto sdc1

This is a new request as your current thread relates to putting Grub2 as a stand alone system.

You do not need Ubuntu put inside sdc1 in order to use the Grub2 menu. The steps described above is all you need. Basically Grub2 when boot to a media like sdc1 will check if grub.cfg exists. It it exists it will execute it otherwise it defaults to a Grub prompt. Therefore having a grub.cfg is the same of having it from the hard disk.

When you put Ubuntu into a flash drive you actually install it and there are two methods.

Method 1 - Normal installation

The flash drive is just a hard disk in Linux so you can install Ubuntu just like you did in the hard disk except you now use sdc1 and not sdb5.

This type of installation is about 3 to 5 times larger than the CD image as many files are expanded and various settings are recorded. As a CD is 700Mb so an installed Ubuntu can be around 3.5Gb. This can take a very long time!!!!!!!!

Once installed your Ubuntu is specific to the PC it has been installed with.

Method 2 - Frugal install

In this method you effective just copy the contents of the Ubuntu CD into sdc1. UBuntu in a CD is shipped to boot from a CD and has the boot loader called ioslinux which boot a filing system created in according to ios9660 standard. Isolinux does not boot a hard disk so you need to change to a hard disk boot loader like Grub2. This part you have already done. Once you copy the contents of Ubuntu CD onto the sdc1 you still need to write instruction to boot Ubuntu. The easiest is to follow isolinux's configuration file and convert it to Grub2.

You can post the ioslinux.cfg here for advice.

If you have no CD drive but just an iso from ubuntu then you need to mount the iso file on a loop back device, kind of like a virtual CD, in order to read/write the contents inside an iso file. The mounting instruction is given in most reference on the mount command, man page of mount etc. I have written a thread showing how to combine several iso into a DVD and then on a flash drive. You can see the details of mounting instruction and conversion of ioslinux to Grub commands (mainly for Grub1).

In a Frugal install you use Ubuntu as a Live CD. The expansion of file takes place in the memory and as a rule settings are not saved but the flash drive can be used on any PC.

Last edited by saikee; 07-17-2010 at 05:21 PM.
 
1 members found this post helpful.
Old 07-18-2010, 12:09 AM   #25
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Saikee,

Thanks a ton for all you have given. All I need for now is to get the menu into the USB. Once, I do that, (and I have been also reading your other posts) I get the confidence to boot my systems (from grub, or otherwise), and like earlier will not have to re-install everything once I mess up the menu! (It has happened many times in the past!)

Once I am a bit familiar with this, I will go further and experiment and understand things better!

So, for now I will just pause and get the grub config file into the usb following your instructions. I will come again to post the final observations. I feel mighty pleased with my efforts - though in your parlance, I may have not even scratched the surface! Of course, all credit to you - to teach a 60 year old the ABC's of grub!

With best regards. I will be seeking you out again, for sure!
 
Old 07-18-2010, 08:56 AM   #26
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Saikee,

Used a brute force method to copy the grub.cfg file into the USB. (had to!) and finally have accomplished everything what I had set out to do! That's a great feeling. Thanks all the way to you.

(why had to!)

As I earlier mentioned, in the course of experimenting, I had overwritten/erased the boot menu/mbr of the the disk which had the XP+Linux OS's. (It was giving a read error). So, I did a "FIXMBR" and "FIXBOOT" with the XP recovery. This erased the Grub menu and it directly boots Windows. (In the normal course, I would be actually reinstalling all the OS's and the programs! Now with the additional knowledge, and after copying the grub.cfg file into USB, I am getting the menu alright and also booting into the system. I know I should be doing a "grub update" - but I don't want to risk a mess-up at this stage - so :

(I will be glad to learn the final tip. To safely reverse the boot menu back to the disk!!)

Warmest regards.
 
Old 07-18-2010, 12:00 PM   #27
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
You can get back to where you were by

Boot up the Ubuntu and do a grub-install to the first boot disk sda.

In root terminal of booted up Ubuntu from sdb5 this command will link your Ubuntu to the MBR of sda
Code:
grub-install /dev/sda
As you are using Ubuntu so it knows where the root partition is. The destination /dev/sda means you want Grub to control the MBR. After this command on a reboot you should see Grub2 screen of the Ubuntu in sdb5. I assume it has the entry to boot your Windows. If it doesn't these entries in /boot/grub/grub.cfg will fire it up
Code:
menyentry 'Winodws in sda1 known to Grub2 as (hd0,1)' {
set root=(hd0,1)
chainloader +1
You can fire up your Windows manually in a Grub prompt with the above commands just by omitting the first "menuentry" statement and add a "boot" statement after "chainloader +1".

Last edited by saikee; 07-18-2010 at 12:04 PM.
 
Old 07-18-2010, 12:48 PM   #28
cr4321
Member
 
Registered: Aug 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Smile

Saikee,

Quote:
cr@cr-ub10:~$ sudo grub-install /dev/sda
Installation finished. No error reported.
Yes, done - and there is no error - so, this should be the happy ending, or a good begining!!

Thanks a lot, and be seeing you. Greatly appreciate your efforts. It was wonderful.

(A point of interest on the side. Since the USB is recognised as a "Drive" in my BIOS, I tried to install Ubuntu 10.04 into a USB after creating partitions. Surprisingly it works - albeit quite slow!)
 
  


Reply

Tags
grub2, menu, multiboot, usb


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to boot from an USB stick without BIOS support using Grub2? vimico Linux - Laptop and Netbook 11 02-25-2012 05:19 PM
how to create usb recovery boot stick? gunzzz5930 Slackware 3 05-18-2010 08:54 PM
GRUB2 - FreeBSD-8.0 does not show up in triple boot menu, dual boot menu it does.. wiliweld *BSD 7 05-03-2010 01:05 PM
Grub2 (1.96) loopback problem on usb-stick ganimo Linux - General 4 10-01-2009 07:26 AM
boot loader on a usb stick gothicbob Linux - Newbie 4 08-19-2007 11:03 AM


All times are GMT -5. The time now is 07:05 PM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration