PDA

View Full Version : [SOLVED] Cannot find Ubuntu partition after installind Windows



jimmys_
February 14th, 2011, 10:58 PM
I used to have Windows 7 dual boot with Ubuntu 10.04 but I decided to replace 7 with XP. I installed XP over 7's partition. I try to boot from a Live CD to fix GRUB2 but I can't see my Ubuntu partition. Here are the results of boot info script in case it helps

Boot Info Script 0.55 dated February 15th, 2010

============================= Boot Info Summary: ==============================

=> Windows is installed in the MBR of /dev/sda

sda1: __________________________________________________ _______________________

File system: ntfs
Boot sector type: Windows XP
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows XP
Boot files/dirs: /boot.ini /ntldr /NTDETECT.COM

sda2: __________________________________________________ _______________________

File system: ntfs
Boot sector type: Windows Vista/7
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files/dirs:

sda3: __________________________________________________ _______________________

File system: Extended Partition
Boot sector type: -
Boot sector info:

sda5: __________________________________________________ _______________________

File system: ext4
Boot sector type: -
Boot sector info:
Operating System: Ubuntu 10.04.2 LTS
Boot files/dirs: /boot/grub/grub.cfg /etc/fstab /boot/grub/core.img

sda4: __________________________________________________ _______________________

File system: swap
Boot sector type: -
Boot sector info:

=========================== Drive/Partition Info: =============================

Drive: sda ___________________ __________________________________________________ ___

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Partition Boot Start End Size Id System

/dev/sda1 * 63 63,119,384 63,119,322 7 HPFS/NTFS
/dev/sda2 63,121,408 167,979,007 104,857,600 7 HPFS/NTFS
/dev/sda3 167,981,054 234,440,703 66,459,650 5 Extended
Extended partition linking to another extended partition
/dev/sda5 167,981,056 230,895,615 62,914,560 83 Linux
/dev/sda4 230,895,616 234,440,703 3,545,088 82 Linux swap / Solaris

/dev/sda3 overlaps with /dev/sda4

blkid -c /dev/null: __________________________________________________ __________

Device UUID TYPE LABEL

/dev/loop0 squashfs
/dev/sda1 B2F0CBCDF0CB964F ntfs
/dev/sda2 64BA809ABA8069FE ntfs Data
/dev/sda3: PTTYPE="dos"
/dev/sda4 7c6e7862-f656-43b6-96e8-de61b62662e1 swap
/dev/sda5 fa7a3cfe-3a13-4478-b98f-f51e31158b93 ext4
/dev/sda: PTTYPE="dos"

============================ "mount | grep ^/dev output: ===========================

Device Mount_Point Type Options

aufs / aufs (rw)
/dev/sr0 /cdrom iso9660 (ro,noatime)
/dev/loop0 /rofs squashfs (ro,noatime)
/dev/sda2 /media/Data fuseblk (rw,nosuid,nodev,allow_other,blksize=4096,default_ permissions)


================================ sda1/boot.ini: ================================

[boot loader]

timeout=30

default=multi(0)disk(0)rdisk(0)partition(1)\WINDOW S

[operating systems]

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect


=========================== sda5/boot/grub/grub.cfg: ===========================

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
set saved_entry=${prev_saved_entry}
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z ${boot_once} ]; then
saved_entry=${chosen}
save_env saved_entry
fi
}

function recordfail {
set recordfail=1
if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-28-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
linux /boot/vmlinuz-2.6.32-28-generic root=UUID=fa7a3cfe-3a13-4478-b98f-f51e31158b93 ro quiet splash
initrd /boot/initrd.img-2.6.32-28-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-28-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
echo 'Loading Linux 2.6.32-28-generic ...'
linux /boot/vmlinuz-2.6.32-28-generic root=UUID=fa7a3cfe-3a13-4478-b98f-f51e31158b93 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-28-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-27-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
linux /boot/vmlinuz-2.6.32-27-generic root=UUID=fa7a3cfe-3a13-4478-b98f-f51e31158b93 ro quiet splash
initrd /boot/initrd.img-2.6.32-27-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-27-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
echo 'Loading Linux 2.6.32-27-generic ...'
linux /boot/vmlinuz-2.6.32-27-generic root=UUID=fa7a3cfe-3a13-4478-b98f-f51e31158b93 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-27-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
linux /boot/vmlinuz-2.6.32-21-generic root=UUID=fa7a3cfe-3a13-4478-b98f-f51e31158b93 ro quiet splash
initrd /boot/initrd.img-2.6.32-21-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
echo 'Loading Linux 2.6.32-21-generic ...'
linux /boot/vmlinuz-2.6.32-21-generic root=UUID=fa7a3cfe-3a13-4478-b98f-f51e31158b93 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-21-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set fa7a3cfe-3a13-4478-b98f-f51e31158b93
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod ntfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set de34b0bb34b097cb
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ### 7.
8.
partitioning - Ubuntu cannot see portable hdd with 2 partitions ...
I don't know why but ubuntu 9.10 is not showing up one of the partitions in my portable hdd. Only the 2nd partition is shown. And I can't find the 1st one. ...
superuser.com/.../ubuntu-cannot-see-portable-hdd-with-2-partitions - Cached
9.
Bug #524104 in ubiquity (Ubuntu): “Can't see partitions during ...
18 Feb 2010 ... + Can't see partition during kubuntu 10.04 amd64 installation ... This is what I did to make it work. put the ubuntu live cd 10.04 open the ...
https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/524104 - Cached
10.
Ubuntu partition
2 posts - 1 author - Last post: 1 Jun 2009
Hello, If i put partition on ubuntu 8.10 where can i find that ... Uninstall ubuntu reinstall windows can't find partition > Forum ...
en.kioskea.net/forum/affich-101960-ubuntu-partition - Cached - Similar
Get more discussion results

Preview image

* Everything
* Images
* Videos
* News
* Shopping
* Discussions

* Books
* Places
* Blogs
* Realtime

MoreFewer
Search Options

*
*

Hide search toolsShow search tools
1 2 3 4 5 6 7 8 9 10 Next

Search Help Give us feedback
Google HomeAdvertising ProgramsBusiness SolutionsPrivacyAbout Google

=============================== sda5/etc/fstab: ===============================

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
/dev/sda6 / ext4 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0

=================== sda5: Location of files loaded by Grub: ===================


97.0GB: boot/grub/core.img
110.0GB: boot/grub/grub.cfg
96.9GB: boot/initrd.img-2.6.32-21-generic
97.2GB: boot/initrd.img-2.6.32-27-generic
97.3GB: boot/initrd.img-2.6.32-28-generic
96.8GB: boot/vmlinuz-2.6.32-21-generic
97.0GB: boot/vmlinuz-2.6.32-27-generic
97.2GB: boot/vmlinuz-2.6.32-28-generic
97.3GB: initrd.img
97.2GB: initrd.img.old
97.2GB: vmlinuz
97.0GB: vmlinuz.old

Quackers
February 14th, 2011, 11:10 PM
The problem is this line
"/dev/sda3 overlaps with /dev/sda4"
You appear to have a primary partition (sda4) within an extended partition (sda3)
This is illegal. I'm not sure how that has happened.
Can you see any output in gparted when run from the live cd desktop?

coffeecat
February 14th, 2011, 11:55 PM
@Quackers, I've noticed a subsidiary problem. The one you've pointed out - the "primary within an extended" issue - clearly takes priority, but this one might become a gotcha when and if the partition table is rectified. In /etc/fstab, what was sda5 - swap - is now sda4, and what was sda6 - root partition - is now sda5. Unfortunately, the OP has '/dev/sdaX' device descriptors instead of UUIDs in fstab.

I thought I'd point this out now because I'm going to log off soon.


I'm not sure how that has happened.

I have a feeling in my bones it was the XP installation disc. It's becoming all too familiar, isn't it? Windows install discs trying to convert Linux logical partitions into primary ones, although why should it nobble the swap partition on this occasion? :?

Quackers
February 15th, 2011, 12:02 AM
I don't know why it should pick on just the swap partition either. Odd. Maybe jimmys_ could tell us the original layout - before installing XP.

jimmys_
February 15th, 2011, 12:04 AM
@Quackers, Can this be fixed? I'll run gparted tomorrow and post the results.

@coffeecat, Will this cause a problem? Actually, Windows 7 was occupying 2 partitions on my disk because 7 creates a 100mb reserved partition. When I installed XP I merged those partitions into one. Maybe that's why there was a shift.

coffeecat
February 15th, 2011, 12:17 AM
@Quackers, Can this be fixed? I'll run gparted tomorrow and post the results.

@coffeecat, Will this cause a problem? Actually, Windows 7 was occupying 2 partitions on my disk because 7 creates a 100mb reserved partition. When I installed XP I merged those partitions into one. Maybe that's why there was a shift.

The problem I identified in /etc/fstab will only be a problem if the original sda5 and sda6 numbers are not correctly reallocated to their proper partitions when the partition table is edited. It's something to look out for. Looking at your fdisk output in the bootscript output it's evident that originally sda6 came before sda5 - odd, but not illegal. Whatever, you will probably have to edit the partition table to fix the main problem.

The reason that I pointed the finger of blame at the Windows XP disc is that both Quackers and I have been involved in threads where it seems that the Windows disc has done what has happened here - a logical partition redesignated as a primary partition but still within the extended partition boundaries: an impossible situation.

Quackers
February 15th, 2011, 12:19 AM
If you are not doing anything until tomorrow, I would leave the thread overnight and see if further suggestions are made. There are one or two users here who could make suggestions overnight.

jimmys_
February 15th, 2011, 09:56 AM
Thanks everyone for your feedback.

@Quackers, I just run gparted. It doesn't show any partitions at all. It just shows the entire disk. When I run it, it said "Can't have overlapping partitions". I don't know if that means anything.
As for my configuration: My disk is ~112GB. I first installed Windows 7 making a 30GB partition plus the extra partition of 100MB Windows 7 automatically reserves. I also created a 50GB NTFS partition for my data. Then I installed Ubuntu 10.04 on a 30GB ext4 partition and created a ~1.7GB(I think) partition for swap area. So, I was using GRUB2 as a boot loader. Then I just booted Windows XP, deleted the two Windows 7 partitions (30GB + 100MB reserved) and installed XP on the unallocated space.

@coffecat, Can it be that the problem occured because I merged the two Windows 7 partitions into one? So, is this something that can be fixed easily or do I have to reinstall Ubuntu? How exactly do I modify the partition table?

coffeecat
February 15th, 2011, 10:12 AM
@coffecat, Can it be that the problem occured because I merged the two Windows 7 partitions into one? So, is this something that can be fixed or do I have to reinstall Ubuntu?

Have a look at this link. The author is forum member srs5694.

http://www.rodsbooks.com/missing-parts/index.html

The issue it describes - an extended partition extending beyond the disc boundary - is different from yours, but it shows how Gparted will show nothing if there is an impossibility in the partition table. Which is what you have. It also shows you how to edit the partition table to put things to rights. Hopefully, you will be able to use sfdisk to mend your partition table and get Ubuntu booting again.

Boot up a live CD, open a terminal and run:


sudo sfdisk -d /dev/sda > Desktop/parts.txt... to get the current layout of the partition table to a text file on the live desktop. Copy that to a USB drive as a permanent backup and post it here and, hopefully, Quackers or I will be able to tell you how to edit it. Please post the parts.txt within
and tags for legibility.

If you use a live USB rather than a live CD, check what your internal HD is designated. Sometimes sda becomes sdb when you run a live USB.

The problem may be related to merging the two partitions but, if so, the Windows disc should have done that without turning your swap partition into a pseudo-primary one. There is definitely something weird going on with Windows and Linux logical partitions. Quackers discovered that Windows 7 Disk Management sees Linux logical partitions as primary partitions (Windows 7 tells me that I have 10 primary partitions on one HD :-s) and that could be related. I'd like to investigate this a bit more, but perhaps after you've mended your partition table.

EDIT: @jimmys_, here is Quackers' thread on the Windows 7 Disk management nonsense. It makes interesting reading:

http://ubuntuforums.org/showthread.php?t=1675458

jimmys_
February 15th, 2011, 10:29 AM
@coffeecat, I run the command and it returned the following warning in terminal:

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


The parts.txt file's contents are:

# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 63, size= 63119322, Id= 7, bootable
/dev/sda2 : start= 63121408, size=104857600, Id= 7
/dev/sda3 : start=167981054, size= 66459650, Id= 5
/dev/sda4 : start=230895616, size= 3545088, Id=82
/dev/sda5 : start=167981056, size= 62914560, Id=83

coffeecat
February 15th, 2011, 12:04 PM
As far as I can see the easiest way would be to convert sda5 back to sda6 and sda4 to sda5. That will result in your two logical partitions not being in numerical order (which doesn't really matter much) but takes into account what you have in your /etc/fstab. We could make your partition table tidier with the logical partitions in numerical order, but that would mean you would have to edit /etc/fstab from the live session as well to make Ubuntu bootable. Nor particularly difficult, but let's go for the straightforward option.

Before you follow the next bit may I suggest you wait to see if Quackers agrees with my logic? I may have missed something.

Here is my suggestion for your edited partitions layout:


/dev/sda1 : start= 63, size= 63119322, Id= 7, bootable
/dev/sda2 : start= 63121408, size=104857600, Id= 7
/dev/sda3 : start=167981054, size= 66459650, Id= 5
/dev/sda5 : start=230895616, size= 3545088, Id=82
/dev/sda6 : start=167981056, size= 62914560, Id=83
I suggest you edit your original parts.txt because I think there is a header missing from your posted output, but I'm going from memory here. As you can see, the edit merely involves changing sda4 > sda5 and sda5 > sda6. Save the edited file as parts_edited.txt and make sure you keep a copy of the unedited parts.txt. You may need it to restore the situation to where you are at the moment if things go pear-shaped.

From the live CD session, place the parts_edited.txt on the desktop and from a terminal:


sudo sfdisk /dev/sda < Desktop/parts_edited.txtYou may have to run:


sudo sfdisk --force /dev/sda < Desktop/parts_edited.txtHopefully, that will enable you to boot into Ubuntu and will enable Gparted to see the partitions.

This is most interesting:




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


In my experiments I hadn't been able to get the Windows XP installer to "convert" a logical partition to a primary one. I was trying to reproduce what had been reported on other threads. But the cylinder boundary issue might be the clue. Thanks for that; none of the OPs of the earlier threads had been clear about what they had done. I don't think the cylinder boundary issue will prevent you from running Ubuntu or Windows, but something worth bearing in mind if you use a Windows installer again. It might be the combination of a Linux formatted logical partition and an extended partition not on a cylinder boundary that's causing the Windows installer to do silly things. I shall investigate.

coffeecat
February 15th, 2011, 12:24 PM
@jimmys_, don't do anything just yet. There's something not right about your parts.txt. I'm doing some investigating and will post back soon.

Quackers
February 15th, 2011, 12:26 PM
That certainly looks like it's worth trying. If it doesn't go according to plan, it should be recoverable to its present state.
The cylinder boundary thing isn't usually a problem, but it may be to a mixture of installer programs, as the ends of the partitions could be read differently.
Professor coffeecat is trying to replicate these circumstances as we speak, I suspect :-)

Edit oops, see above post!

coffeecat
February 15th, 2011, 12:40 PM
Sorry about that. I was checking my own partition table, forgot the -d option and got a completely different layout, which was worrying. Silly mistake. :oops:

However, there is one thing that may be necessary. The partition table normally has a null entry for any unused primary partition. If you edit sda4 to become sda5, there will be an unallocated primary partition slot which needs a null entry. sfdisk may sort that out for you, but if you get an error, you need to include a line like this:


/dev/sda4 : start= 0, size= 0, Id= 0See my complete partition table for comparison. Apart from the larger number of logical partitions, it is similar: sda1 and sda2 are primaries and sda3 an extended with a zero line for sda4.


# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 2048, size=209715200, Id= 7, bootable
/dev/sda2 : start=209717248, size=377487360, Id= 7
/dev/sda3 : start=587206654, size=389566466, Id= 5
/dev/sda4 : start= 0, size= 0, Id= 0
/dev/sda5 : start=587206656, size= 8388608, Id=82
/dev/sda6 : start=595597312, size= 83886080, Id=83
/dev/sda7 : start=679485440, size= 83886080, Id=83
/dev/sda8 : start=763373568, size= 41943040, Id=83
/dev/sda9 : start=805318656, size= 41943040, Id=83
/dev/sda10: start=847263744, size= 41943040, Id=83
/dev/sda11: start=889208832, size= 41943040, Id=83
/dev/sda12: start=931153920, size= 41943040, Id=83

jimmys_
February 15th, 2011, 01:01 PM
@coffecat, Should I try it now and if I get an error include the line for sda4?

coffeecat
February 15th, 2011, 01:07 PM
@coffecat, Should I try it now and if I get an error include the line for sda4?

I think so. If the worst comes to the worst you can always restore the partition table to the way it is now with your saved original parts.txt file.

Actually, I don't think it would hurt to edit in the sda4 line anyway. Just make sure you get it in the right place (after sda3) and make sure the formatting is correct. If you copy and paste my sda4 line, that *should* ensure the formatting is OK.

EDIT: Before you run the sfdisk command in the live session, run this:


sudo swapoff -a

That's probably unnecessary because the live session probably can't see your swap partition to mount it anyway, but in case it has, the swap needs turning off.

jimmys_
February 15th, 2011, 01:24 PM
What's the worst thing that can happen? Is it possible to damage my hardware? If not, although I have important things on my disk, I will try editing the partition table and if it doesn't work I'll just reinstall everything.

Quackers
February 15th, 2011, 01:28 PM
You can't physically damage the hardware. You can lose data, although if you have the backed up partition table, that shouldn't happen.

coffeecat
February 15th, 2011, 01:33 PM
What's the worst thing that can happen? Is it possible to damage my hardware? If not, although I have important things on my disk, I will try editing the partition table and if it doesn't work I'll just reinstall everything.

The worst? A completely corrupted partition table with two unbootable systems. But even if that happened the partitions and filesystems would still be there and you would be able to restore the partition table as it is now. That sfdisk command merely rewrites the partition table, which is only about 150 bytes at the end of the mbr, which is the first 512 bytes of the hard drive, so it should have no effect on any other part of the hard drive. And it certainly won't affect your hardware.

If you can backup any data from the live CD, it would be a good idea to do so, but I guess that might be in your currently inaccessible Ubuntu partition. I presume you are unable to mount the Ubuntu root partition from the live CD?

jimmys_
February 15th, 2011, 01:40 PM
No I cannot mount the Ubuntu partition from the Live CD. Anyway I'll proceed with the 'experiment' and I'll let you know about the results. Thanks again both coffeecat and Quackers.

coffeecat
February 15th, 2011, 01:52 PM
Anyway I'll proceed with the 'experiment' and I'll let you know about the results.

Good luck! By the way, this is no experiment. This is a tried and tested way of repairing a partition table. The tricky bit is getting the editing right. :|

The "experiment" is my so-far unsuccessful attempt to reproduce what the XP disc has done to you and to others but, fear not, I shall persevere. :)

jimmys_
February 15th, 2011, 02:03 PM
:) Sorry for that. I meant it more like an operation or a task that will take place..

Quackers
February 15th, 2011, 02:06 PM
Lol, I'm sure the professor isn't offended :-) (He's still listening to his music).

coffeecat
February 15th, 2011, 02:11 PM
(He's still listening to his music).

Could you repeat that? I didn't hear it. :p

jimmys_
February 15th, 2011, 02:15 PM
I know you said that I may need to use --force but here's what I get if I don't use it. Just fyi and in case it means something bad

ubuntu@ubuntu:~$ sudo sfdisk -d /dev/sda > Desktop/parts.txt
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
ubuntu@ubuntu:~$ sudo swapoff -a
ubuntu@ubuntu:~$ sudo sfdisk /dev/sda < Desktop/parts_edited.txt
Checking that no-one is using this disk right now ...
OK

Disk /dev/sda: 14593 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 3928 3929- 31559661 7 HPFS/NTFS
/dev/sda2 3929+ 10456- 6528- 52428800 7 HPFS/NTFS
/dev/sda3 10456+ 14593- 4137- 33229825 5 Extended
/dev/sda4 14372+ 14593- 221- 1772544 82 Linux swap / Solaris
/dev/sda5 10456+ 14372- 3917- 31457280 83 Linux
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sda1 * 63 63119384 63119322 7 HPFS/NTFS
/dev/sda2 63121408 167979007 104857600 7 HPFS/NTFS
/dev/sda3 167981054 234440703 66459650 5 Extended
/dev/sda4 230895616 234440703 3545088 82 Linux swap / Solaris
/dev/sda5 167981056 230895615 62914560 83 Linux
Warning: partition 2 does not start at a cylinder boundary

sfdisk: I don't like these partitions - nothing changed.
(If you really want this, use the --force option.)

coffeecat
February 15th, 2011, 02:20 PM
Device Boot Start End #sectors Id System
/dev/sda1 * 63 63119384 63119322 7 HPFS/NTFS
/dev/sda2 63121408 167979007 104857600 7 HPFS/NTFS
/dev/sda3 167981054 234440703 66459650 5 Extended
/dev/sda4 230895616 234440703 3545088 82 Linux swap / Solaris
/dev/sda5 167981056 230895615 62914560 83 Linux
Warning: partition 2 does not start at a cylinder boundary

sfdisk: I don't like these partitions - nothing changed.
(If you really want this, use the --force option.)


It look as though your parts_edited.txt is no different from your original parts.txt. Post both the parts.txt (again) and your parts_edited.txt so we can see what's what.

jimmys_
February 15th, 2011, 02:22 PM
I saw that too but I guess that's the old partition table not the new one. My parts_edited.txt is like it should be (with sda5, sda6).. Anyway I already used the --force option and it gave me a message that the table was successfully updated. I'm waiting to see the results now.

Quackers
February 15th, 2011, 02:25 PM
Did you "save" the file after editing?

coffeecat
February 15th, 2011, 02:26 PM
Strange that it should say 'new situation' and then list the old situation. Did you put a zero sda4 line in? If not, and this doesn't work, you will need to put a zero sda4 line in as I describe earlier.

If it doesn't work, post your parts_edited.txt file anyway. It's always useful to double-check things like this.

jimmys_
February 15th, 2011, 02:27 PM
Yes I did. I also saved them on my usb so here they are:


# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 63, size= 63119322, Id= 7, bootable
/dev/sda2 : start= 63121408, size=104857600, Id= 7
/dev/sda3 : start=167981054, size= 66459650, Id= 5
/dev/sda4 : start=230895616, size= 3545088, Id=82
/dev/sda5 : start=167981056, size= 62914560, Id=83




# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 63, size= 63119322, Id= 7, bootable
/dev/sda2 : start= 63121408, size=104857600, Id= 7
/dev/sda3 : start=167981054, size= 66459650, Id= 5
/dev/sda5 : start=230895616, size= 3545088, Id=82
/dev/sda6 : start=167981056, size= 62914560, Id=83

jimmys_
February 15th, 2011, 02:30 PM
Strange that it should say 'new situation' and then list the old situation. Did you put a zero sda4 line in? If not, and this doesn't work, you will need to put a zero sda4 line in as I describe earlier.

If it doesn't work, post your parts_edited.txt file anyway. It's always useful to double-check things like this.

No I didn't put a zero sda4 line. I thought I should try it without it and then put it. Should I put it?

coffeecat
February 15th, 2011, 02:33 PM
No I didn't put a zero sda4 line. I thought I should try it without it and then put it. Should I put it?

Yes. I think what might happen is that sfdisk parses the file as an error check, notices the missing sda4 and then renumbers your carefully renumbered lines back again. I think you need this:


# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 63, size= 63119322, Id= 7, bootable
/dev/sda2 : start= 63121408, size=104857600, Id= 7
/dev/sda3 : start=167981054, size= 66459650, Id= 5
/dev/sda4 : start= 0, size= 0, Id= 0
/dev/sda5 : start=230895616, size= 3545088, Id=82
/dev/sda6 : start=167981056, size= 62914560, Id=83

jimmys_
February 15th, 2011, 02:34 PM
I just rebooted from the Live CD and run gparted. It shoes the same thing as before. Under Places now I can see two 32GB partitions but they don't mount. Should I rewrite the parttion table with the sda4 line?

jimmys_
February 15th, 2011, 02:36 PM
Yes. I think what might happen is that sfdisk parses the file as an error check, notices the missing sda4 and then renumbers your carefully renumbered lines back again. I think you need this:


# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 63, size= 63119322, Id= 7, bootable
/dev/sda2 : start= 63121408, size=104857600, Id= 7
/dev/sda3 : start=167981054, size= 66459650, Id= 5
/dev/sda4 : start= 0, size= 0, Id= 0
/dev/sda5 : start=230895616, size= 3545088, Id=82
/dev/sda6 : start=167981056, size= 62914560, Id=83

Yes you are right. I checked my partition table again and it hasn't changed. I'll try it now with the sda4 line.

coffeecat
February 15th, 2011, 02:37 PM
I just rebooted from the Live CD and run gparted. It shoes the same thing as before. Under Places now I can see two 32GB partitions but they don't mount. Should I rewrite the parttion table with the sda4 line?

Yes. I don't think sfdisk is happy with a missing sda4 line. See my previous post for what I believe parts-edited.txt should look like.

coffeecat
February 15th, 2011, 02:38 PM
We are posting simultaneously and talking across each other. :) I shall go and wash up my lunch things and return in a few minutes.

jimmys_
February 15th, 2011, 02:40 PM
Something weird is happening. It turns out that I CAN mount the two partitions and I can see my data. I haven't added the sda4 line and the partition table is the same as it was before doing anything. I'm still getting the same warnings though and gparted doesn't show the correct configuration. What should I do?

coffeecat
February 15th, 2011, 03:01 PM
Something weird is happening. It turns out that I CAN mount the two partitions and I can see my data. I haven't added the sda4 line and the partition table is the same as it was before doing anything. I'm still getting the same warnings though and gparted doesn't show the correct configuration. What should I do?

Even though you can mount your partitions, there is a serious illegality in your partition table that needs fixing, because it will cause problems sooner or later. It's the parted backend of Gparted that won't tolerate the bad partition table - hence the blank Gparted. But if you can mount the Ubuntu root partition, then clearly the kernel, udev and whatever else is involved can cope with the partition inconsistency for now. But I wouldn't rely on it.

If that was my system, I would backup any important data (just in case), then unmount any mounted partitions (don't forget to swapoff as well) and write the edited partition table with the zero sda4 line with sfdisk.

jimmys_
February 15th, 2011, 03:23 PM
I updated the partition table correctly and everything seems okay now. GParted shows the disk the way it should be and I don't get any warnings/errors. Now I have to fix GRUB2.. I want to thank you one last time for your helpful guidance!

coffeecat
February 15th, 2011, 03:41 PM
That's good news. I'm pleased.

What was the problem with grub 2? Do you need any help?

Also - I'm curious. You replaced Windows 7 with XP. That's unusual. I can understand people "upgrading" Vista to XP, but not Windows 7. I have a grudging respect (whisper it softly!) for W7. What was the problem with W7?

Quackers
February 15th, 2011, 09:15 PM
Aha! Well done Professor CC :-)

coffeecat
February 17th, 2011, 11:41 PM
Because there have been several threads where the Windows XP installer seems to have corrupted the partition table by creating the illegal situation of a primary partition within an extended one, I have tried to reproduce this but without success - until now. But now I have been successful, although it's a strange sort of success when it involves corrupting a partition table, but there you go. I must thank the OP of this thread - jimmys_ - for providing the clue. It was the merging of the first two partitions into one that was important - see post #8

I adapted the OP's parts.txt to simulate what they probably had before their problem arose, with sda1 ~ 100MB and sda2 ~ 32GB. The OP has a 120GB disc, but I used a 250GB, simply leaving a large amount of unallocated space. This was my parts.txt:


# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 63, size= 204800, Id= 7, bootable
/dev/sda2 : start= 206848, size= 62914560, Id= 7
/dev/sda3 : start= 63121408, size=104857600, Id= 7
/dev/sda4 : start=167981054, size= 66459650, Id= 5
/dev/sda5 : start=230895616, size= 3545088, Id=82
/dev/sda6 : start=167981056, size= 62914560, Id=83Which I wrote to sda with:


sudo sfdisk --force /dev/sda < parts.txtI then created appropriate filesystems in each partition with mkfs and fdisk now showed me:


ubuntu@ubuntu:~$ sudo fdisk -lu

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008614f

Device Boot Start End Blocks Id System
/dev/sda1 * 63 204862 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 206848 63121407 31457280 7 HPFS/NTFS
/dev/sda3 63121408 167979007 52428800 7 HPFS/NTFS
/dev/sda4 167981054 234440703 33229825 5 Extended
/dev/sda5 230895616 234440703 1772544 82 Linux swap / Solaris
/dev/sda6 167981056 230895615 31457280 83 Linux

Partition table entries are not in disk orderNot in disk order - true. I copied the OP's layout with sda6 coming before sda5, but whether that was responsible for what the XP installer did, I don't know.

I did take a Gparted screenshot but the PNG file got corrupted on the USB pendrive. :roll: Believe me - it showed a nice, tidy partition layout.

Then I booted into the Windows XP installer, used that to delete the first two NTFS partitions and to create a NTFS partition in that space for installing to. The installation proceeded without incident and I was able to boot into a workable XP desktop. Rebooting into the Ubuntu live CD gave me the Gparted window as in the attached thumbnail. And fdisk as here:


ubuntu@ubuntu:~$ sudo fdisk -lu
omitting empty partition (5)

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008614f

Device Boot Start End Blocks Id System
/dev/sda1 * 63 63110879 31555408+ 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 63121408 167979007 52428800 7 HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sda3 167981054 234440703 33229825 5 Extended
Partition 3 does not end on cylinder boundary.
/dev/sda4 230895616 234440703 1772544 82 Linux swap / Solaris
Partition 4 does not end on cylinder boundary.
/dev/sda5 167981056 230895615 31457280 83 Linux
ubuntu@ubuntu:~$ Yup - we have a so-called primary partition sitting inside an extended partition. Another victim of the windows installer! A successful experiment - a theory proven - and I shall celebrate. :)

EDIT: added XP Disk Management screenshot. It's making a creditable attempt at making sense of an impossible situation by showing the swap partition twice, as both a primary and logical partition. Interesting.

Quackers
February 18th, 2011, 12:09 PM
That's a lot of work you've been up to!
The installer seems to just re-number the partitions when one is deleted. This is fine, so long as it doesn't forget which is primary and which is logical. Very poor housekeeping by MS.
Many thanks coffeecat :-)

coffeecat
February 18th, 2011, 12:54 PM
The installer seems to just re-number the partitions when one is deleted. This is fine, so long as it doesn't forget which is primary and which is logical. Very poor housekeeping by MS.

Agreed. It seems that the installer notices that one of the primary slots is now not used and simply grabs the first logical partition it can find.

Whatever, you wouldn't have thought it could get worse, would you? But you haven't reckoned with Vista. Take a deep breath before you read on. This is not a pretty sight - not for the faint-hearted.

I redid the partition table exactly as in my previous post. The parts.txt and first fdisk output were exactly the same. I managed to get a Gparted screenshot this time before Windows had had its wicked way - it's the first thumbnail. I then installed Vista from the Home Premium DVD doing exactly what I did with XP: deleting sda1 and sda2 with the Windows installer and creating a NTFS partition in the resultant unallocated space to which I installed Windows.

Vista boots up fine and the Disk Management screenshot is the second thumbnail, giving a hint of the horrors to come. Booting up the Ubuntu live CD again gives me fdisk output of:


ubuntu@ubuntu:~$ sudo fdisk -lu

Disk /dev/sda: 250.1 GB, 250059350016 bytes
240 heads, 63 sectors/track, 32301 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008614f

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 63121407 31559680 7 HPFS/NTFS
/dev/sda2 63121408 167979007 52428800 7 HPFS/NTFS
/dev/sda3 167981054 234440703 33229825 5 Extended
/dev/sda5 230895616 234440703 1772544 82 Linux swap / Solaris
ubuntu@ubuntu:~$ And the Gparted screenshot is the third thumbnail. Instead of corrupting the partition table Vista has simply blown the ext4 partition away! WHY?

The ext4 partition was empty, admittedly, but this shouldn't make a difference. So you now have a choice if you decide to use the Windows installer to create one C: partition out of two primary partitions. You can install XP and then have problems with the partition table. Or you can install Vista and say goodbye to the first logical partition. Which if it is your Ubuntu partition, that's effectively goodbye to Ubuntu.

Perhaps Vista is getting its revenge for all those Windows installations that have been zapped by the Maverick installer.

Caveat emptor Microsoftii productii. (Something like that.)

Quackers
February 18th, 2011, 03:34 PM
What a mess! Sabotage! MS has lost the plot here.