LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   GRUB not working (https://www.linuxquestions.org/questions/linux-newbie-8/grub-not-working-4175419143/)

Ansonite 07-28-2012 09:45 PM

GRUB not working
 
Hi all,

I am having trouble with my hard disk. Previously, I had a working Linux Mint Debian Edition partition and a Windows XP partition, all working and bootable through GRUB.

However, I decided to replace LMDE with Debian, so on my Windows parition I deleted the LMDE parition. I downloaded Debian Live on to a USB flash drive, booted it, however during Debian installation it fails to install GRUB (or any other bootloader it offers). Somewhat confused, I aborted installation and went to reboot into Windows. However, when loading GRUB the error "no such parition" appears, and a rescue prompt appears.

I am not sure how this happened, however I want to try and repair GRUB so I can have both my old Windows XP partiion (it's still fine, I can mount it in Debian) and a fresh Debian 6 partition. Here is my fdisk output:

Code:

user@debian:~$ sudo fdisk -l

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 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: 0x04fa04fa

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1            3297        4864    12580864    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              1        3297    26480641    5  Extended
/dev/sda5  *          1        3157    25355264  83  Linux
/dev/sda6            3157        3297    1124352  82  Linux swap / Solaris

Partition table entries are not in disk order

Disk /dev/sdb: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x20ac7dda

This doesn't look like a partition table
Probably you selected the wrong device.

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1  ?      210559      238826  216435558+  7  HPFS/NTFS
Partition 1 has different physical/logical beginnings (non-Linux?):
    phys=(187, 180, 14) logical=(210558, 221, 10)
Partition 1 has different physical/logical endings:
    phys=(784, 0, 13) logical=(238825, 64, 22)
Partition 1 does not end on cylinder boundary.
/dev/sdb2  ?      213663      341223  976730017  16  Hidden FAT16
Partition 2 has different physical/logical beginnings (non-Linux?):
    phys=(906, 235, 61) logical=(213662, 17, 20)
Partition 2 has different physical/logical endings:
    phys=(262, 116, 59) logical=(60762, 71, 9)
Partition 2 does not end on cylinder boundary.
/dev/sdb3  ?          1          1          0  6f  Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
    phys=(370, 101, 50) logical=(0, 0, 1)
Partition 3 has different physical/logical endings:
    phys=(10, 114, 13) logical=(280460, 46, 4)
Partition 3 does not end on cylinder boundary.
/dev/sdb4            3279      63637  462167897    0  Empty
Partition 4 has different physical/logical beginnings (non-Linux?):
    phys=(0, 0, 0) logical=(3278, 20, 45)
Partition 4 has different physical/logical endings:
    phys=(0, 0, 0) logical=(63636, 236, 34)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

Disk /dev/sdc: 987 MB, 987738624 bytes
31 heads, 61 sectors/track, 1020 cylinders
Units = cylinders of 1891 * 512 = 968192 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

  Device Boot      Start        End      Blocks  Id  System
user@debian:~$

/dev/sda1 is my Windows parition, and /dev/sda5 seems to be my corrupted Debian installation. Not sure about the other one (/dev/sda6 is swap space). I'm not sure what that message under /dev/sda1 means, either.

So would anyone be able to help me in fixing this error?

And I am unable to use apt-get to install packages that may fix this due to lack of Internet connection (had this in LMDE, I needed to install MadWifi which I'll do once I get it set up properly) however if need be I can get and transfer .deb packages from my phone.

Thanks!

gentisle 07-28-2012 10:43 PM

If I am understanding you correctly, you deleted the LMDE partitions from within Windows, and that would be your problem. Windows Disk Adminstrator now called disk management in XP is nothing but problems; I'm leery of even opening it on a multi-OS system. That program will screw up any partition table that has anything on the disk that is NOT NTFS or FAT. I suspect that's how you got these errors:

Quote:

Partition 1 does not end on cylinder boundary.
Partition table entries are not in disk order
This doesn't look like a partition table Probably you selected the wrong device.
I've never even seen that 3rd error, but it looks bad.

If you haven't done anything else to it, you may be able to bring the old LMDE back so you can start from there.

1. You need to back up the partitions of what you have so you can return to that if needed.
sudo dd if=/dev/sda of=/dev/SomeUSBstick/WhateverFileNameUwant.mbr bs=512 count=1

2. Then you need to go backwards in partitioning. So if you tried to install Debian, and it partitioned, then boot it, run fdisk to delete the partitions it created.

3. Or go back into Windows (I think you boot the install disk, select recover w/F5 or something like that and run FIXMBR). Use this as a last resort, it will wipe out GRUB.

4. You may not need to do anything in Windows, if you just delete (w/Linux fdisk) all the other partitions that Debian created, and there is nothing but the sda1 NTFS part.

5. Now from a Linux live disk you can run gpart (use the man command to find out how) and it will try to Guess PARTitions. This will take awhile, and I forget the option it gives, but take the LONG, SLOW route if it asks you. IT should find the old partitions. IF you know the correct sizes, placements, let it restore.

6. After this, you'll probably have to reboot the Linux boot disk. Use fdisk to check and see if the correct partition has the bootable flag set. If so, GRUB *MAY* be restored and working correctly. If it is, and you can boot either Windows or LMDE, then boot your Linux live disk/USB and use the fdisk in the LMDE version or another of the LM editions to delete the LMDE partitions. At this point, if you're going to use Debian, you need to research how the install program handles the partitioning. If you can select empty Linux partitions that are already on the disk, I would create them the way I wanted while I had the LM live disk booted. Then do the Debian install. But if the Debian program expects to do the partitioning, then get rid of everything except the NTFS partition before starting the install.

There should be *NO* partition errors w/a Windows/Linux system. You just have to partition and install correctly. Here's what I do to avoid problems.

A. Boot Linux live and partition for Windows only - no other partition.
B. Install Windows
C. After Windows is installed, finished all it's rebooting through the installation, installing all the drivers, etc., i.e., when it's actually usable, then I
D. Boot Linux live again, partition the rest of the disk, and install Linux.
E. After Linux is installed, and both systems are bootable, I save a copy of the MBR so I can restore if something goes wrong (and w/Windows, it's a matter of when -- not IF).

This MIGHT get you back going, but w/partitioning, there are NO guarentees.
gentile

Ansonite 07-28-2012 11:20 PM

Sounds a bit tricky and I do not have Windows CD or removable media except USB with debian. Can I not remove grub and Debian partitions?

EDDY1 07-28-2012 11:30 PM

Quote:

Originally Posted by Ansonite (Post 4740370)
Sounds a bit tricky and I do not have Windows CD or removable media except USB with debian. Can I not remove grub and Debian partitions?

I almost think that you partitioned sdb, is sdb your usb device?
You can start all over by repairing your windows xp os.
Hiren's-BCD has miniwinsxp you can repair from the command console.
Then you can reinstall whatever linux distro you want.

Ansonite 07-29-2012 03:18 AM

Alright, I have decided that I want to return to my Windows installaion. I will install Debian later on.

I have removed all partitions on my disk apart from the one Windows XP is on (/dev/sda1) and have set the boot flag on this parition.

Code:

Disk /dev/sda: 40.0 GB, 40007761920 bytes
16 heads, 16 sectors/track, 305235 cylinders
Units = cylinders of 256 * 512 = 131072 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x04fa04fa

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *      206889      305176    12580864    7  HPFS/NTFS

I have rebooted several times, however when I reach GRUB it tells me 'no such parition':

Code:

GRUB loading.
Welcome to GRUB!

error: no such parition
Starting rescue mode
grub rescue>

I am thinking and I want to know if it is possible to remove GRUB from my hard drive using the USB that still has Debian Live on it, seeing as I only have one partition -- my Windows one.

On a side note, while the kernel loads with my Debian stick, a warning appears mentioning that my Windows parition is "dirty". I'm not sure what this means or if it relates to the issue, but it says I should run chkdsk on Windows. I can't post the full message as I'm unable to copy it.

Would anyone be able to tell me how it is possible to remove GRUB, still keeping my Windows parition (I don't want to re-install it, as I can't back up and I don't have a Windows CD/image).

Thanks again!

EDDY1 07-29-2012 12:20 PM

You can run chdisk from gpated-live-cd.
You can possibly run fsck from debian live.
I noticed your wins installation is not at beginning of drive did you move it or erase some other partitions?
Winsxp can be reinstalled via i386 folder you just have to findout if it's still there.

z99 07-29-2012 01:49 PM

Quote:

still keeping my Windows parition (I don't want to re-install it, as I can't back up and I don't have a Windows CD/image).
hope this one work.
insert your windows cd then press R for (recovery mode),then press C (console),then enter 1(your windows installation drive 1 for c),and at last type fixmbr

PTrenholme 07-29-2012 02:16 PM

When you get the GRUB rescue prompt, enter the command set and note the value of prefix. That's probably the partition that's missing, and it's the one in which GRUB is trying to look for its grub.cfg file, and all the other files it needs to dynamically load in order to boot properly.

I.e., if you've deleted that partition, you need to re-install GRUB. That can, I believe, be done from inside a Windows system, but - other then telling you to look on-line - I don't know much more than that.

gentisle 07-29-2012 02:35 PM

Try not to give up on this; it's really not that hard. It just takes some time and patience. The software will take care of you most of the time, you just need to understand how to use it so it will work right.

techguru666 08-22-2012 09:36 PM

If you want to remove GRUB from the MBR, you can use dd command:

dd if=/dev/zero of=/dev/sda bs=512 count=1

This will remove GRUB, but remember, then your system won't even show the grub prompt. You will have to install the windows bootloader on the MBR. fixmbr command will install the windows bootloader on MBR.


All times are GMT -5. The time now is 09:04 AM.