Using Grub Rescue to fix a broken Ubuntu system

Asked by Julianloui on 2014-09-09

2014-09-09

I am trying to fix my broken Ubuntu partition table through grub rescue. I know that my boot partiton is /dev/sda5 as it contains the following files in its /boot directory:

vmlinuz-3.13.0-24-genric
initrd.img-3.13.0-24-generic

I saw the following grub-rescue procedure at some Linux-support sites but I haven't been able to use it. Any help will be much appreciated.

(1) set root=(hd0,5)/boot
(2) insmod linux
(3) linux (hd0,5)/boot/vmlinuz-3.13.0-24-generic
(4) initrd (hd0,5)/boot/initrd.img-3.13.0-24-generic
(5) boot

Responses from grub-rescue:
(1) command is accepted OK.
(2) linux is declared an unknown filesystem
(3) linux is declared an unknown command
(4) initrd is declared an unknwon command
(5) boot is declared an unknown command

Julianloui

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gparted Edit question
Assignee:
No assignee Edit question
Last query:
2014-09-12
Last reply:
2014-09-14

Does your /boot folder reside on the same partition as the rest of the OS?

Julianloui (julianloui) said : #2

Andrew,

Yes. I find /boot only in (hd0,5), not in (hd0,6) or (hd0.7). sda2=sda5+sda6+sda7.
Blkid shows /dev/sda5 as ext2, /dev/sda6 as swap, and /dev/sda7 as ext4.
I hope this info helps. Thanks.

Julianloui

If you choot to the non boot partition then mount /boot then you can fix grub.

I have done this myself and the server ISO is really good at this :-)

Ubfan (ubfan1) said : #4

Your set root should be to (hd0,5) not the /boot subdirectory. Not sure what the linux module gives you, but you might use insmod ext2, then try the linux ... lines.

Julianloui (julianloui) said : #5

Andrew,

You mean I should use the Ubuntu 12.04 Livecd? Can I use a Linux Mint Livecd also?

Do I mount /boot by issuing 'sudo mount /dev/sda5 /boot'?

Julianloui

Julianloui (julianloui) said : #6

uban1,

Thank for your kind advice on using grub rescue.

I can run the following two sequential commands without any trouble:
> set root=(hd0,5)
> insmod ext2

But grub rescue rejects the next command mainly because it considers linux an unknown command.
> linux (hd0,5)/boot/vmlinuz-3.13.0-24-generic

Julianlou

Julianloui (julianloui) said : #7

Andrew,

I've just tried the Rescatux grub-repairing livecd. It seemed to work but grub rescue returned as soon as I booted the system.
Have you had any experience with this livecd?

Can you explain your post #3 in more detail? Thanks.

Julianloui

Boot to the Ubuntu Server install media (USB or CD etc)
There is an option to repair a broken OS. You will also be given the option to mount /boot

You can then drop to the terminal and reinstall grub with the command:

sudo grub-install /dev/sda; sudo update-grub; sudo reboot

Should do it.

Why do you even have a separate partition for /boot ?

Boot to the Ubuntu Server install media (USB or CD etc)
There is an option to repair a broken OS. You will also be given the option to mount /boot

You can then drop to the terminal and reinstall grub with the command:

sudo grub-install /dev/sda; sudo update-grub; sudo reboot

Should do it.

Why do you even have a separate partition for /boot ?

Boot to the Ubuntu Server install media (USB or CD etc)
There is an option to repair a broken OS. You will also be given the option to mount /boot

You can then drop to the terminal and reinstall grub with the command:

sudo grub-install /dev/sda; sudo update-grub; sudo reboot

Should do it.

Why do you even have a separate partition for /boot ?

Boot to the Ubuntu Server install media (USB or CD etc)
There is an option to repair a broken OS. You will also be given the option to mount /boot

You can then drop to the terminal and reinstall grub with the command:

sudo grub-install /dev/sda; sudo update-grub; sudo reboot

Should do it.

Why do you even have a separate partition for /boot ?

Sorry for the multiple post. Phone went weird.

Manfred Hampl (m-hampl) said : #13

see https://help.ubuntu.com/community/Grub2/Troubleshooting#grub_rescue.3E-1

"2.The proper paths must be set via the set prefix command.
Many GRUB 2 commands will not work until the correct path is set.
If the path to the grub folder (normally /boot/grub) is not correct, an unknown command or file not found message is likely. "

it seems that your command syntax was not fully correct or incomplete, maybe has to be

set prefix=(hd0,5)/boot/grub
set root=(hd0,5)
linux /boot/vmlinuz-3.13.0-24-genric root=/dev/sda5 ro
initrd /boot/initrd.img-3.13.0-24-generic
boot

Julianloui (julianloui) said : #14

Manfred,

Thank you so much for your suggestion and the excellent grub_rescue guide. I received an "Unknown command' error when I
entered the 'linux' line in your suggested code.

So I next tried to follow the guide's trouble-shooting procedure, step by step. As soon as I got to 'insmod normal' after settiat
ng preifx and root, grub2 declared "file not found". It didn't help even when I entered 'insmod (hd0,5)/boot/grub/normal.mod'.
Since I must pass this essential step first, there was not much I could do next. However, I was able to define initrd and kernel as follows in the meantime after I discovered that they both reside in the root directory of the /dev/sda5 partition.

>kernel=/vmlinuz
>initrd=/inird.img

Now grub_rescue reveals the following status via the set command:

initrd=/initrd.img
kernel=/vmlinuz
prefix=(hd0,5)/boot/grub
root=hd0,5

I guess my next job is to restore normal.mod in this partition's /boot/grub directory. Many thanks again.

Julianloui

Julianloui (julianloui) said : #15

-----------------------------------------------------------------------------------------------------------------------------
"Boot to the Ubuntu Server install media (USB or CD etc)
There is an option to repair a broken OS. You will also be given the option to mount /boot
You can then drop to the terminal and reinstall grub with the command:
sudo grub-install /dev/sda; sudo update-grub; sudo reboot
Should do it.

Why do you even have a separate partition for /boot ?"
-----------------------------------------------------------------------------------------------------------------------------
Andrew,

Thanks very much again.

Can I use my Ubuntu 12.04 livecd? This is the only livecd I have.

As for the separate patition, are you referring to /dev/sda6 or /dev/sda7?

Julianloui

Manfred Hampl (m-hampl) said : #16

It seems I omitted the command

insmod Linux

before the "linux /boot/vmlinuz..." command.

See the grub2 troubleshooting guide for instructions to search for the files, and the required commands.

Julianloui (julianloui) said : #17

Manfred,

I've just searched through my entire broken Ubuntu computer and found omly one file in /boot/grub and it's named grubenv, using an Ubuntu rescue livcd. However, my MacBook-based Ubuntu system does show the normal.mod file in /boot/grub directory and another directory. The grub_rescue guide is really helpful and thorough.

Thanks again.

Julianloui

Julianloui (julianloui) said : #18

Partitions Don't End on Cylinder Boundary!

Andrew and Manfred,

I've now discovered some bad news from 'sodo fdisk -l'. It indicated that all my 4 partitions sda2, sda6, sda7, and sda5 'don't end on cylinder boundary'. Does it mean that the partition table is hopelessly broken?

Julianloui

Manfred Hampl (m-hampl) said : #19

"Partitions Don't End on Cylinder Boundary" is a message that you usually can safely ignore.
In past times when disks were a fixed number of real sectors of real cylinders read with a number of heads, it was recommended to start and end partitions on cylinder boundaries. Nowadays most disks only simulate that they have a fixed number of heads, cylinders and sectors, and the cylinder boundary start/end is no more required.

If your /boot/grub directory is (almost) empty, you have either lost all files, or your setup is different (e.g. with a /boot directory on some other partition).

Julianloui (julianloui) said : #20

Can't Restore Normal.mod to /boot/grub

Manfred,

Thanks again. Using the Ubuntu 32-bit Boot Repair Disk, I was able to restored the missing normal.mod file to my broken Linux computer's /boot/grub directory for the /dev/sda5 partition. However, it failed to appeared in grub_rescue's /dev/sda5's /boot/grub directory. I wasn't able to run 'sudo update-grub' while using the repair disk.

Is there a way to fix this problem?

Julianloui

Did you try the server install media as I suggested?

Did you try the server install media as I suggested?

Manfred Hampl (m-hampl) said : #23

Just putting normal.mod into /dev/sda5's /boot/grub directory is not enough. There have to be dozens of files for grub to be able to work.

Are you sure that you had the boot directory /boot/grub on /dev/sda5 and not maybe /dev/sda7?

what is the output of
ls (hd0,7)
from the grub-rescue prompt?

Maybe showing the output of boot-repair https://help.ubuntu.com/community/Grub2/Troubleshooting#Boot-Repair could also shed some light on the details of your system.

Julianloui (julianloui) said : #24

Manfred,

I've just repeated the following grub-rescue commands.

--------------------------------------(hd0,7)----------------------------------------
>set prefix=(hd0,7)/boot/grub
>set root=(hd0,7)
>set
    prefix=(hd0,7)/boot/grub
    root=hd0,7
>set prefix
>ls /boot/grub
    error: file not found.
>ls (hd0,7)
   error: bad file name

------------------------------------ (hd0,6)-------------------------------------------
>set prefix=(hd0,6)/boot/grub
>set root=(hd0,6)
>set
    prefix=(hd0,6)/boot/grub
    root=hd0,6
>ls /boot/grub
   error: unknwon filesystem
>ls (hd0,6)
   error: unknown filesystem

------------------------------------ (hd0,5)---------------------------------------------
>set prefix=(hd0,5)/boot/grub
>set root=(hd0,5)
>set
    prefix=(hd0,5)/boot/grub
    root=hd0,5
>ls /boot/grub
./ ../ gfxblacklist.txt

>ls (hd0,5)
   error: bad filename
--------------------------------------------------------------------------------------------

Thanks again.
Julianloui

Julianloui (julianloui) said : #25

<<-- UBUNTU SERVER INSTALL MEDIA --->>

Andrew,

"Did you try the server install media as I suggested?"

(1) I don't have the server install media you're referring to. How and where can I download it?
(2) What's its exact name?

Julianloui

You can get it from the same place you got the desktop media you downloaded...... The ISO name has the word 'server' instead of 'desktop'

Julianloui (julianloui) said : #27

Andrew,

I've just burned an Ubuntu-12.04.5-server-i386.iso disk. Can I use it live without installing it on my system? As you know, my aim is to troubleshoot my Ubuntu 12.04 Desktop partition table. Please let me know. Thanks.

Julianloui

Julianloui (julianloui) said : #28

Andrew,

I think I am now left in a very difficult situation. The server installer is displaying the following warning:

"If you have not finished th einstall, your system may be left in an unusable staet. Are you sure you want to exit now?"

PLEASE HELP.

Julianloui

Julianloui (julianloui) said : #29

Andrew,

(1) Please ignore my above post #27 and #28. I've run Rescue Mode without any significant results.

/dev/sda2: Mount fail

/dev/sda5: bash: /usr/share/bash_completion/bash-completion: No such file or directory

/dev/sda6: Mount fail

/dev/sda7: No shell found in target

(2) Can you tell me in detail how to do chroot and other commands you mentioned in an earlier post?

Julianloui

Julianloui (julianloui) said : #30

<<<< Running Rescue Mode in Server Installer Environment >>>>

Andrew,em?

One more question. Does running Rescue Mode in the installer environment imply writing over or destroying my
already broken system?

Thanks.

Julianloui

Julianloui (julianloui) said : #31

2014-09-11
Andrew,

I was able to use Ubuntu Server Disk tonight and found that its prvided the same information as Grub Rescue. I didn't find any
directory named discs in /dev as indicated in the following two commands I saw in an article named " Boot Ubuntu Linux into Rescue Mode to fixsystem.html".

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you need to run fsck command use fdisk -l command to find out partition name. Usually they are located at /dev/discs/discX/partY. For example repair 2nd partition (not mounted as /target) you may type command:

# ls -l /dev/discs/disc0hh
# fsck.ext3 /dev/discs/disc0/part1
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I could mount /dev/sda5 but didn't get much out of the appplication. Oncve again 'ls /boot/grub' confirms that the/booot/ grub directory contains only one and the same fxblacklist.txt file.

Julianloui

Julianloui (julianloui) said : #32

2014-09-11
Andrew,

I was able to use Ubuntu Server Disk tonight and found that its prvided the same information as Grub Rescue. I didn't find any
directory named discs in /dev as indicated in the following two commands I saw in an article named " Boot Ubuntu Linux into Rescue Mode to fixsystem.html".

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you need to run fsck command use fdisk -l command to find out partition name. Usually they are located at /dev/discs/discX/partY. For example repair 2nd partition (not mounted as /target) you may type command:

# ls -l /dev/discs/disc0hh
# fsck.ext3 /dev/discs/disc0/part1
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I could mount /dev/sda5 but didn't get much out of the appplication. Oncve again 'ls /boot/grub' confirms that the/booot/ grub directory contains only one and the same fxblacklist.txt file.

Julianloui

Manfred Hampl (m-hampl) said : #33

Can you try booting into a live system and execute boot-info https://help.ubuntu.com/community/Boot-Info
What is the output?

You aren't installing the server OS. When the CD boots you will get an option that says "fix a broken OS" or similar. Use that.

Julianloui (julianloui) said : #36

Andrew and Manfred,

Immediately after opened up Ubuntu Server Disk, I did inadvertently cllick on 'Install Ubuntu Server" but it didn't seem to have created great damage in spite of the warning message.

I've just run 32-Bit Boot-Repair Disk on my broken system. The URL of the Repair-Info file is htp://paste.ubuntu.com/8328191.
I've looked at it and it's a very long file. Can you two kindly look it over and advise me what to do next?

Many thanks.

Julianloui

Julianloui (julianloui) said : #37

2014-09-12
Andrew and Manfred,

After taking another look at the repair-info file, I'm inclined to think that it would be better for me to try to salvage my personal files from this broken computer than to revive the /dev/sda5 partition. My orinignal Ubutu 12.04 OS seems to have gone for good.

Perhaps I should try Test Disk next. Your advice is appreciated.

Julianloui

Julianloui (julianloui) said : #38

I hope you've received the picture of my sander by now.
Seller

On 09/12/2014 01:03 PM, Julianloui wrote:

>
> Julianloui posted a new comment:
> 2014-09-12
> Andrew and Manfred,
>
> After taking another look at the repair-info file, I'm inclined to think
> that it would be better for me to try to salvage my personal files from
> this broken computer than to revive the /dev/sda5 partition. My
> orinignal Ubutu 12.04 OS seems to have gone for good.
>
> Perhaps I should try Test Disk next. Your advice is appreciated.
>
> Julianloui
>

Manfred Hampl (m-hampl) said : #39

The output of boor-repair shows two severe problems:

1. several files needed by grub are missing on the file system /dev/sda5
2. the file system /dev/sda5 is full (no space left on device)

I assume crating a backup copy of all your important files to external media, and then doing a new clean installation of Ubuntu on the sda device will be the easiest solution.

Trying to revive the current installation would require:
boot into a live system that you can work on /dev/sda5
Identify some files that can be deleted from sda5
Delete these file (or move them elsewhere)
Do an new installation of grub on /deb/sda1 (e.g. by the procedure as shown in actionparsnip's last link)

Can you help with this problem?

Provide an answer of your own, or ask Julianloui for more information if necessary.

To post a message you must log in.