LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-03-2007, 02:01 AM   #1
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Rep: Reputation: 34
Smart Boot Manager hack


For those of us who like using SBM (Smart Boot Manager) at one point or another will come across a situation where a partition tool which falsely reports no partitions on the drive and, instead, will usually report the whole drive as one big FAT12 partition.......Partimage is one of those programs, as well as RedHat's Disk Druid and for the Puppy Linux fans, the Pmounter partition tool......For the most part all the various fdisk programs, gparted, and others, have no problem reporting the correct partition table.........This leads me to suspect that maybe it's not entirely the fault of SBM, but the shortcoming of those "buggy" programs that have problems with SBM.....

I consider SBM as one of the best boot managers to put in the MBR....It is able to chainload any bootable partition which contains an operating system's native bootloader, and also has it's own el torito stack for booting CD drives for those old BIOS which cannot boot such a drive.

Well, I finally got tired of it all and decided to investigate the problem.........I started off by looking up the "magic" number that identifies a FAT12 partition, which is 0x01 in hexadecimal.....Next, I opened up a hex editor and took a peek at the primary hard drive (/dev/hda) and did a hex search or '01', which I found at offsets 0x0000000d and 0x0000000e (the 13th and 14th bytes from the beginning, starting with 0).....

Then, I changed only the first offset to a null byte (0x00), fired up partimage, and partimage now reported all the partitions......After saving the change, I rebooted to see if I broke SBM......And what do you know, there was SBM staring me in the face .........I highlighted the appropriate entry to boot me back into the same OS, and everything was working perfectly........

So I decided to write a script to automate the process, using dd to make the appropriate change..........With the hex editor, I changed the offset back to it's original value and first tested dd on the command line with the following command:
Code:
dd if=/dev/zero bs=1 count=1 seek=14 of=/dev/hda
I opened up the hex editor to look at the change, and discovered I changed the wrong offset......I changed the second instance of 0x01 at offset 0x0000000e, not the one before it.............After a bit if head-scratching, I finally figured out where I went wrong..........I was doing the count starting with 1, where I should have started the count with 0.......

Since I was feeling adventurous, I decided to see if that made any difference with partimage..........To my surprise, partimage reported the partitions correctly!.........Here, I was trying to change the very first instance of 0x01, figuring that would do the trick and accidentally discovered that changing the second occurrence also worked..........

I then decided to change both occurrences to null bytes and see what happens.........Partimage still reported all the partitions correctly, so I rebooted to check on the boot manager......After rebooting, SBM still appeared and looking normal........So, again, I highlighted the correct OS, and booted in without any issues.....

So I modified the dd command (getting it right this time) and made the following script for whenever I need to reinstall SBM:
Code:
#! /bin/sh

dd if=/dev/hda bs=16 count=1 of=/sbm.bin       # Save the relevent portion before making the change in the MBR
dd if=/dev/zero bs=1 count=2 seek=13 of=/dev/hda
I saved the script as sbmhack.sh.......I didn't make it executable, just as an added precaution........

For those interested, to run the script you must be root (or have root privileges) and simply run it like so: sh sbmhack.sh.......Using a script will avoid any heartache from possible typos (as long as the script is free of typos )

I hope this will be of help for those who like Smart Boot Manager, like I do...........This is a safe hack as long as you use the script, but I will NOT be responsible for any problems if you decide to do so............You make the choice without any arm-twisting, so it's your responsibility for any problems. YOU HAVE BEEN WARNED!........

But as I said, this is a safe hack and will not cause any data loss by following the instructions carefully and correctly.....

---thegeekster

Last edited by thegeekster; 06-03-2007 at 02:36 AM.
 
Old 06-04-2007, 06:38 AM   #2
DJ_Maiko
Member
 
Registered: Jan 2007
Location: Los Angeles, CA
Distribution: Linux Mint 8, Ubuntu Studio 9.10, DSL 4.1
Posts: 30

Rep: Reputation: 15
you rock!

I'd had some problems trying to install RH 7.02 using its DiskDruid program. Now, I at least have something to try & see if it works after I get some sleep. Thx & I'll post back my results.
 
Old 06-04-2007, 09:00 AM   #3
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Original Poster
Rep: Reputation: 34
If by chance it doesn't work out for you and you want to change things back and you used the script, you can restore the MBR the way it was by cat'ing the saved sbm.bin file:
Code:
cat /sbm.bin > /dev/hda
It will overwrite the first 16 bytes of the MBR, back to what it was before.....

But I'm pretty sure it will do the trick for you, although I don't have any distro which uses DiskDruid, but I also tried it out on the Pmounter utility in Puppy Linux, which was successful......

---thegeekster
 
Old 06-04-2007, 11:20 AM   #4
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Original Poster
Rep: Reputation: 34
*** Update ***

I had a sudden inspiration to possibly make things a bit safer and easier.......I whipped up a little script which will modify or restore the correct bytes........

Copy and paste the following, making it executable, and save it as sbmhack:
Code:
#! /bin/sh
#
# sbmhack - Fixes the Smart Boot Manager installation to allow all programs to
#           correctly read the partition table.
#
# Copyright by CTWaley, June 2007
#
# This script may be used freely, for any purpose.  It is understood that by
# using this script, you assume all responsibility for any possible damages or
# loss of data that may occur.
#

print_usage(){
    echo "USAGE: ${0##*/} modify|restore [device]    # default 'device' is /dev/hda"
}

if ! [ $# -eq 1 -o $# -eq 2 ] ;then
    print_usage >&2  &&  exit 1
fi

case ${1} in
  modify)   HEX='\x00\x00'               ;;
  restore)  HEX='\x01\x01'               ;;
  *)        echo "${0}: ${1}: Invalid option"
            print_usage >&2  &&  exit 1  ;;
esac

DEV="${2:-/dev/hda}"

printf "\xfa\xeb\x5c\x53\x42\x4d\x33\x2e\x37\x2e\x31\x00\x02${HEX}" > ${DEV}  ||  exit $?

echo -e \\tDone!
exit 0
So now, when the occasion arises and you have to [re]install SBM, install it and run the script........This way you won't have to save anything to disk and be able to easily modify or restore the relevent bytes.......

---thegeekster

Last edited by thegeekster; 06-04-2007 at 11:23 AM.
 
Old 06-08-2007, 07:28 PM   #5
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by DJ_Maiko
I'd had some problems trying to install RH 7.02 using its DiskDruid program. Now, I at least have something to try & see if it works after I get some sleep. Thx & I'll post back my results.
Hi DJ,

Did you get the boot situation straightened out?..............I'd really like to know how it turned out....

---thegeekster
 
  


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
Smart Boot Manager & Xandros kreng Linux - General 3 11-09-2006 12:14 AM
SMART package manager? Edwardml Mandriva 6 01-16-2006 04:40 AM
Smart Boot Manager wont boot dos on logical part. AlanL Linux - Software 5 09-01-2005 12:25 AM
Smart boot manager ZalastaQuikos Linux - Newbie 1 07-21-2005 09:42 AM
Unable to use Smart Boot Manager. rvijay Linux - Software 7 02-02-2005 05:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:45 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