LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-26-2009, 01:57 AM   #1
chadwick
Member
 
Registered: Apr 2005
Location: At the 100th Meridian where the great plains begin
Distribution: Debian Testing on T60 laptop
Posts: 105

Rep: Reputation: 17
GRUB Error 17 and a buggered up partition table


I made the mistake of trying to resize some of my partitions yesterday. Unfortunately, gparted exited with an error, and today I've been having the interesting exercise of trying to get my system to boot properly, along with the fact that one of the partitions (the one with the contents of /opt, not an important one, and everything should work perfectly fine without it) is nowhere to be found using testdisk.

Fortunately I have backups of my important data, but I'm pretty sure it's possible to just fix this issue without having to reinstall the operating system. The partitions that I can find appear to be intact. I feel like I'm close, but don't know enough about how to use programs like fdisk and checkdisk and grub, so I'm kind of poking around in the dark and would appreciate some help.

Before I buggered up the system, my ATA hard drive looked like this:
Code:
  
#1	P	ntfs    WINDOWS  	
#3	P 	ext3 	/boot
#4    EXTENDED
#5	L	ext3 	/
#6	L	ext3 	/opt
#7	L	ext3 	/usr/local
#8	L	swap 	swap
#9	L	ext3 	/home
#2	P	fat32   IBM LENOVO RECOVERY PARTITION

P=primary
L=logical
Here they're listed in the order that they appear physically on the drive, from low to high sector number.
I can't remember which was set as bootable, but for the sake of getting it to work again I'll just go with whatever works, and forget about what it was set as before.

My /boot/grub/menu.lst was:
Code:
#A bunch of lines preceded by the number sign (#) which I'm assuming are comments so I'm leaving them out. 
## ## End Default Options ##

title		Debian GNU/Linux, kernel 2.6.26-2-686
root		(hd0,2)
kernel		/vmlinuz-2.6.26-2-686 root=/dev/sda5 ro 
initrd		/initrd.img-2.6.26-2-686

title		Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root		(hd0,2)
kernel		/vmlinuz-2.6.26-2-686 root=/dev/sda5 ro single
initrd		/initrd.img-2.6.26-2-686

title		Debian GNU/Linux, kernel 2.6.26-1-686
root		(hd0,2)
kernel		/vmlinuz-2.6.26-1-686 root=/dev/sda5 ro 
initrd		/initrd.img-2.6.26-1-686

title		Debian GNU/Linux, kernel 2.6.26-1-686 (single-user mode)
root		(hd0,2)
kernel		/vmlinuz-2.6.26-1-686 root=/dev/sda5 ro single
initrd		/initrd.img-2.6.26-1-686

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title		Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title		Windows XP Home Edition
root		(hd0,0)
savedefault
chainloader	+1


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda2
title		ThinkVantage Rescue and Recovery 3          
root		(hd0,1)
savedefault
chainloader	+1
After gparted exited with an error, gparted itself claimed that there were no partitions whatsoever on the drive. So I decided to see what testdisk said instead. As you'll see, I'm not very well-versed in testdisk, although I was able to find all of the partitions except for the /opt partition.

Now after writing a new partition table using testdisk, fdisk -l says that my drive looks like:

Code:
root@Microknoppix:/home/knoppix# fdisk -l

Disk /dev/sda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xcccdcccd

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        2305    18514881    7  HPFS/NTFS        <- WINDOWS
/dev/sda2   *        2306        2314       72292+  83  Linux            <- /boot 
/dev/sda3            2315       11515    73907032+   f  W95 Ext'd (LBA)  
/dev/sda4           11516       12161     5186632+   c  W95 FAT32 (LBA)  <- IBM LENOVO RECOVERY
/dev/sda5            2315        2991     5437971   83  Linux            <- /
/dev/sda6            2992        3164     1389591   83  Linux            <- /usr/local
/dev/sda7            3784        4160     3028221   82  Linux swap / Solaris 
/dev/sda8            4161       10944    54492448+  83  Linux            <- /home 

Disk /dev/sdb: 4007 MB, 4007624704 bytes
32 heads, 63 sectors/track, 3882 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Disk identifier: 0x62517944

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3882     3913024+   b  W95 FAT32

Disk /dev/sdc: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x41ffc810

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1       38913   312568641   83  Linux
I added some comments preceded by a "<-" to show what partition number is now what. I'm sure there are plenty of things wrong with this, and this is probably the source of the problem. As you can see, the partition numbers have changed. There's also something weird now about how the IBM partition is labeled with an ID of c, and is partition 4, right after the extended partition. It seems to be telling me that the extended partition is W95, same as sda4, which is weird.
sda5,sda6,sda7 and sda8 are the ones that are supposed to be logical partitions inside the extended partition.

Anyway, I naively hoped that I could ignore these questions and just go ahead and change my /boot/grub/menu.lst to:

Code:
title		Debian GNU/Linux, kernel 2.6.26-2-686
root		(hd0,2)
kernel		/vmlinuz-2.6.26-2-686 root=/dev/sda5 ro 
initrd		/initrd.img-2.6.26-2-686

title		Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root		(hd0,2)
kernel		/vmlinuz-2.6.26-2-686 root=/dev/sda5 ro single
initrd		/initrd.img-2.6.26-2-686

title		Debian GNU/Linux, kernel 2.6.26-1-686
root		(hd0,2)
kernel		/vmlinuz-2.6.26-1-686 root=/dev/sda5 ro 
initrd		/initrd.img-2.6.26-1-686

title		Debian GNU/Linux, kernel 2.6.26-1-686 (single-user mode)
root		(hd0,2)
kernel		/vmlinuz-2.6.26-1-686 root=/dev/sda5 ro single
initrd		/initrd.img-2.6.26-1-686

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title		Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title		Windows XP Home Edition
root		(hd0,0)
savedefault
chainloader	+1


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda2
title		ThinkVantage Rescue and Recovery 3          
root		(hd0,1)
savedefault
chainloader	+1
So I hoped maybe I'd at least be able to boot into Linux, but with no such luck. Instead I get the GRUB error 17.

Does anyone have any advice on this? If someone's familiar with using fdisk, testdisk or something similar then any help would be much appreciated.

Let me know if there's some info I may have left out.

Thanks.

Last edited by chadwick; 07-26-2009 at 02:01 AM.
 
Old 07-26-2009, 04:30 AM   #2
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
When did you get GRUB error 17 ?
When you try to start linux ?
You're menu.lst stated for Debian (Hd0,2) that is sda 3
sda2 is (hd0,1)
As far as I see it SDA3 w95 ext
 
Old 07-26-2009, 05:06 AM   #3
chigurh8
Member
 
Registered: Jul 2009
Distribution: Ubuntu, Gentoo
Posts: 102

Rep: Reputation: 18
I would say pretty much the same thing.
hd(0,2) corresponds to sda3. Your boot partition would be hd(0,1).
What is the sda3 W95 Ext'd (LBA) partition for?

I have experience with fdisk and GParted ... but what exactly did you do to the hard disk between the original layout and what it ended up?
The GRUB error 17 is "cannot mount the selected partition", by the way.
 
Old 07-26-2009, 01:17 PM   #4
chadwick
Member
 
Registered: Apr 2005
Location: At the 100th Meridian where the great plains begin
Distribution: Debian Testing on T60 laptop
Posts: 105

Original Poster
Rep: Reputation: 17
Thanks guys.

I am getting grub error 17 and I now think that my menu.lst is as you suggest:
Code:
## ## End Default Options ##

title           Debian GNU/Linux, kernel 2.6.26-2-686
root            (hd0,1)
kernel          /vmlinuz-2.6.26-2-686 root=/dev/sda5 ro 
initrd          /initrd.img-2.6.26-2-686

title           Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root            (hd0,1)
kernel          /vmlinuz-2.6.26-2-686 root=/dev/sda5 ro single
initrd          /initrd.img-2.6.26-2-686

title           Debian GNU/Linux, kernel 2.6.26-1-686
root            (hd0,1)
kernel          /vmlinuz-2.6.26-1-686 root=/dev/sda5 ro 
initrd          /initrd.img-2.6.26-1-686

title           Debian GNU/Linux, kernel 2.6.26-1-686 (single-user mode)
root            (hd0,1)
kernel          /vmlinuz-2.6.26-1-686 root=/dev/sda5 ro single
initrd          /initrd.img-2.6.26-1-686

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title           Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title           Windows XP Home Edition
root            (hd0,0)
savedefault
chainloader     +1


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda2
title           ThinkVantage Rescue and Recovery 3          
root            (hd0,3)
savedefault
chainloader     +1
Between when everything worked and now, here's how it went:

1) Before using gparted, I ran out of space on the / partition. So I wanted to use GParted in order to grow that partition. In order to do so, I needed to shrink /home, and then move /swap, /usr/local and /opt all to the right. This worked until getting to /opt, at which point it wasn't able to finish and instead reported an error.

2) I tried to run gparted again, but then it told me that there were no partitions on the drive.

3) I was able to boot into linux using the CTRL-D option at bootup, but for example I couldn't find list the contents of the directory ~ (I'm just going by memory). So even though gparted saw no partitions, I was able to boot into Linux, albeit a poorly working version of linux.

4) I booted into Knoppix and am now trying to use testdisk to restore the partition table. After doing this, gparted sees the partitions that I've listed as output of fdisk -l in my first post.

When I use testdisk, I don't use a very advanced method, and as I say I'm kind of poking around in the dark. I just do the following.

i) Call testdisk from command prompt.

ii) Choose to create a new log file.

iii) Select /dev/sda as the disk to look at.

iv) Select partition type "Intel/PC partition"

v) Then to decide what to do with the disk, select "[ Analyse ] Analyse current partition structure and search for lost partitions"

vi) Then select "Quick Search: try to locate partition"

vii) After doing so, it looks like this:

Code:
TestDisk 6.10, Data Recovery Utility, July 2008
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sda - 100 GB / 93 GiB - CHS 12162 255 63
     Partition               Start        End    Size in sectors
D HPFS - NTFS              0   1  1  2304 254 63   37029762 [IBM_PRELOAD]
D Linux                 2305   0  1  2313 254 63     144585
D Linux                 2314   1  1  2990 254 63   10875942
D Linux                 2991   1  1  3163 254 63    2779182
D Linux Swap            3272   1  1  3648 254 63    6056442
D Linux Swap            3783   1  1  4159 254 63    6056442
D Linux                 4160   1  1 10943 254 63  108984897
D Linux Swap           11101   0  1 11477 254 63    6056505
D Linux                11478   0  1 11511 254 63     546210
D FAT32 LBA            11515  75  1 12160 254 63   10373265 [IBM_SERVICE]



Structure: Ok.  Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
*=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
Keys A: add partition, L: load backup, T: change type, P: list files,
     Enter: to continue
viii) The way it's set up like that, it says that all the partitions are deleted (D). So now the goal is to write a new partition table so that these partitions show up when they're supposed to.

I say the following (see the P,D,L on the left):
Code:
TestDisk 6.10, Data Recovery Utility, July 2008
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sda - 100 GB / 93 GiB - CHS 12162 255 63
     Partition               Start        End    Size in sectors
P HPFS - NTFS              0   1  1  2304 254 63   37029762 [IBM_PRELOAD]
* Linux                 2305   0  1  2313 254 63     144585
L Linux                 2314   1  1  2990 254 63   10875942
L Linux                 2991   1  1  3163 254 63    2779182
D Linux Swap            3272   1  1  3648 254 63    6056442
L Linux Swap            3783   1  1  4159 254 63    6056442
L Linux                 4160   1  1 10943 254 63  108984897
D Linux Swap           11101   0  1 11477 254 63    6056505
D Linux                11478   0  1 11511 254 63     546210
P FAT32 LBA            11515  75  1 12160 254 63   10373265 [IBM_SERVICE]



Structure: Ok.  Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
*=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
Keys A: add partition, L: load backup, T: change type, 
     Enter: to continue
Swap occurs three times although there's only supposed to be one of them. There's some empty space on the drive before the IBM rescue partition (called [IBM_SERVICE]), i.e. there's supposed to be empty space between 10944 and 11514. This is where one of the extraneous Swaps occurs and also where what seems to be an extraneous portion of some ext3fs partition. There's also some empty space where /opt used to be, and this is where another instance of Swap occurs. So I'm leaving these extraneous partitions as deleted.

I click enter to proceed, then select [Write] to write the partition structure to disk.

Then I try to reboot and that's when I get grub error 17.

I have no idea why I now have a W95 Ext'd (LBA) partition.
Thanks for asking though. When running testdisk, I select the P and L in the column on the left in hope that it will set up an extended partition for me that contains logical partitions / , /usr/local , swap , /home since this is how it was set up when it was working (see how I describe the layout of my hard drive when it was working).

All of these partitions that are supposed to exist as logical partitions are formatted as ext3fs, so I don't understand what the reference to W95 is for. The IBM partition is FAT32. Does W95 mean Windows 95 or something? I'm having a bit of a hard time finding the appropriate documentation that will tell me what all of these abbreviations are or how to proceed properly in testdisk so that I actually know that I'm setting up the partition table properly.

I think I'm going to try to figure out how to do this from within fdisk since that might allow for a bit more control. If there are any suggestions on a different program to use, or a better way to proceed with one of the programs that I've already been using, or some good tutorials, then please let me know.

Okay thanks again.

Last edited by chadwick; 07-26-2009 at 01:37 PM.
 
Old 07-26-2009, 04:26 PM   #5
chadwick
Member
 
Registered: Apr 2005
Location: At the 100th Meridian where the great plains begin
Distribution: Debian Testing on T60 laptop
Posts: 105

Original Poster
Rep: Reputation: 17
Many thanks guys. I've got this fixed. I'm writing this now booted from my hard drive.

I used fdisk to write the partition table instead of just hoping that/wondering if testdisk was doing it correctly.

Testdisk was indispensable in letting me to find out where the partitions were supposed to start and stop, but I didn't find it very useful for actually writing the partition table in the proper way.

I used the partition table created by testdisk to tell me where to start and stop each partition, but fdisk gave me more flexibility of changing what file system type they should be and so on. I found the following howto to be helpful:
http://tldp.org/HOWTO/Partition/fdis...ing.html#mixed

One thing you have to watch out for is the fact that testdisk starts at 0 whereas fdisk starts at 1, so if you're not careful you can end up with off-by-one errors.

But once you're in fdisk, the help menus are really nicely laid out, so if there are any issues you can refer to the help menus.

I wrote the old partition table to be like it was before I used gparted, and then when that was done, I went back to the old /boot/grub/menu.lst that was there before I used gparted.

The only thing now is that at bootup it tells me that /dev/sda6 is not formatted properly (that's the missing /opt which indeed is not formatted properly). So I'll just format that and I'm crossing my fingers that everything's fixed.

Last edited by chadwick; 07-26-2009 at 04:28 PM.
 
Old 07-26-2009, 05:30 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,139

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
I find sfdisk best for partition table backups - it creates a txt file you feed back to it to recreate the partition table.
Like all backups, no help if not done in advance of being needed. I use a USB key to ensure it is available when I need it.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Unknown Partition Table Signature" error when making a grub boot floppy ? uncle-c Linux - General 2 02-02-2008 05:29 AM
GRUB and partition table... Balvir Kumar Linux - Hardware 3 07-29-2005 12:39 AM
grub install unknown partition table signature imranakbar Linux - Hardware 1 10-31-2004 01:30 AM
FreeBSD invalid partition table error gmalleus *BSD 4 10-22-2003 11:58 PM
Arrg... Messed up Grub and partition table... raid517 Linux - Software 1 10-09-2003 06:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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