problem installing grub with /boot in a separate partition

Asked by smurf

Firstly I installed ubuntu 8.10 on a machine with windows XP installed, after the installation my disk was like this:
- sda1 with windows
- sda2 /boot
- sda3 /
- sda4 logical
- sda5 empty partition
- sda6 /home

Well, after a while I decided to move windows in VirtualBox, so I changed the disk layout like this:
- sda1 /boot
- sda2 /
- sda3 empty partition to try new ubuntu releases
- sda4 /home

Ok, until now no probs, I moved all data and redefined the partitions with GParted, I defined the boot flag in /sda1 and with gparted live cd I changed the menu.lst in /boot/grub to update new UUIDs and root(hdx,y).
At this point I tried to restore grub with SuperGrubDisk, but I had no lucky. Super GrubDisk didn't do the magic.
So I tried with the rescue option in Ubuntu 8.04 Alternate cd, but neither this was able to restore grub: always said FATAL ERROR.

Finally, I installed Hardy in the empty partition, and defined /boot separated, not formatted the one present on the disk. The installer did everything well, he recognized the boot partition and installed the 2 systems in teh same menu.lst.
Fantastic, I could boot again my Intrepid system... NO, I COULDN' T.
Because the new menu.lst was made with boot root /dev/sda2 (hd0,1) for Intrepid, and /dev/sda1 (hd0,0) for the new installation. Obviously the /boot was empty in Intrepid, it was only a mount point for /dev/sda1.

Ok, the subsequent try was to use grub command line, I gave this commands:
find /boot/grub/stage1
       here grub said to me that it could find stage1 in hd0,0
root (hd0,0)
setup (hd0)
       here grub gave an output confirming all directories and devices where to find stages and so on
quit
reboot

Fatal: Error 15
..... Damn......
I can assure that uuids and root definitions was correct, even I tried to change uuids for /dev/sda1, but always Error 15. I also tried with setup (hd0,0).

No way, the only solution working has been to restore in the /boot directory inside Intrepid, all the files that was in the /boot partition prior the changes in partioned. In the menu.lst I defined root (hd0,1), while the hardy system boot from /dev/sda1 partition. Attached my actual menu.lst.

Now my question is: did I made some errors or what? I really want to understand this because probably I'll have to do again (on others machines) the same procedure and I wish to do it like a charm, as it should be.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub Edit question
Assignee:
No assignee Edit question
Solved by:
Ufuk
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
smurf (luca-dgh) said :
#1

# 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'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 10

## 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/sda2

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)

## 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

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) 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

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##
title Ubuntu 8.10
root (hd0,1)
kernel /boot/vmlinuz-2.6.27-11-generic root=/dev/sda2 ro quiet splash
initrd /boot/initrd.img-2.6.27-11-generic
savedefault
quiet

title Ubuntu 8.10 (recovery mode)
root (hd0,1)
kernel /vmlinuz-2.6.24-19-generic root=/dev/sda2 ro single
initrd /initrd.img-2.6.24-19-generic

title Memtest86+
root (hd0,0)
kernel /memtest86+.bin
quiet

title Other operating systems:
root

title Ubuntu 8.04.1, kernel 2.6.24-19-generic
root (hd0,0)
kernel /vmlinuz-2.6.24-19-generic root=UUID=b431b68e-9428-4577-b299-27365ee6745b ro quiet splash
initrd /initrd.img-2.6.24-19-generic
quiet

title Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root (hd0,0)
kernel /vmlinuz-2.6.24-19-generic root=UUID=b431b68e-9428-4577-b299-27365ee6745b ro single
initrd /initrd.img-2.6.24-19-generic

### END DEBIAN AUTOMAGIC KERNELS LIST

Revision history for this message
Ufuk (ufukkilicaslan) said :
#2

Hello,
If you use a separate partition for /boot directory, you should change some commands to install grub. I will write the correct commands to install.
So, you have sda1 partition as boot. Boot into with livecd. Mount your Ubuntu partition. Move your /boot content (cupaste) to your sda1 partition. Then, you should mount sda1 into your /boot directory. So,

sudo mkdir /mnt/ubuntu #this is for mounting ubuntu, creating a mount point

sudo mount /dev/sda2 /mnt/ubuntu #mounting your ubuntu partition to created point

sudo mount /dev/sda1/ /media/ubuntu/boot #mounting your boot partition to ubuntu's /boot directory

sudo mount -o bind /dev /mnt/ubuntu/dev #needed for /dev info

sudo mount -o bind /proc /mnt/ubuntu/proc #needed for /proc

sudo cp /proc/mounts /mnt/ubuntu/etc/mtab #say "y" to this

sudo chroot /mnt/ubuntu /bin/bash #chrooting into ubuntu, to execute commands and install grub

After this: --Install grub like this:

sudo grub

--in the grub command dialog:

find /grub/stage1 #the trick is here, you should not run /boot/grub/stage1

root (hd0,0) #because you have /boot in your sda1 partition

setup (hd0)

quit

exit

Then control roots and uuids in /boot/grub/menu.lst. root (hd0,0) is correct, because it's the sda1, the boot partition. In the kernel line, uuid must be your ubuntu (sda2) partition's uuid.

After checking these, unmount your partitions and reboot from disk.

Revision history for this message
smurf (luca-dgh) said :
#3

Thanks Ufuk, that solved my question.

Revision history for this message
smurf (luca-dgh) said :
#4

definitely solved. Can I ask you more info? just to understand better.

find /grub/stage1 returned exactly the same output than find /boot/grub/stage1: in the first attempt it looks for a /boot/grub/stage1, if not found it goes fot a /grub/stage1 and it found it. Really the trick is the find command? or the trick is in using a chroot?

if the trick is chroot: Why it is necessary with /boot separated from root? As far as I know, if the boot partition is not separated from root, there is no need to make a chroot to install grub and setup it.

Thanks a lot again for your help

Revision history for this message
Best Ufuk (ufukkilicaslan) said :
#5

1. Yes, if there is a separate boot partition, it looks for configuration in it, so it points the /grub/stage1 (you can think /boot partition as a separate root).

2. Regarding the chroot, I am not sure why it is necessary all the time, may be I am missing something but I remember I got error when setting up the grub with a separate partition without chrooting. Besides this, I prefer chroot because I can use some basic commands and I work comfortable using it for basic configuration. You can read for further information in: https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows It has same information in Troubleshooting section. It describes the method as "cases when grub fails to install".

I am happy to help,.

Revision history for this message
smurf (luca-dgh) said :
#6

Ok ufuk, thanks for the link and much more for your time.
Problem solved 100%

Revision history for this message
Michal Kaut (michalkaut) said :
#7

Ufuk, you have made my day! :)

Revision history for this message
pmtech (pmtech) said :
#8

Ufuk, I LOVE YOU