Monday, May 1, 2017

windows - Move an existing Linux install to a new multiboot setup



I have an Ubuntu 10.04 LTS installation on a failing hard drive (I already have my data backed up so that is not an issue.) I want to move the current Ubuntu install intact to a new hard drive.
The new hard drive will also need to boot 1 version of Windows for legacy software and 1 other linux distro (that will change from time to time for test purposes.



My current Ubuntu partition scheme:
/dev/sda1 ext2 boot
/dev/sda2 Linux swap
/dev/sda3 Linux extended
/dev/sda5 ext4 LVM2 pv




What would be a a good (i.e. simple, straight forward) approach to accomplishing this?
I am not considering a virtual machine setup because most of my hardware is pretty old.



I've multi-booted many o.s's But never had to move a Linux install to a multi-boot or worked with LVM much.


Answer



It is a well-known fact that "Windows does not play nice with other partitions". Still it is possible.



Though I have never done it, I believe the strategy below is sound. And you can easily backtrack from it, should anything untoward occur.




1) determine the size of your current disk, minus boot partition.



2) Go to your new disk, and format it as follows: make a NTFS partition for Windows, one extN for Linux. It is not important that you break the Linux space into 2+ partitions nor whether you use ext2/ext3/ext4, we are going to overwrite that with dd shortly.
Just make sure that the Linux partition is at least as large as your current disk, minus the boot partition.



This step must be performed from a live Linux distro, I suggest you use Ubuntu for reasons that will be made clear later.



3) Install Windows on the new disk, in the only partition it recognizes, i.e. the NTFS one.



4) Make sure it has not trespassed onto the Linux partition. You can easily do so from the Live Ubuntu stick, using gparted.




5) Now dd your old disk onto the new disk, in the Linux partition. You use the live distro again, to do this.



You do not need to unhinge your old disk, just use an external HD as a "transfer agent".



When dd'ing onto the new disk, you need to skip the Windows partition. If the Windows partition is X MiB, then the following command will do



 dd if=/dev/sdT of=/dev/sdV bs=1M skip=X



Now you see why I told you it was useless to subdivide the Linux partition on the new disk: the reason is that in this step we overwrite it.



6) There are a few more things to check. First, do you have an /etc/fstab that uses GUIDs? If so, it's ok because of course GUIDs are preserved by dd'ing. Otherwise, you will have to edit the /etc/fstab to identify the partitions to be mounted. You can do this from the live, by means of a chroot jail in the / folder of the newly created Linux filesystem on the disk, but my suggestion is to do it, if you have not done it already, on your old system, before abandoning it. You will find your work already done on your new system.



Second, check that you have the drivers for your hardware, especially ethernet, wireless and monitor. You may download them from the live, then again transfer them inside the chroot jail and install them from within chroot.



7) This is where I tell you why I suggest you use Ubuntu. Your new system cannot possibly boot Ubuntu because we have left its MBR behind, and the new one was installed by Windows when Linux was not yet on the system. But Ubuntu has a very nice utility called Boot Repair, which you can download onto the live, and use it to fix the MBR and grub.



That's all folks.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...