Migrate ubuntu to another partition

Alan McKinnon alan at linuxholdings.co.za
Sat Mar 4 11:51:26 UTC 2006


On Saturday, 4 March 2006 01:05, Phillip Susi wrote:
> Copy all the files on the root partition over to the new one:
>
> mount -t ext3 /dev/hdb3 /mnt
> cp -ax / /mnt
>
> Then update /mnt/boot/grub/menu.lst to refer to hdb3 instead of
> hdb1, and reinstall grub with:
>
> grub
> root (hd1,2)
> setup (hd0)

This step is only necessary if the partition containing /boot changes. 
This would be the case if /boot is on the same partition as /

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.

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 /

as root:
mount --bind / /mnt/test
cd /mnt/test/boot/
ln -s . boot
mkdir -p grub
cp /boot/vmlinuz-xxxxxx ./
cp /boot/grub/menu.lst grub/

adjust vmlinuz-xxxxxx to suit what you have. Also copy the initrd if 
you use that. When the real /boot is mounted these new files become 
invisible. If you happen to botch a grub-install on a multi-OS system 
these simple steps will save you a heap of trouble. The symlink also 
helps prevent file not found errors if you forget where /boot is 
while re-installing grub and get it wrong. I've made this mistake 
more than once myself :-)

alan

>
> That will install grub on hda but configured to load the kernel
> from hdb3.  Alternatively you may be able to set your bios to boot
> directly from hdb so you can change hd0 to hd1 to install grub
> there instead.
>
> Also edit /etc/fstab and change hdb1 to hdb3 for the root fs entry.
> Reboot and you should be running from the new partition which you
> should be able to verify by seeing that df says / is mounted on
> /dev/hdb3.
>
> Filip Ruymen wrote:
> > Hi all,
> >
> > I want to migrate my installation from one partition to another.
> > currently it is on hdb1 and I want to move it to hdb3.
> >
> > How can this be done without reinstalling everyting?
> >
> > any help or tips on how to do it?
> >
> > --
> > Kind regards
> > Filip Ruymen

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