Government Security
Network Security Resources

Jump to content

Photo

Grub Repair and Tips


  • Please log in to reply
9 replies to this topic

#1 Kenny

Kenny

    Former Commander In Chief

  • Retired Admin
  • 6,747 posts

Posted 28 January 2009 - 03:55 AM

Grub repair tips

One of the most common problems when you have a dual boot option is a dreaded Grub error message at boot up...this can happen for instance if you resize a partition using programs like Gparted in linux...thing is you cannot resize your linux partition if your using it...so to do this you have to "Boot to the Live" distro to make changes to existing partitions.

So ok we resized or deleted partition and allocated free space to expand your drive...now in some cases like mine recently i had one of my systems duel boot with XP pro / Ubuntu 8.10

i decided to delete the XP pro and resize my linux...then i hit on a problem at boot up

i got the dreaded Grub loading error 22 message and could not boot to any OS on the system...so had to manually repair the grub boot loader...here is what i did and it might help others if you have the same problem:

this is not new and a well documented linux procedure am just doing it here for GSO members who might have had the same problem like i did.

ok lets begin:

1)Boot from a live distro ie Ubuntu

2)Open a console

3)type in: sudo grub

4)type in: root (hd and hit the TAB button

this will then show you what physical drives you have and return usually as

root (hd0, or hd1,

hit the TAB again and it will list possible partitions similar to this

grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 07
Partition num: 2, Filesystem type is ext2fs, partition type 083
Partition num: 4, Filesystem type unknown, partition type 07
Partition num: 5, Filesystem type is fat, partition type 0xb
Partition num: 6, Filesystem type is fat, partition type 0xb
Partition num: 7, Filesystem type unknown, partition type 082

The one were interested in is 2 with the ext2fs ... this is the one with the linux installed to

so we type

root(hd0,2)

*caution*

providing hd0 is the main physical partition it could be hd1 remember !!

ok so after you have typed root(hd0,2)

you need to type:

setup (hd0)

close terminal exit live cd and reboot...you should have your grub loader repaired

REMEMBER this is for Linux repair... NOT... windows you need to reset MBR if you deleted linux partition and getting a grub loading error message.
Kenny aka ComSec

Please read the Forum Rules !!!

______________________

#2 Blake

Blake

    Former Commander In Chief

  • Retired Admin
  • 7,334 posts

Posted 28 January 2009 - 05:10 AM

Wow kenny is back with his first tutorial in a long time!

#3 Kenny

Kenny

    Former Commander In Chief

  • Retired Admin
  • 6,747 posts

Posted 28 January 2009 - 09:14 AM

Lol hardly a tutorial blake....just thought i would put it together after the hassle of thinking i had lost everything i had on my ubuntu distro ...

i have just added Fedora 10 to a separate partition on same box for a different flavour and installed both Gnome and KDE desktops...i don't like the new kde look.. i hate widgets..still prefer the classic so reverted to that.. but saying that one program i do like using in fedora is the Yum extender gui... very handy indeed... get it ;)

http://www.yum-exten...s/modules/news/
Kenny aka ComSec

Please read the Forum Rules !!!

______________________

#4 Edu

Edu

    First Sergeant

  • Members
  • 2,269 posts

Posted 28 January 2009 - 01:41 PM

Very nice and user-friendly explanation topic my friend. going to pin it :)
http://www.secumania.net - Secumania security blog.


Embed any executable in a JPEG image and get it to run upon opening the image with this cool tool that abuses a feature of GDI in Windows systems. for governmentsecurity.org members only! click here to get it!

#5 Kenny

Kenny

    Former Commander In Chief

  • Retired Admin
  • 6,747 posts

Posted 28 January 2009 - 03:04 PM

well seeing its pinned and grub tips..... here is another

Clean your Grub via terminal

as we all know once you have installed linux it will often update the kernel ...so when you boot your often have several kernel versions...what i done was first backup

backup type:

sudo cp /boot/grub/menu.lst /boot/grub/menu.lst-backup

am using nano editor

then to edit type:

sudo nano /boot/grub/menu.lst

scroll down to

## ## END DEFAULT OPTIONS ##

then edit or comment out old kernels from the the list

keeping the first two in the list...save it reboot

you have a nice clean looking menu

there are programs to do it in linux...just i like using the terminal method

you can also edit the timeout to bypass waiting if you don't have a 2nd OS installed or deleted old partitions that had previous OS ...the grub will still have them so remove them from the grub as needed

here is a snapshot of one i edited cleaned out as you can see i have just kept the latest kernel for booting...

ie generic and recovery mode

only do this IF YOUR SURE YOU KNOW WHAT YOU ARE DOING as you can see i have deleted old kernels out NOT commented them out which is recommended.

see image:

Attached Files


Kenny aka ComSec

Please read the Forum Rules !!!

______________________

#6 guerillagardens

guerillagardens

    Private First Class

  • Members
  • 58 posts

Posted 02 June 2009 - 10:32 AM

I found Puppy was a good liveOS to use for grub edits - cause it has an easy to use GUI disk mounter, what you can do is, for any partition, just see the grub boot menu

(might need the console to write onto the mounted drives, I can't remember offhand if they mount ro (read only) or not - however, if you want to avoid that anyway you can just copy the menu.lst for the details wanted, then boot into grub as per usual - but use the 'c' command to edit it
(sometimes the edit facility is already listed in the grub menu).

If you do write to the mounted disks (eg, directly from the liveOS), alls you do is select the main boot partitions grub/boot/menu.lst entry - and amend it as you wish, to point to the various installs you may have - and you can get their details from mounting their partitions, and just copying from their menu.lst text file.

One to watch out for, if you install Solaris it uses a customised version of grub - so you kind of have to use the Solaris grub menu to boot anything else on that disk (and possibly also on other disks, depending on your BIOS).
I think that has something to do with Solaris not being bootable from regular grub - that's an official recommendation & I didn't want to mess about with it to see if, well maybe it can....too many headache potentials.
So, don't do what I did and intend to install other OSs after Solaris, as then you always have to boot into Solaris to edit the menu by hand, so the other OSs are on its grub menu - install Solaris last! and overwrite the other grub bootloader.
Also, Puppy for example won't mount zfs and ufs to read (not from the GUI mounter anyway), so the above trick for quick grub edits don't work out there.


Also, & this is a standard well-known too, if you're going to dual (or more) boot with Windows and a different OS type, then Windows always goes on first - ie, install it first, as it has to have written to the MBR at the start of the disk.
Then when grub overwrites the MBR, which should work ok, it won't disrupt the Windows OS booting.
I haven't done this much - I know Puppy installs itself without any issues onto a hard drive that already has Windows on (not with 'frugal' just a regular partition install), & it uses an easy wizard that overwrites the MBR for you (but you do need to know what options to select).
- point being, cause it should work ok, it means that Windows is always bootable from that grub/MBR.

& always put oldest Windows on first, if you're going to install >1 Windows, as newer versions should know about the older versions.
Older versions might have trouble figuring out how to accommodate a newer Windows into the bootloader / MBR.

#7 algorithm

algorithm

    Private

  • Members
  • 1 posts

Posted 13 October 2009 - 10:43 PM

Thanks Kenny for the post. It's very helpful.

Edit: No thanks post allowed. Please read the rules, wD

#8 Game Master

Game Master

    Private

  • Members
  • 1 posts

Posted 08 February 2010 - 04:47 AM

I am gay.


EDITED:

YOU ALSO FORGOT TO ADD YOUR " A TOTAL DICKHEAD "

#9 muntakem

muntakem

    Private

  • Members
  • 4 posts

Posted 14 March 2010 - 01:21 PM

whenever i try too boot PHLAK 0.3 live cd in my laptop (pre installed with vista) i get some error messages !!! The GRUB menu is listed and after choosing any boot option i am displayed several fast paced text and then the following messages :

looking for CDROM in : /dev/ubd[1-9]
warning:unable to find base module !

can't find P.H.L.A.K filesystem, sorry

dropping you to a Busybox shell


Make sure you have a PHLAK base image on your CD-ROM/HDD/Network devices
press RESET button to quit
.
.
.
.
.
.
.
/static/ash:can't access tty: job control turned off
phlak#





are these messages linked to any booting defects or is it just a defect of the iso i used for burning ? Plz help. What boot options can i effectively use to boot PHLAK ?
(For information: i use an intel centrino laptop which uses ati graphics card )

#10 Kenny

Kenny

    Former Commander In Chief

  • Retired Admin
  • 6,747 posts

Posted 15 March 2010 - 04:02 PM

assuming it was burned as a bootable CD for an Image

it don't seem to be reading your cd to boot...

so if its re-writable reburn it...and try again....if still a problem then

have you tried using a flash drive ?

if not the download UNetbootin from here:

http://unetbootin.so...orge.net/#other

point it to the ISO...this will expand it and install a boot loader....then boot it from usb after you change boot options in BIOS (ie boot from usb)

it might solve problem...? if it dont work then the iso might be corrupt... or its a hardware problem not recognising and reading from your CDROM....


or you could use Virtualbox and try installing it that way

http://www.virtualbox.org/

let us know how you get on
Kenny aka ComSec

Please read the Forum Rules !!!

______________________




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users