Messed up partition table and Windows' partition boot sector
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Messed up partition table and Windows' partition boot sector
I'll start my post with where I'm stuck. When I do fdisk -l /dev/hda I get this:
Code:
Disk /dev/hda: 122.9 GB, 122942324736 bytes
255 heads, 63 sectors/track, 14946 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2550 20482843+ c W95 FAT32 (LBA)
/dev/hda2 2551 5099 20474842+ f W95 Ext'd (LBA)
/dev/hda3 5100 14946 79096027+ 7 HPFS/NTFS
/dev/hda5 2551 5099 20474811 b W95 FAT32
As you can see, it's messed up, and I want to fix it.
To be clear, on hda I have 2 20GB FAT32 partitions and then an 80GB NTFS partition. Both of the FAT32 partitions are windows installs (hda2, above as hda5 also, is a pretty clean, relatively new install, while hda1 is an old one with some problems and lots of stuff on it). My linux (kubuntu) install is on hdb.
I discovered this problem when I was trying to look at my hda2 windows install, and there was nothing at my mount point. It's listed in my /etc/fstab (partially pasted below) and I expected it to be mounted.
When I manually tried to mount it with mount -t vfat /dev/hda2 windows2, it returned
mount: /dev/hda2: can't read superblock
I searched around for a bit and found some advice to fsck it. So I ran fsck /dev/hda2 and got
fsck 1.38 (30-Jun-2005)
dosfsck 2.11, 12 Mar 2005, FAT32, LFN
Seek to 20966237696:Invalid argument
When I googled "Seek to" "Invalid argument" (omitting the number from the search) I found one hit that placed the phrases in similar context. It was in German, here. This gave me the idea to run fdisk -l /dev/hda. I followed the German thread through to where the output from his fdisk -l was posted here and I can see that his hde has a similarly messed up partition table to my hda. My trail ends here, as my German isn't good enough to understand all of that and babelfish turns a bunch of it to gibberish.
A few more things of note:
1) If I mount -t vfat /dev/hda5 /mnt/windows2 I can see the data on my second windows partion- hda2, as I think of it, or hda5 as it now wants to be called.
2) When I tell grub to boot my hda2, it won't do it. I think it says it can't find the partition, or something to that extent, but I when I tell grub to boot to my windows install on hda1, it goes ahead and does it, but the install that actually boots is at hda2. When I fsck /dev/hda1 it runs fine except for this at the very beginning:
I don't know what that means, so I pick option 3, and it goes through the rest of the partition just fine.
3) Mounting /dev/hda1 tells me that the install there is still intact so I know I'm not just booting into hda1 when I tell grub to do that.
So, anyway, I want to get my partition table straightened out so that I can mount my second windows install by mounting hda2, make my partition table look like it should, and get that boot sector sorted out (and hopefully understand what it means).
Thanks in advance.
Last edited by pyromithrandir; 04-07-2006 at 12:08 AM.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
Quote:
Originally Posted by pyromithrandir
I'll start my post with where I'm stuck. When I do fdisk -l /dev/hda I get this:
Code:
Disk /dev/hda: 122.9 GB, 122942324736 bytes
255 heads, 63 sectors/track, 14946 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2550 20482843+ c W95 FAT32 (LBA)
/dev/hda2 2551 5099 20474842+ f W95 Ext'd (LBA)
/dev/hda3 5100 14946 79096027+ 7 HPFS/NTFS
/dev/hda5 2551 5099 20474811 b W95 FAT32
As you can see, it's messed up, and I want to fix it.
To be clear, on hda I have 2 20GB FAT32 partitions and then an 80GB NTFS partition. Both of the FAT32 partitions are windows installs (hda2, above as hda5 also, is a pretty clean, relatively new install, while hda1 is an old one with some problems and lots of stuff on it). My linux (kubuntu) install is on hdb.
I never saw an extended W95 partition, I though it was either W95, or extended.
What are you trying to do?
Quote:
Originally Posted by pyromithrandir
I discovered this problem when I was trying to look at my hda2 windows install, and there was nothing at my mount point. It's listed in my /etc/fstab (partially pasted below) and I expected it to be mounted.
When I manually tried to mount it with mount -t vfat /dev/hda2 windows2, it returned
mount: /dev/hda2: can't read superblock
# 1 The definition for /dev/hda3 looks wrong. I don't know what you are trying to do with that.
# 2 The fstab is built (or not) by scanning the HD and only linux essentials have to be there. This isn't used by Win or anything else. The superblock error at the mount makes sense because the partition is going to have an extra 63 sectors at the beginning (it's extended) and does not normally contain data. Normally, an extended partition contains an MBR (pointers to additional logical partitions.)
# 3 if you have a definition in fstab for /dev/hda2 for example, you don't need to specify anything for mounting except mount /dev/hda2. It will do what fstab has specified.
Ok now on to your problem:
Quote:
Originally Posted by pyromithrandir
I searched around for a bit and found some advice to fsck it. So I ran fsck /dev/hda2 and got
fsck 1.38 (30-Jun-2005)
dosfsck 2.11, 12 Mar 2005, FAT32, LFN
Seek to 20966237696:Invalid argument
Don't fsck on non linux filesystems. It's not designed to work with NTFS and I wouldn't use it on FATx. You might wind up toasting your filesystem.
Quote:
Originally Posted by pyromithrandir
A few more things of note:
1) If I mount -t vfat /dev/hda5 /mnt/windows2 I can see the data on my second windows partion- hda2, as I think of it, or hda5 as it now wants to be called.
2) When I tell grub to boot my hda2, it won't do it. I think it says it can't find the partition, or something to that extent, but I when I tell grub to boot to my windows install on hda1, it goes ahead and does it, but the install that actually boots is at hda2. When I fsck /dev/hda1 it runs fine except for this at the very beginning:
So, anyway, I want to get my partition table straightened out so that I can mount my second windows install by mounting hda2, make my partition table look like it should, and get that boot sector sorted out (and hopefully understand what it means).
Thanks in advance.
Maybe you should get a second opinion, but I think hda2 has to be set to normal Win95 FAT32 (type "b"). That will eliminate the ghost on hda5. There doesn't seem like much risk because the cylinder boundaries line up properly. Then your partition table will be normal 1-3 all physical partitions.
If you want to add something after that, create p4 as extended, and then add logical partitions after it.
I never saw an extended W95 partition, I though it was either W95, or extended.
What are you trying to do?
Well, that's part of what threw me off about my partition table. When I formatted it I told it to be FAT32 (this was with the partition manager on the Windows install disc). I don't know why it did what it did, but if you look at hda5, the cylinders shows that it is hda2 all over again, but that it is formatted to FAT32, like I wanted it.
Quote:
# 1 The definition for /dev/hda3 looks wrong. I don't know what you are trying to do with that.
I'm mounting my 80GB NTFS partition to /mnt/NTFS Storage. If it's the "\040" you don't understand, that just makes it a space. There aren't any problems with it, it mounts fine and reads fine.
Quote:
# 2 The fstab is built (or not) by scanning the HD and only linux essentials have to be there. This isn't used by Win or anything else. The superblock error at the mount makes sense because the partition is going to have an extra 63 sectors at the beginning (it's extended) and does not normally contain data. Normally, an extended partition contains an MBR (pointers to additional logical partitions.)
# 3 if you have a definition in fstab for /dev/hda2 for example, you don't need to specify anything for mounting except mount /dev/hda2. It will do what fstab has specified.
I know about fstab. I have the the Windows stuff in there so that they automount and I can get at the files on them when I'm on linux. When I got the superblock error I was still working toward diagnosing the problem and was under the impression that hda2 wasn't extended but just a plain old FAT32 partition. Infact, I tried just using mount /dev/hda2 first. When it gave me an error I figured I'd better just make sure that it was trying to mount the partition right (I thought maybe the error was that it was getting the mount information wrong, perhaps trying to mount it as the wrong type of filesystem. I was still troubleshooting at this point). I figured I'd include what I did to find my problem in case anyone else gets it and searches some of the errors I came up with.
Quote:
Don't fsck on non linux filesystems. It's not designed to work with NTFS and I wouldn't use it on FATx. You might wind up toasting your filesystem.
Well, when I run fsck on a FAT32 partition, it really runs dosfsck, which is designed for that.
Quote:
Maybe you should get a second opinion, but I think hda2 has to be set to normal Win95 FAT32 (type "b"). That will eliminate the ghost on hda5. There doesn't seem like much risk because the cylinder boundaries line up properly. Then your partition table will be normal 1-3 all physical partitions.
If you want to add something after that, create p4 as extended, and then add logical partitions after it.
That's how I see it, too, but I don't know how to go about that. If I use fdisk to change hda2 from type f to type b, would it force me to format hda2 and loose my data on it? Or would I be able to just tell the partition table that that hda2 really is type b? And if I were to use fdisk to delete hda5, would it remove all the data there, or would it just get rid of the entry that I don't know why is there in the first place?
Probably isn't a good idea to go deleting partitions if you don't understand what you are doing.
hda2 is an extended partition - it is a container for logical partitions. Logical partitions are where you data is addressable, not the extended. From your perspective as a user, your data is in hda5, not hda2 - get used to it.
Update your fstab to accomodate.
The reason you get your second (Windows) install launched when you attempt to boot the first is because M$oft don't allow multiple installs. ntldr is updated to treat your hda5 install as the boot partition.
I strongly suspect there is no problem with your setup, just misunderstanding.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
Quote:
Originally Posted by pyromithrandir
That's how I see it, too, but I don't know how to go about that. If I use fdisk to change hda2 from type f to type b, would it force me to format hda2 and loose my data on it? Or would I be able to just tell the partition table that that hda2 really is type b? And if I were to use fdisk to delete hda5, would it remove all the data there, or would it just get rid of the entry that I don't know why is there in the first place?
Yes, I'm suggesting that you change the type of hda2 to b. It won't cause you to reformat anything. The partition table is just pointers to data, it doesn't affect the data it points to. I think hda5 will disappear by itself when you change the type on hda2.
It's not a problem to reconstruct the partition table if I am wrong. But, don't try to change any data until you have it working.
I see nothing wrong with the partition table either. Like syg00 posted hda2 is an extended partition. You can not mount an extended partition. Your data is on hda5.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
If partition hda2 was extended, it should just be type 5, EXT. Then the extended partition hda5 would be type Win95 FAT. I think he made a mistake and caused an incorrect type to be assigned. What is "Win95 FAT extended" supposed to mean? That doesn't make any sense.
I have to strongly agree w/ michaelk & syg00. Everything is fine, don't change it. As syg00 said: "... there is no problem with your setup, just misunderstanding."
1st, & easiest, "W95 Ext'd (LBA)" is simply the way fdisk labels partitions of type "f". If that's what type it is, what the fdisk that made it labelled it, don't mess w/ it. If you change it to "b", you will be telling the OS that it is a non-LBA FAT 32 part. not the LBA extended part. that it really is.
2nd, it is a little known, or at least often overlooked fact, that the extended partition need not be the last partition; nether in the partition table, nor physically on the HD. We get used to hdx4 being the ext. part., but it isn't mandatory.
One of the things I think is causing confusion here is the fact that there is nothing in hda2 except hda5. That is fine, it lets "Winders" see the 2 FAT32's at the same time.
Again, everything fine, perhaps unusual, but fine. All you need to do is mount hda5, your data; not hda2, the ext. part.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
> 2) When I tell grub to boot my hda2, it won't do it. I think it says it can't find the
> partition, or something to that extent, but I when I tell grub to boot to my windows install
> on hda1, it goes ahead and does it, but the install that actually boots is at hda2.
It's more than his imagination; according to what he wrote, he has a problem; he can't boot his systems properly. And there isn't any reasonable explanation (except error made by the OP) why two equivalently-sized Win 95 partitions have different partition types.
I said before that he should change hda2 to type b but looking over this again, he should probably change it to c, to be like hda1, the first Win install. There isn't any risk in changing the type. If my guess is wrong, he can just change it back. The important thing is not to write on the filesystem until everything is verified. And he should probably use linux cfdisk to straighten this mess out.
I looked at your links and the information shown is that type f partitions are known to cause problems. And now they have
If the OP simply reported that everything was working, but that when he tried to look at his filesystem that he thought was on hda2 from linux, and he couldn't see it, then I would agree with most of what the other guys have said. Since he is reporting booting problems, it seems like if nobody agrees with my analysis then you should help him boot his systems
Okay, I understand now what my partition table says, thanks to your posts here, everybody. I still don't know why hda2 is an extended partition and my windows install is on hda5... I told the windows install disc to format hda2 and put windows on that. That's really where my problem started- I told the partition manager to make a FAT32 partition out of the empty space that would be hda2, and assumed it would, of course, make an ordinary FAT32 partition out of it. Not once did it mention it was going to be extended. Oh well, it's not important, and I won't be using that partition manager ever again.
I suppose now that if I were to change my /boot/grub/menu.lst to look for my second windows install on hda5 instead of hda2 it will boot it up fine, right?
Quote:
Ok, the OP really never posted what the boot sector problems nor post any errors.
Well, there aren't any errors to post regarding the boot sector, except what I posted from fdisk telling me that the original boot sector didn't match the backup. When I try to boot to hda1, I don't get any errors, and it just boots the windows install on hda5.
I'm thinking now that I were to tell fdisk, when I run it on hda1 and it tells me about my boot sector, to copy the backup boot sector into the original, then telling grub to boot to hda1 will probably go back to booting to hda1 correctly. I didn't do that before because it was the only way I could get to the second windows install, which was the one I was interested in using anyway.
Typically, when windows creates additional drives it will automatically create an extended partition with logical partitions. Without knowing more details I would say your correct that if you change menu.lst to hda5 it will boot up fine. No need to mess with fdisk anymore. Any changes to booting windows or linux are accomplished via menu.lst unless you mess up the Master Boot Record (MBR).
# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.
## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
default saved
## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 15
## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu
# Pretty colours
#color cyan/blue white/blue
## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret
#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#
#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below
## DO NOT UNCOMMENT THEM, Just edit them to your needs
## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=/dev/hdb3 ro
## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd1,2)
## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true
## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false
## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash
## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery mode) single
# altoptions=(recovery mode) single
## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all
## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true
## ## End Default Options ##
title Ubuntu, kernel 2.6.15-19-386
root (hd1,2)
kernel /boot/vmlinuz-2.6.15-19-386 root=/dev/hdb3 ro quiet
initrd /boot/initrd.img-2.6.15-19-386
savedefault
boot
title Ubuntu, kernel 2.6.15-19-386 (recovery mode)
root (hd1,2)
kernel /boot/vmlinuz-2.6.15-19-386 root=/dev/hdb3 ro single
initrd /boot/initrd.img-2.6.15-19-386
boot
title Ubuntu, kernel 2.6.12-10-386
root (hd1,2)
kernel /boot/vmlinuz-2.6.12-10-386 root=/dev/hdb3 ro quiet splash
initrd /boot/initrd.img-2.6.12-10-386
savedefault
boot
title Ubuntu, kernel 2.6.12-10-386 (recovery mode)
root (hd1,2)
kernel /boot/vmlinuz-2.6.12-10-386 root=/dev/hdb3 ro single
initrd /boot/initrd.img-2.6.12-10-386
boot
title Ubuntu, kernel 2.6.12-9-386
root (hd1,2)
kernel /boot/vmlinuz-2.6.12-9-386 root=/dev/hdb3 ro quiet splash
initrd /boot/initrd.img-2.6.12-9-386
savedefault
boot
title Ubuntu, kernel 2.6.12-9-386 (recovery mode)
root (hd1,2)
kernel /boot/vmlinuz-2.6.12-9-386 root=/dev/hdb3 ro single
initrd /boot/initrd.img-2.6.12-9-386
boot
title Ubuntu, memtest86+
root (hd1,2)
kernel /boot/memtest86+.bin
boot
### 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/hda1
title Microsoft Windows XP Professional
root (hd0,0)
savedefault
makeactive
chainloader +1
title Windows2
root (hd0,1)
savedefault
makeactive
chainloader +1
This is my menu.lst in its entirety. I'm going to change the root section in the last option from "(hd0,1)" to "(hd0,4)". Other than that, you can see the option titled "Microsoft Windows XP Professional" is supposed to boot hda1. But, as I said before, that's the option that currently allows me to get to my second windows install (hda5). (Which I think is weird)
From what you posted using (hd0,1) boots your second windows install successfully so I see no reason to change it. An extended partition does have a boot sector and windows might be using it.
Actually, as I said in my first post, "When I tell grub to boot my hda2, it won't do it." It's a bit confusing at first to understand what happens, so let me make it clear.
When I try to boot (hd0,0), the first install, grub doesn't give me any errors, and windows boots. The problem here is that the windows install that boots up isn't at (hd0,0). It doesn't boot hda1. What boots up when I tell grub to boot (hd0,0) is the second windows installation, which is on hda5.
When I try to boot (hd0,1), the second install, grub gives me an error that it can't find something there to boot. I'm going to change it from (hd0,1) to (hd0,4) because I think that if I tell it that that it will be able to boot the second windows install from an option that makes sense.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.