LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 03-31-2014, 10:20 AM   #1
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Rep: Reputation: 26
grub boot loader help


I am messing around with grub on SLES 11.3.
My goal is to clone a hard drive, right now i have sles 11.3 installed from dvd onto a hard drive, with /dev/sda1 as swap 1gb in size and the remainder of the disk as /dev/sda2 formatted as ext3 mounted as /.
I tar'd everything under /dev/sda2 and saved to file.
for a new hard drive i put in the system and format that similarly- if it shows up as /dev/sdb then sdb1 is formatted as 1 or 2 gb swap partition then sdb2 is remainder of the disk as ext3. I mount sdb2 to a working system an untar that image file into /dev/sdb2, thus performing most of the cloning process.

my hangup is grub and the bootloader.
i've tried doing "dd if=/dev/sda of=/root/mbr bs=446 count=1" to save the master boot record of the good working disk built from the sles install dvd,
then doing "dd if=/root/mbr of=/dev/sdb bs=446 count=1" to restore it to the cloned disk. This does not work, when booting the cloned disk I get Error No active partition.
I feel that i am fairly close, i just need to understand grub.
so, can someone explain these options and/or provide me some links on how grub works (see attached pic) ?
The default is "boot from root partition" for grub on my system, should i change that?
From what i've read, the MBR first 446 bytes is the bootloader, the next 64 is the partition table, the next 2 is some identifier. What exactly is going wrong when i try to save the mbr from a working disk and dd it to a new disk ?
thanks
Attached Thumbnails
Click image for larger version

Name:	grub1.jpg
Views:	44
Size:	34.9 KB
ID:	15110  
 
Old 03-31-2014, 09:26 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,121

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by ron7000 View Post
when booting the cloned disk I get Error No active partition.
I feel that i am fairly close, i just need to understand grub.
Maybe, but that message is from the BIOS, not grub.
Turn the boot flag on.

In your previous thread on this very subject last week you were advised against cloning the MBR. All sorts of ways for this to go wrong.
 
Old 04-01-2014, 09:07 AM   #3
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Original Poster
Rep: Reputation: 26
yeah i know i was advised but the more i've been looking into it the more i'm not convinced.
we're talking 512 bytes worth of information, 2 of which are always 55 AA, and 64 bytes is the partition table which i should not need to touch after i've formatted a new disk. so then it's a matter of how grub works and how or what it installs in 446 worth of space and where. if anything i'd like to simply understand what's going on.
and since this thread got moved to the novell forum, is grub tailored in suse/sles and is all this specific to the operating system type? or does everything (people who run redhat, ubuntu, whatever) also have the same grub options as in my attached pic?

if i have time and a spare system i'll continue to play around with the grub options,
my next thought is since the stage1 grub file shows up as 512 in size, is that what gets installed into the MBR if i choose the option "boot from Master Boot Record"... or 446 bytes of it ?
 
Old 04-01-2014, 06:45 PM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,494

Rep: Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488
Quote:
does everything (people who run redhat, ubuntu, whatever) also have the same grub options as in my attached pic?
No, they don't. Most distributions I have used give you the option to install to the mbr, the root filesystem partition or in some cases, not install Grub at all. Opensuse has depending upon your perspective, the most detailed or convoluted bootloader installation of any system I have used. In your image above under Bootloader Settings you have Section Management as well as Bootloader Installation tabs and you also have a tab below for Bootloader Options where you can Set the Active Flag, Write generic code to mbr as well as several other options.
 
Old 04-02-2014, 09:31 AM   #5
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Original Poster
Rep: Reputation: 26
well let me say that the grub 0.97 in sles 11.3 is bugged.
it does not set the active flag in the partition table and fails to install the bootloader properly, unless you are doing everything the first time during a clean install.
most times i get an error saying because of partition table the bootloader cannot be installed.
this is with the default settings for sles during install which wants to have "boot from root partition" selected as shown in my pic. in the past when i've installed sles 11.1, i was able to do the clone process then for the cloned disk i would boot the sles 11.1 dvd and say automatic repair or fix bootloader and it would recognize the problem, fix it, and then everything would work.

the latest test is i did another fresh install of sles 11.3 from dvd and during the install i selected "boot from master boot record" instead. not sure if this is a fix but i've been able to get my clone process to work.
i think the biggest hangup is the active partition flag in partition table.
I've disk dumped (dd) numerous times the first 512 bytes of various disks i've been playing with and identified the 0x80 value at the 0x1CE location in the partition table when the first partition is set to swap and the second partition is the root partition. or if i set things up to use no swap and have only 1 partition on the disk then the location would be 0x1BE. and the byte value of 0x80 is the active flag, i found when i get the error no active partition reported by the bios this location is 0x00.
I know when you repartition a disk if you also tell the partitioner to also create new MSDOS partition table, you definitely wipe the active flag. but if the active flag on a used disk happens to already be set, then you only delete partition and make new ones the active flag hangs around.

so now how do you use dd to change a single byte at a given location ?
i want to throw the value 0x80 into the location 0x1Be or 0x1CE on /dev/sdb.
 
Old 04-02-2014, 09:53 AM   #6
ron7000
Member
 
Registered: Nov 2007
Location: CT
Posts: 248

Original Poster
Rep: Reputation: 26
looks like this did the trick for the partition table.

dd if=/dev/sdb of=mbrnoflag bs=512 count=1

to change the 0x1CE location, decimal 462, which for me means it's /dev/sdb2, and there is a /dev/sdb1 on the disk which i had as swap.

dd if=mbrnoflag of=z1 bs=1 count=462
dd if=mbrnoflag of=z2 bs=1 count=63

cat z1 binary80 z2 > mbrflagset

the file binary80 is exactly that, contains the hex value 80.

if it were the first partition in the table, then change 462 to 446 and change 63 to 79.
 
  


Reply



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
wireless Keyboard not working to select boot options (Grub boot loader) psrini_vasan Fedora 7 12-16-2009 05:45 PM
Unable to boot into GRUB loader: GRUB command shell boots up: urgent issue wombat53 Linux - Software 9 09-04-2009 06:20 AM
How to change from grub boot loader to lilo boot loader linuxjamil Linux - Software 1 05-27-2008 01:47 PM
Two hard disks - dual boot ( XP - Linux ) using microsoft boot loader, not grub cristy88 Linux - General 2 12-17-2007 06:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 10:52 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
Open Source Consulting | Domain Registration