Sunday, April 18, 2010

Strugling with the partition table

I hate to use MS Windows: 1) insecure 2) dog slow after patching for years. Recently I decided to try Solaris Express or the new OpenSolaris. The first step is to leave some space for Solaris partition, so I deleted a Windows partition.

Now the partition table looks like:

| Free (for solaris) | Ubuntu | Windows | extened partition including several ntfs and linux swap|

Unfortunately, after I installed the solaris, both the existing Windows and Ubuntu failed to boot. For Windows, the error message is: "Windows\System32\ntoskrnl.exe is missing", for Ubuntu, it jumped to grub command  directly.

I guess the reason was probably the partition number changed. I logged into Solaris, run format -> fdisk command, the result is below:

      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 Linux native   2551  5099    2549     21
          2                 IFS: NTFS      5100  7011    1912     16
          3                 EXT LBA      7012  12160    5149     42
          4       Active    Solaris2          1  2550    2550     21

then use ntfscat to show the content of boot.ini of Windows partition:

bash-4.0# ntfscat /dev/dsk/c1d0p2 boot.ini 
[boot loader]
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition" /noexecute=optin /fastdetect
C:\Ubuntu81.img="Ubuntu 8.10"

You can see the partition number "1" is not correct since the Windows partition number has changed to "2". So to fix it: make a new boot.ini (also need unix2dos command to add "/r" for Windows), then overide it on Windows:
 ntfscp /dev/dsk/c1d0p2 ./newboot.ini boot.ini
Also, change the /rpool/boot/grub/menu.lst to correct the partition numbers to:
title Windows
        rootnoverify (hd0,1)
        chainloader +1
title Ubuntu8.1
        rootnoverify (hd0,0)
        chainloader +1

Reboot the system, I can start Windows normally.

Next, for Ubuntu problem, I need to get the content of Ubuntu grub menu.lst. Solaris currently does not have built-in supports for linux ext2/ext3 file system. I need to install some packages by following the guide, then, mount the Ubuntu partition:
mount -F ext2fs /dev/dsk/c1d0p1 /mnt
and got the content of Ubuntu grub menu.lst:

title           Ubuntu 8.10, kernel 2.6.27-14-generic
uuid            2786d26c-beb2-43e6-93a8-1cb3be921f23
kernel          /boot/vmlinuz-2.6.27-14-generic root=UUID=2786d26c-beb2-43e6-93a8-1cb3be921f23 ro quiet splash
initrd          /boot/initrd.img-2.6.27-14-generic

Reboot the system, select to boot Ubuntu in Solaris's grub menu, I was prompted to enter grub command. I tried to manually input: root (hd0,0) and the content of "Kernel....", "initrd....", then boot command, however, the system failed to boot up in the process.

So there must be somthing wrong with the Ubuntu's grub (My Ubuntu's grub was installed in Ubuntu's partition not the MBR), it seems I need to re-install the grub:
grub> root (hd0,0)
grub> install /boot/grub/stage1 (hd0,0) /boot/grub/stage2 p
grub> boot

O.K. The problem is resolved.

Don't delete a partition then create a new partition, it would possibly cause the partition numbers to change, making all things suck.

No comments:

Post a Comment