LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   How to clone and rebuild with multi boot (https://www.linuxquestions.org/questions/ubuntu-63/how-to-clone-and-rebuild-with-multi-boot-938192/)

joboy 04-04-2012 11:06 PM

How to clone and rebuild with multi boot
 
Hi there,

I am using a ThinkPad with win7 perinstalled, I replaced the whole system with Ubuntu, but I want to rebuild the system with multi boot, what I want to do is to backup my current running system with Clonezilla, then recover the notebook to original state, and then repartiton and restore my Ubuntu image to it, and then install Grub or similar thing for multi boot, so that I will have the original ThinkPad system recovery partition (F11), plus multi boot to Ubuntu.

I do have experience backup with Clonezilla, but I've problem restore the image, it just won't boot, and I don't know how to install multi boot manually, I know it is much easier to install Ubuntu from fresh, but I don't want to lost all my settings and updates, please advise, thanks !

widget 04-04-2012 11:35 PM

It might be easier and cleaner to just back up your data, including the config files ("hidden files in your /home/<user name> directory) and do a clean install of Ubuntu when you get to that point.

Another thing you could do with your current install is simply use gparted and copy it to someplace else it you have something suitable for that (external drive, etc.) and then just copy it back.

I am sure someone else can tell you about things likd clonezilla which I have never used. I do my moving around with gparted only but then I have places to put it.

I would suggest repartitioning your drive with the Live CD so that you limit the space that MS can take up when you install it. This will avoid having to shrink partitions later.

tommcd 04-04-2012 11:37 PM

Quote:

Originally Posted by joboy (Post 4645071)
I do have experience backup with Clonezilla, but I've problem restore the image, it just won't boot, and I don't know how to install multi boot manually, I know it is much easier to install Ubuntu from fresh, but I don't want to lost all my settings and updates, please advise, thanks !

If you install Windows and the clone Ubuntu to the new system it is possible that the grub boot menu would need to be changed. You could try using a boot repair CD after installing Windows and Ubuntu to try and fix grub: https://help.ubuntu.com/community/Boot-Repair
What you should do is to install Windows to the first primary partition on the hard drive. Then install Ubuntu to a primary or logical partition. Then let grub control the MBR to boot both Ubuntu and Windows.
Here is a great site with tutorials for dual booting Windows 7 and Ubuntu: http://members.iinet.net.au/~herman546/

TobiSGD 04-05-2012 12:11 AM

In a case like yours I wouldn't use clonezilla for the backup of your system, I would use tar.
1. Boot from your Ubuntu Live CD
2. Make a new directory and mount your Ubuntu partition, for example /dev/sda1, to it
Code:

sudo mkdir /mnt/internal
sudo mount /dev/sda1 /mnt/internal

Of course you have to adapt the partition to your needs
3. Make a new directory and mount and external drive, for example /dev/sdb1, to it
Code:

sudo mkdir /mnt/external
sudo mount /dev/sdb1 /mnt/external

4. Create an tar-archive with the contents of your Ubuntu partition on the external disk
Code:

cd /mnt/internal
tar -cf /mnt/external/ubuntu.tar *

This can take some time
5. Umount the external disk to flush the cache and make sure that the whole archive is on the disk
Code:

sudo umount /mnt/external
6. Reboot and install Windows
7. Use the Windows partition manager to shrink your Windows partition
8. Start again from the Ubuntu CD and create a partition for swap and a partition for Ubuntu
9. Mount the external and the internal disk again (like in 2. and 3., of course with adapted partitions)
10. Extract the archive to the new disk
Code:

cd /mnt/internal
tar -xf /mnt/external/ubuntu.tar

11. Adapt your /etc/fstab to resemble the new partition layout
12 Reinstall Grub2

joboy 04-05-2012 12:56 AM

Thanks for the input guys, but the problem is, Lenovo system recovery is supposed to re-image the whole hard drive, so everything else will be gone, it would be much simply to install Ubuntu back at that point, but I want to save time to re-do everything I've spent long time to do, config files are nothing but the updates downloads and apps are huge.

widget 04-05-2012 02:15 AM

If you have an external drive either use the tar ball method or just copy your partition(s) with Ubuntu to it with gparted. Disconnect the external, do your MS thing.

Hook up the external and copy the bugger back to an new unused area of the internal drive. You will in need to check your /etc/fstab for accuracy but this should not be a problem if you are using uuids and you copy with gparted as it will use the same uuid as your origanal partition.

If you don't have an external maybe you could borrow one. Your box also has, undoubtedly, capacity for at least one more internal drive. A moderate sized drive is pretty cheap (say 200 to 320 gigs). Slap one in there.

You will have to follow the directions here under outlind number 12;
https://help.ubuntu.com/community/Grub2

to get grub installed back on the MBR. Then if MS is not on the menu for some reason run from your ubuntu install;
Code:

sudo update-grub
That should put the MS menuentry back on the menu where it belongs.

You should also remember that using Clonezilla will. like the tarball method, leave your fstab with incorrect uuids. You can correct them by, from the LiveCD, running;
Code:

sudo blkid
and editing the fstab from that Live Session too.

Those really are your options. Have, as I said, only used gparted as it is easiest but no matter what you use it is not that tough. There are things you need to do and have correct. If you use the Ubuntu you have it will be set up for a completely different partition table. You need to correct that.

That is much easier than reinstalling.

The OS I am on right now I want to reinstall the / partition on. I do not want down time that amounts to much. I have another install of Debian testing on another drive that I am setting up with the same core of packages I have here so that all my panel launchers and so forth will work. All my custom Thunar right click menu items will work. In a couple of days I will simply use gparted and copy it into this partition which I will have formatted.

I can easily check to make sure it will work from the other drive by pointing it at this installs /home partition in the fstab which will need to be done anyway. Piece of cake.

Or you can reinstall from scratch.

joboy 04-05-2012 05:17 AM

Thanks Widget, I don't realize gparted alone can do so much, I will try to see if I can follow, the dumbest way to do is to install a basic Ubuntu, and then restore the image back, it should fit the partitiion I suppose.

syg00 04-05-2012 06:19 AM

I have seen mondorescue mentioned here a few times, so decided to test it a week or so back.
Creates (in my case) DVD images, the first of which can be booted. Rebuilds partitions, and filesystems - including NTFS. The whole deal.

Took several hours on my laptop to backup, compress and verify a couple of hundred Gig. 8 DVD isos in total.
I had no luck getting the DVDs burned successfully as it ran, so eventually just got it to write isos to disk, then burnt them later. Haven't tested the full system trash-and-rebuild. Nor do I hope to, but I have 4 (yes FOUR) copies of the isos ...
In addition to my data backups elsewhere.

Seems like a good solution to me, having just had my hard-disk (in that laptop) replaced, and a having to do a full rebuild. Win7 plus 3 Linux systems.

TobiSGD 04-06-2012 11:25 AM

Quote:

Originally Posted by widget (Post 4645183)
copy with gparted as it will use the same uuid as your origanal partition.

...


The OS I am on right now I want to reinstall the / partition on. I do not want down time that amounts to much. I have another install of Debian testing on another drive that I am setting up with the same core of packages I have here so that all my panel launchers and so forth will work. All my custom Thunar right click menu items will work. In a couple of days I will simply use gparted and copy it into this partition which I will have formatted.

Won't you run into problems with this approach, since you will have two partitions with the same UUID?

widget 04-06-2012 01:07 PM

Quote:

Originally Posted by TobiSGD (Post 4646540)
Won't you run into problems with this approach, since you will have two partitions with the same UUID?

In the case of the OP this is no problem as the copy would be made into a drive with only MS installed.

You are right of coarse in a general way. If you have copies to several drives that are enabled at the same time there will be duplicate uuids which can totally screw things up.

This is, however, Linux. There is a tool for this problem. Let's say you have an install of Squeeze 2 partitions that you want to copy the / partition so that you can have 2 identical / partition sharing a common /home and upgrade one of them to testing.

You just make your copy and run, as root;
Code:

tune2fs -U clear /dev/sdd10
which clears that partition of a uuid at all and then;
Code:

tune2fs -U random /dev/sdd10
which will give that partition a unique uuid.

For all I know you could get away with using just the second command. I am too chicken to try it that way.

I have used this a number of times now and it works very slick.

Being nervous the first time I opened a root terminal window just for the "blkid" command. Ran it before doing any thing.

Had 3 partitions, one on one drive (original) and 2 on another drive (copies) with identical uuids.

Ran the 2 commands above on one of the copies, went to the blkid window and opened another tab and ran blkid there. Comparing the 2 tabs showed that the uuid of the copy was now unique and, much to my relief, everything else left alone.

Did the same thing again with the other copy and checked the same way.

Am getting ready to use this on my production OS as after 2 years of running it has a huge and bloated / partition. Also on this same drive I have a Sid install that I would like to have identical to this testing install. I have been working on a Wheezy install that was installed just for this purpose. It is just about identical to the install I am on now and I am about to test it by changing the copies fstab to use this /home and boot from it and make sure things are right. Then I will simply delete this /home (after saving the many "treasures" in this / - theme and icon colection and so forth) and copy the new one in.

Will do the same for the Sid install after upgrading that new install to Sid.

This is the easiest way to have a new clean install that I have found. No presure. Can use this install, as is while setting up, pretty completely, the replacement. Can take as long as I like or need to. Can test the results before committing to them. Can then do the delete and copy, randomize the uuid and be done with it.

I believe that using the dd command has the same "problem" but have never done that so am not sure that I am correct at all. It may just copy content rather than partitions.

joboy 04-16-2012 09:22 AM

I just did a test with my portable boot USB flash with gparted, the original flash is 8G, I use gparted to copy the partition to another flash of the same size, and it boot normally. Then I do the same to a 16G flash, and expand the partition to full size, but this time the flash can't boot with invalid partiton error, this is the first time I do this with gparted, please fill me in, thanks a lot !!

widget 04-16-2012 12:53 PM

Quote:

Originally Posted by joboy (Post 4654140)
I just did a test with my portable boot USB flash with gparted, the original flash is 8G, I use gparted to copy the partition to another flash of the same size, and it boot normally. Then I do the same to a 16G flash, and expand the partition to full size, but this time the flash can't boot with invalid partiton error, this is the first time I do this with gparted, please fill me in, thanks a lot !!

Have never used a flash drive but there should be no problem with copying a partition.

The invalid partition error sounds like a problem that may be due to not having gparted set correctly.

I think I would start over with blanked drive. Copy the partition as before but do not resize the partition. Boot to the new install and make sure it works.

Then try to resize the bugger but do not use gparted. Use cfdisk (CLI partitioning tool) as root;
Code:

cfdisk /dev/<whatever the flash drive is>
One problem that gparted has at times is slight over lapping of partitions. I wonder if the partition reads as being bigger than the drive.

I do not believe that cfdisk will do that. It should give you the total size of the partition and the drive. Make sure that the resized partition is no larger than the drive. You may want to reduce the size a very small amount just to be safe.


All times are GMT -5. The time now is 03:19 PM.