Problem with partition table

Hello guys. I’m new to opensuse - i wanted to change to KDE 4.2, because I find gnome is still not yet mature enough to be a base of a good OS. I’ve chose openSuse 11.1.

First, before I tell you about my problem, I’ll make a small introduction : I’ve got a 20 GB partition with Windows XP (now abandoned, cannot remove it), and an ~260GB extended, and inside it : 50 GB WinXP (which I used), 200GB for data, and about 10 GB for linux.

I don’t exactly know why, but because of this setup I cannot remove the 20 GB partition I don’t use it anymore - i tried paragon partition manager, and it cannot remove it because It’s the only one that’s primary, I think. So I changed some system files so that it only booted to 50 GB WinXP. I then installed Ubuntu. GRUB worked fine (ubuntu, ubuntu safe, and win 50 GB to choose), but as I said, I wanted to try opensuse. So I tried installing (installer left 20GB, 50 GB and 200 GB unchanged, it only splt the 10 GB partition for home, root and swap). I then changed GRUB option for WinXP to be the first one and the default entry (don’t know if this matters)

Then after copying files it tried installing GRUB. Here’s what I got (in short, unnecessary info removed)


Error occured while installing GRUB.

GNU GRUB version 0.97

grub> setup --stage2 = /boot/grub/stage2 --force-lba(hd0,1)(hd0,7)

Checking if "/boot/grub/stage1" exists... yes

Checking if "/boot/grub/stage2" exists... yes

Checking if "/boot/grub/e2fs_stage1_5" exists... yes

Running "embed /boot/grub/e2fs_stage1_5(hd0,1)"... failed (this is not fatal)


Running "embed /boot/grub/e2fs_stage1_5(hd0,7)"... failed (this is not fatal)

Running "install --force-lba --stage2=/boot/grub/stage2 /boot/grub/stage1 (hd0,1) /boot/grub/stage2 p /boot/grub/menu.lst" ... failed

Error 22: no such partition

grub>quit

So after rebooting I thought there’s gonna be problem. I’ve experienced bad GRUB installs before with earlier Ubuntus and ‘fixboot’ from WinXP recovery console always fixed it.

After turning PC on, I got a message “No operating system”.

I ran WinXP CD and recovery console, but I don’t know why, instead of “fixboot” I wrote “fixmbr” (I logged in into 50GB partiton, not 20GB). Yes, I know, my fault! I thought it does the same. And after reboot I got: “Invalid partition table”. Then I ran fixboot, and still the same.

Any idea how to get the partition table back to normal? Please! First help me with this, and then we’ll think about how to get GRUB working.

Another thing that might be useful - I don’t know if that’s the cause of GRUB problems, but I often got some sort of sata errors when logging into ubuntu (then it logged into some sort of text console called BusyBox 1.1.3). I’ve read that it’s caused by my onboard SATA chip (JMicron) and some sort of incompatibility between it and linux driver. Anyway, In Ubuntu I fixed it with appending “all_generic_ide floppy=off irqpoll” to boot command line. I’m mentioning it because It might have something to do with partiton and disk errors in linux, because I didn’t append it in opensuse boot CD.

I REALLY hope you can help me! You’re the only ones I can get help from. First, how can I rebuild this partition table?

I found a site, that may be of some help.

Recovering a Lost Partition Table

Otherwise sorry to say but you might be SOL.

Well, I don’t think It’s entirely screwed. I mean, I tried running installer for the second time and it still sees the partitions it makes me think it’s just the computer which cannot “see” something, but the partition table structure is overall ok (I hope so). If we won’t be able to come up with a solution, I’ll hook it up to a different computer - maybe it’ll be able to detect the partitions.

Have you got your data backed up? I would make that the first priority. Can you use a livecd and then mount partitions that way to get access?

i can see ntfs partions in dolphin, but when i try to access it says : "an efror occured while accessing 'volume (ntfs) ; org.freedesktop.hal.device.permissiondeniedbypolicy:org.freedesktop.hal.storagemount.fixed auth_admin_keep_always . so, how can i authenticate myself as admin?

In the kde menu there should be an icon to open dolphin in ‘super user mode’.

“Invalid partition table”
it is very likely that there is no “active/boot” partition or more than 1. Run linux fdisk to check and correct or any other program you know how to use.

So I changed some system files so that it only booted to 50 GB WinXP
If you only have 1 primary partition then the XP’s boot files are on the 20g partition or you were using a third party boot manager in the MBR that allows booting to an extended partition. (there is another way but unlikely you used due to its difficulty to set up).

Before jumping into rebuilding the partition table - this is not trivial - let’s take a look at it. As @LostFarmer has already indicated, it sounds as if the Windows boot code is in the MBR and it cannot either find an active primary in the table (or possibly there is a problem in the boot sector of the partition it does find).

If you have a LiveCD, boot it, open a terminal, switch to root, and do:

fdisk -lu

If you have the DVD, do this booting into Rescue and logging on a root. (And tell us which you have, DVD or LiveCD). While you’re there, let’s take a look at the MBR itself:


dd if=/dev/sda of=mbr bs=512 count=1
xxd mbr

Ok, I’ve got opensuse 11.1 kde 4 liveCD. “fdisk -lu” spits out:


Disk /dev/sda: 320,0 GB, 320072933376 bytes
240 heads, 63 sectors/track, 41345 cylinders, total 625142448 sectorsUnits = sectors of 1 * 512 = 512 bytes
Disk identifier : 0x00000001

    Device Boot   Start   End      Blocks   Id   System
/dev/sda1         63     42078959 21039448+  7  NPFS/NTFS
/dev/sda2 *   42079084  625137344 291529130+ f W95 Ext'd(LBA)

/dev/sda5    42079085  147072239  52496577+  7 NPFS/NTFS

/dev/sda6    147072303  604164959 228546328+ 7 HPFS/NTFS

/dev/sda7    604172583  608381549  2104483+  82 Linux swap / Solaris

/dev/sda8     608381613  618871994  5245191   83 Linux
/dev/sda9    618872058   625137344  3132643+  83 Linux

PS one more thing - I have no idea where is this “launch as superuser” doplin icon, so i tried accessing it via terminal. I logged in as root (sudo su), and moved to /dev/. “ls” shows me allthe sda partitions, but when i try to exectute “cd sda5” for example, it says “bash: cd: sda5: Not a directory”

So i opened /dev/ in dolphin and there are lots of files, also those sda partitions - dolphin description is:
Type: block device
Size: 0B

I know linux makes some kind of “mounting” the volumes one wants to access, and then one can access them i /mnt/ folder. Am I right? How can I mount these partitions? (BTW: /mnt/ is empty, so I’m sure they aren’t mounted)

PPS: Sorry about the triple post, but I cannot edit my messages. Second thing - I read in Internet how to mont partitions, and I made a directory “sda5” in /mnt/, and executed “mount /dev/sda5 /mnt/sda5”

And Terminal switched to new line, and nothing happens. I think it’s working. How long could it take to mount a partiton? Can I Ctrl+C mounting?

To get a few of your questions out of the way first . . . launching an application as root is preferably done by pressing Alt-F2 (the equiv in Windows to Start/Run) and then typing the name of the app preceded by “kdesu” (w/o quotes) in KDE or “gnomesu” in Gnome. The program can also be launched from a terminal after switching to root (the “su” command), but there are technical reasons why the above is better.

Second, what you see under /dev are the block devices. These are created dynamically at boot by udev. These are not mount points. You should stay out of /dev unless you know exactly what you are doing.

Third, re mount points: A mount point is a directory at which the top of a file system is placed; a very different animal than a block device. The pre-defined mount points are in the file /etc/fstab. On your system the filesystem on sda8 is mounted at / (root), and the filesystem on sda9 is mounted at /home under /. The /mnt subdirectory is the traditional location for mounting partition filesystems outside of the root tree (e.g., a separate user data partition), but that is not automatic; usually there will be subdirectories under /mnt (e.g., /mnt/data) for the additional partitions. Personally, I mount my Windows partitions there (i.e., /mnt/XP, /mnt/Vista, /mnt/W7), but the openSUSE installer may set up a new subdirectory under / just for the Windows partitions - usually they are under /windows, e.g., /windows/C, /windows/D. Of course, you will not see any of this from the LiveCD, as it is running an entirely separate OS and root from within RAM.

Finally, let me strongly advise you know exactly what you are doing before running commands as root; root can do virtually anything to the OS including irreparable damage. Re your mount command, if /dev/sda5 was already set up in fstab, you would only need to do “mount /dev/sda5” and the mount program will pull the rest from the file. If not in fstab, then the command would be “mount -t ntfs-3g /dev/sda5 /mnt/sda5” (assuming the /mnt/sda5 directory has already been created).

As far as your table and booting is concerned . . .

You did not post back as requested the contents of the MBR. I surmise from your problem description that you over-wrote the grub code that had been installed there with Windows code. I suggest the first thing you do is try to get Windows to boot. So, boot from the LiveCD, open a terminal, and do:

su -
sfdisk -A1 /dev/sda

Some explanation is needed here. You posted that you did not need the first XP partition, and tried but could not remove it. However, you do need it. Windows ordinarily is installed in the same partition, but also supported is separating what Microsoft calls the “system volume” from the “boot volume”. The “system volume” is the partition where the boot sector and ntldr loader are located; this must be a “primary” other than the “extended primary”; the “boot volume” is the partition where the OS resides and it can on a “logical” within an “extended primary”. If the Windows boot code is in the MBR, then the system volume must also be marked “active”; the sfdisk command above does this. So assuming Windows code in the MBR and that your system volume boot sector is not corrupted (fixboot should have fixed that), then just switching the active flag should get Windows booting again. I am concerned with your description of moving system files around between sda1 and sda5. But let’s try the above first and see if Windows boots.

Additionally, your description of where SuSE and Ubuntu are installed isn’t clear. The grub commands you posted indicate an attempt to put grub’s stage1 in the extended primary’s boot sector calling grub’s stage2 loader from sda8 - is sda8 where SuSE is or is that the Ubuntu partition? In the LiveCD, after doing the sfdisk command above and before rebooting to test Windows, do this:

mkdir /mnt/sda8
mount -t ext3 /dev/sda8 /mnt/sda8
cat /mnt/sda8/etc/grub.conf
cat /mnt/sda8/boot/grub/menu.lst

And post back here the output of the cat commands. If the cat on grub.conf fails and/or the menu.lst is Ubuntu’s (SuSE’s will say “YaST” at the top), then SuSE is on sda9. In that case, do:


mkdir /mnt/sda9
mount -t ext3 /dev/sda9 /mnt/sda9
cat /mnt/sda9/etc/grub.conf
cat /mnt/sda9/boot/grub/menu.lst

Ok, so first of all: doing “mount -t ntfs-3g /dev/sda5 /mnt/sda5” gives me full access to my 200GB partition. Good to know it’s left untouched and nothing bad happened to my data :wink:

Now - I had 3 partitions with swap, /home and / for Ubuntu. openSUSE installer automatically detected them, removed them and automatically made new ones for itself. (So it didn’t alter windows partitions)

“sdfisk -A1 /dev/sda” results in:


Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Done

Now, what does grub.conf include:


setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,7)
quit

And menu.lst (I’ll only write the important parts, it’s a lot of work to re-write it all):


title Windows 
rootnoverify (hd0,0)
chainloader +1

title opensuse 11.1
root (hd0,7)
kernel /boot/vmlinuz-2.6.27.7.9-default root=/dev/disk/by-id/ata-ST3320833AS_4NF1P9NY-part8 resume=/dev/disk/by-id/ara-ST3320833AS_4NF1P9NY-part7 splash=silent showopts vga=0x31a
initrd /boot/initrd-2.6.27.7-9-default

Now Failsafe suse comes (I don't think it's important, basically the same with more boot line options)

So, just to make it clear, I don’t have any Ubuntu partitions at all now. opensuse installer automatically made them ‘it’s own’. Of course menu.lst has those “created in YaST2” comments.

PS.: After I rebooted, my WindowsXP (50 GB one) booted. No GRUB or anything like this. Thanks for your time and patience and the will to help me! Now just one more question - I want to boot opensuse too. Can I somehow install GRUB? (If the opensuse files are still in its partition. I’m sure it would be possible to boot it).

PPS.: So now the error that caused this situation in the first place - why didn’t GRUB want to install? Can you help me with this? Maybe I should’ve altered the GRUB options in the opensuse installer? (because from what I can see, the installer wasn’t able to locate the partition or something like that.

That is good news that you could boot Windows and that your sda6 NTFS data volume is also accessible. The fact that changing the active flag on sda1 made Windows bootable confirms that sda1 is the “system volume”; it is the boot sector on that partition which is being called by the Windows MBR boot code you reinstalled with fixmbr, and that boot sector is in turn calling ntldr (the XP loader).

The reason the grub installation failed is the same reason you got the sfdisk warning; also note that grub was installed using the --force-lba option. So, what did you use to create the extended primary? And, please go into the bios and look for a disk drive setting with choices like “auto, large, lba” - and set it to “lba” if it is not. I need to know these answers before replying further re grub re-installation.

I didn’t answer a question in your first post re the Ubuntu kernel boot arguments affecting (or not) the partitioning or grub installation - the answer is no, that would not be a factor.

Well, I think primarly I set all those partitions with WinXP installer (when I installed the 20 GB one).

PS I changed “Disc Access Method” or something like that in BIOS from Auto to LBA, and just after restarting the PC BIOS returned an error message:


A disc read error occured
Press Ctrl+Alt+Del to restart

Changing it back to Auto fixed it. Any more ideas?

Well, I think primarly I set all those partitions with WinXP installer (when I installed the 20 GB one).

From this, plus what happened when you changed the bios setting to LBA, plus the sfdisk error message, plus the grub error message . . . all this suggests there is a geometry translation problem in the values in the partition table and/or a bios-induced geometry translation problem with the OS.

This is a large and complicated subject. To try to keep it simple, disk geometry translation was introduced so that larger capacities could be used. As drives got larger, different methods were used; but with each method, a change was required in the disk controller on the mobo, in the bios, in the disk drive firmware, and in the OS - all four have to support a particular method for it to work. Your bios has a translation setting (the “disk access method”) of “Auto”, which means that it can use either the old “CHS” method (no translation), or “Large” in which the physical geometry is translated into a logical geometry map, or “LBA” which translates geometries into a linear sector address. The LBA method was enhanced (now called 48bit-LBA) in 2002 in order to support drives >137GB, and it is now the industry standard.

But that was not so when XP was released. XP supported drives >137GB only with Service Pack 1, so the original XP install CD does not have this support. As a result, and depending on the bios, partitioning a 320GB drive with XP’s installer can result in incorrect geometries or the use of “Large” rather than LBA; Large and LBA and not compatible with one another. When you swtiched “Auto” to “LBA” that resulted in the partition table not being readable, which indicates that LBA was not used when the table was built. Whether due to partitioning with pre-SP1 XP or some other cause, LBA was not used in the table. This is further indicated by the grub parameter “–force-lba” when trying to install grub’s stage1 to the sda2 (hd0,1) boot sector; embedded in the stage1 is a pointer to the location of the grub stage2 loader program - this parameter forced grub to use LBA translation for the location address rather than what the bios was providing (which is “Large”). This can be necessary for grub because at boot, no OS is running and so grub must rely on the bios and/or must make its own disk location calculations. When the OS is running (either Windows or Linux), this is not an issue as the OS will simply use LBA regardless of the bios setting. The whole problem was complicated by your creating sda2 as an extended primary taking all the disk space beyond sda1.

Your first option is to re-partition the disk correctly using LBA, reinstall everything, and restore from backup. As it is, you already have had problems between the Windows system volume and boot volume. The current partition table and disk layout may not be reliable. I include this option only because it is the cleanest and safest in the long-term - but of course, you probably do not want to do this.

A second option is to try to install grub to the MBR. When you installed openSUSE, it wanted to put grub in the sda2 boot sector pointing to sda8 and either leave the Windows boot code in the MBR or, if that wasn’t already there, install DOS boot code to the MBR. Installing grub to sda2 is what failed, because of the Large/LBA issue. But Ubuntu will not install grub this way; it would have tried to use the MBR. So, you can try to install grub as Ubuntu probably did: Boot the LiveCD, open a terminal, switch to root, and do:

grub
root (hd0,7)
setup (hd0) (hd0,7)
quit

If the install fails as it did before, try changing the setup line to:


setup --force-lba (hd0) (hd0,7)

If grub installs but at reboot grub does not work properly, then reboot into the LiveCD, and in a terminal as root try:

grub
root (hd0,7)
setup (hd0,1) (hd0,7)
quit

sfdisk -A2 /dev/sda

After doing this, you may need to use your XP CD with /fixmbr to get the system bootable; the attempt above to install grub to the MBR, while failing, may have put bits in the MBR anyway which would need to be replaced by working code. So keep the XP install CD nearby. Note that if you do need to use /fixmbr and the system does not boot, it will because the active flag needs to be switched back to sda1. To fix that, do as you did before with the LiveCD:

sfdisk -A1 /dev/sda

Good luck.

Ok, thanks for your help.

Installing GRUB to MBR did the trick. Everything working like a charm now.

I know now that it was thoughtless of me to make such a partition layout. I wanted to change it when I’ll be upgrading from WinXP to Windows 7.

Once again, thanks for all your help! I appreciate that :wink:

Glad it all worked out. :slight_smile:

Just as an aside re planning ahead for your W7 upgrade: W7 will not permit an “in-place” upgrade of XP. W7 will need to be a clean install with your XP data and programs migrated post-install. It may be that W7 will be able to do this on the same partition (that is, by creating a new directory structure alongside the old one; this method has been used in the past), but I can’t say for sure yet.


Glad it all worked out.

Just as an aside re planning ahead for your W7 upgrade: W7 will not permit an "in-place" upgrade of XP. W7 will need to be a clean install with your XP data and programs migrated post-install.

Yep, I already know that :wink: