Migrate ubuntu to another partition

Alan McKinnon alan at linuxholdings.co.za
Mon Mar 6 23:08:55 UTC 2006

On Monday, 6 March 2006 18:59, Phillip Susi wrote:
> Alan McKinnon wrote:
> > It's relatively common to have /boot on it's own partition, in
> > this case the step should not be run. In fact if it is run the
> > system will be unbootable - the stage1_5 files in the boot sector
> > (not the MBR) won't be able to find stage2, menu.lst or the
> > kernel images.
> It is not very common in the ubuntu community to have a separate
> /boot partition because the installer does not do it by default. 

I have *always* used a separate /boot where I can and honestly 
wouldn't know what the default is (a few bad experiences taught me to 
never trust partitioning decision made by any installer). Perhaps I 
should have said more prominently that what I said applies to 
dual-boot setups with a separate /boot. I did mention it, but could 
have been clearer.

> Also if you try to install grub to the wrong /boot partition it
> will not make the system unbootable, it will simply fail to install
> because it can't find the stage2 file.

I don't understand what you mean here. Does grub-install not keep it's 
stages in /lib/grub/<arch>, and copy stage 1 and stage1_5 to the MBR 
and boot sector, and stage2 to /boot/grub? At boot time stage1 loads 
stage1_5, which loads stage2 from /boot/grub

On unbootable, this will indeed be the case if grub was installed to 
the / partition, and the bootloader is set up with root(x,y) pointing 
to the /boot partition. But this matters naught if the user did a 
default install.

> > This can be intensely annoying and only seems to happen on the
> > days when you left the repair disc at home. A good tip if you
> > have a separate /boot is to create a symlink called "boot" in the
> > real /boot pointing to ".", and copy a working kernel, support
> > files and menu.lst to the /boot *directory* on /
> Why on earth would you do that?  What good does having a /boot/boot
> => /boot link in the root filesystem do?  And what good does having
> a copy of the kernel and menu.lst in the root fs do?  If grub is
> installed on the /boot partition, then that is where it will load
> stage2 and menu.lst from, and where it should load the kernel image
> from.

It's /boot/boot -> ./ on the partition holding /boot. Again, it's for 
dual-boot systems with more than one distro. To this day I still 
often make the mistake of getting --root-directory=/path/ wrong and 
grub presents me with a completely blank screen. Usual solution = 
reboot with Knoppix, re-run grub-install. With a minimalist grub 
backup on / I instead usually get a grub shell, which can boot. Then 
I don't have to search for the Knoppix cd (which is never handy when 
I need it). The symlink is a gentoo-ism that catches the occasional 
wrong --root-directory path. Since I started using it my grub-install 
failures are zero, one symlink does no harm and when I get it wrong 
it still gives the result I want

> > as root:
> > mount --bind / /mnt/test
> > cd /mnt/test/boot/
> Why make an alias with the bind mount?  Just skip the mount and cd
> to /boot.

My bads, the order is wrong. 'cd /boot ; ln -s . boot' is issued 
before 'mount'. And it's --rbind, not --bind

The --rbind is to get to the files under /boot on the root partition. 
They are hidden once /boot is mounted

> > ln -s . boot
> > mkdir -p grub
> > cp /boot/vmlinuz-xxxxxx ./
> > cp /boot/grub/menu.lst grub/
> That is trying to copy /boot/vmlinuz-xxx onto itself, which isn't a
> good idea.

Nope. It will copy a file from the real /boot partition to the / 
partition at /mnt/test/boot. mount --rbind does not bind sub-mounts

Alan McKinnon
alan at linuxholdings dot co dot za
+27 82, double three seven, one nine three five

More information about the ubuntu-users mailing list