PDA

View Full Version : [ubuntu] How I cloned my Ubuntu partition



bugritall
July 28th, 2009, 12:57 PM
I am a linux newbie and I want to upgrade to Ubuntu 9.10 so that I can use Lazarus-gtk2. I have tried all sorts of ways to build Lazarus with gtk2 on my Ubuntu 9.04 installation but without success.

I have already tried out Karmic alpha3 as a separate installation and it fixed my Lazarus problem but it left me with a whole host of new ones and so I abandoned it. However, there still remained the possibility of doing a system upgrade. As a linux newbie, I know only too well how package installations/upgrades can cause problems and I'm unwilling to risk another disaster by implementing something as risky as a system upgrade. Hence the need for a cloned setup for my experiments. This is what I did:

First, I used gparted to create a new partition (sda9) to hold the cloned version of my Ubuntu 9.04 setup. After that my system looked like this:

sda 160GB
sda1 ntfs XP 68D8A514D8A4E214
sda5 ntfs Games 1098546998544F7A
sda6 ext4 swap c0503f88-45b7-4a6b-8982-877c578954e7
sda7 ext4 boot 87f378ec-4a45-4113-b265-b803f9752f28
sda8 ext4 home 9e1697ea-fadd-4090-a138-ab43f2c62ccb
sda9 ext4 - 74e562da-3bac-8021-49f9-c6a8d918f0d1

sdb 500GB
sdb1 ntfs OS E800CD9D00CD735C
sdb5 ext4 ubuntu 8070c8db-d014-4f88-8f58-e74c1069bbfa

sdb 500GB
sdc1 ntfs Transit 4000E8DB00E8D944

sdb 500GB
sdd1 ntfs Knoxx 94D8ADDBD8ADBC3C
sdd5 ntfs Images 92B8F24BB8F22CFB
sdd6 ntfs Music 0888EF7E88EF68A0

As you can see, I am still in the process of migrating from ******* and my drives are all sata - hence the sdan nomenclature, rather than hdan. That also means that they don't get mounted automatically like (I believe) ATA drives do. My swap, boot and ubuntu partitions are mounted during boot, of course, but Ubuntu considers all the others to be removable media. Note that sda8 isn't used at all because I store my data on the ntfs drives and so a separate home partition is surplus to requirements, for now at least.

Anyway, I compiled my chart with help from these:
ls -l /dev/disk/by-uuid/
ls -l /dev/disk/by-label/Having researched various methods of doing backups and the like, I decided to use ddrescue to clone my (sdb5) Ubuntu 9.04 partition to sda9. Note that ddrescue requires that source and target partitions should NOT be mounted and so all of the following was undertaken from the "try-out" environment on Ubuntu's live CD.
sudo -s
apt-get install ddrescue
dd_rescue /dev/sdb5 /dev/sda9After a few minutes I had a bit-for-bit clone of my Ubuntu setup on sda9, including sdb5's label, uuid, fstab and hostname - a situation likely to render the system (and me) severely paranoid. In the interests of preserving everyone's sanity I decided to begin by giving the clone partition a new label:

e2label /dev/sda9 test910I also gave it a new UUID, generated by uuidgen:

uuidgenThis blurted "4a9cecd4-ead2-48f0-927d-c61eccf68a38" and so I gave the clone its new uuid:
tune2fs -U 4a9cecd4-ead2-48f0-927d-c61eccf68a38 /dev/sda9It was now time to adjust the clone's fstab, which I could hear muttering to itself disconsolately in the background:
mkdir /mnt/tmp
mount -t ext4 /dev/sda9 /mnt/tmp
gedit /mnt/tmp/etc/fstabI searched for the comment line in fstab that says "/ was on /dev/sdb5 during installation" and for reasons of clarity I changed the "sdb5" to read "sda9". The following line still contained UUID=8070c8db-d014-4f88-8f58-e74c1069bbfa (appropriate to sdb5) so this needed changing to my new (sda9) one: 4a9cecd4-ead2-48f0-927d-c61eccf68a38

fstab stopped grumbling after that, so I saved and closed it. The next job was to do something about the clone's hostname:
gedit /mnt/tmp/etc/hostnameI changed the existing text to "test910" so that I would be "bugrit@test910" at the clone's command prompt. Then I saved the file, closed gedit and unmounted the clone:
umount /dev/sda9I was nearly done and all I needed to do now was to tell grub about my new installation. My 100MB /boot partition is on sda7 so...
mount -t ext4 /dev/sda7 /mnt/tmp
gedit /mnt/tmp/grub/menu.lstI searched menu.lst for the line that says "## ## End Default Options ###" and I copied and pasted the following five lines so that I had two identical entries for my current setup. I edited the second entry so that the title value became "test910" and I replace the UUID in the kernel line to reflect sda9's new UUID: 4a9cecd4-ead2-48f0-927d-c61eccf68a38
That was grub sorted out so I saved menu.lst and closed gedit and my brand new clone:

umount /dev/sda9I am now ready to post this from my freshly upgraded Ubuntu 9.10 installation, complete with its pretty gtk2 Lazarus! All seems well apart from the inevitable Alpha-version-system niggles, although you Linux gurus will no doubt spot a disaster or two eagerly waiting to happen - but please, please don't. :D

pmlxuser
July 28th, 2009, 01:09 PM
cool, yo said you are a newbie?? is it in ubuntu or linux, i doubt the latter ;)

bugritall
July 28th, 2009, 02:06 PM
cool, yo said you are a newbie?? is it in ubuntu or linux, i doubt the latter ;)I'm retired and so I have had plenty of time to devote to all things Ubuntu, since I first installed it in the spring. I still consider myself a novice, though.

My previous Xnix experience was a brief flirtation with Red Hat about 5 years ago and some COBOL programming on a Mips system, about twenty years back. I'm currently drawing ever closer to finally ditching ******* once and for all. :D

bugritall
July 28th, 2009, 04:48 PM
In case my adjustments to grub's menu.lst weren't explained very clearly in my first post, here is what the relevant section of menu.lst said initially:

## ## End Default Options ##
title Ubuntu
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /vmlinuz-2.6.28-13-generic root=UUID=8070c8db-d014-4f88-8f58-e74c1069bbfa ro quiet splash
initrd /initrd.img-2.6.28-13-generic
quiet

title Ubuntu(recovery mode)
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /vmlinuz-2.6.28-13-generic root=8070c8db-d014-4f88-8f58-e74c1069bbfa ro single
initrd /initrd.img-2.6.28-13-generic

title Ubuntu memtest86+
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /memtest86+.bin
quiet
### END DEBIAN AUTOMAGIC KERNELS LIST

After duplicating and editing, it looked like this:

## ## End Default Options ##
title Ubuntu
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /vmlinuz-2.6.28-13-generic root=UUID=8070c8db-d014-4f88-8f58-e74c1069bbfa ro quiet splash
initrd /initrd.img-2.6.28-13-generic
quiet

title Ubuntu(recovery mode)
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /vmlinuz-2.6.28-13-generic root=8070c8db-d014-4f88-8f58-e74c1069bbfa ro single
initrd /initrd.img-2.6.28-13-generic

title Ubuntu memtest86+
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /memtest86+.bin
quiet

title test910
uuid 87f378ec-4a45-4113-b265-b803f9752f28
kernel /vmlinuz-2.6.28-13-generic root=UUID=4a9cecd4-ead2-48f0-927d-c61eccf68a38 ro quiet splash
initrd /initrd.img-2.6.28-13-generic
quiet
### END DEBIAN AUTOMAGIC KERNELS LIST


Similarly, the relevant bit of fstab initially said:

# / was on /dev/sdb5 during installation
UUID=8070c8db-d014-4f88-8f58-e74c1069bbfa / ext4 relatime,errors=remount-ro 0 1
# /boot was on /dev/sda7 during installation
UUID=87f378ec-4a45-4113-b265-b803f9752f28 /boot ext4 relatime 0 2
# swap was on /dev/sda6 during installation
UUID=c0503f88-45b7-4a6b-8982-877c578954e7 none swap sw 0 0
blah, blah...

After editing, it looked like this:

# / was on /dev/sda9 during installation
UUID=4a9cecd4-ead2-48f0-927d-c61eccf68a38 / ext4 relatime,errors=remount-ro 0 1
# /boot was on /dev/sda7 during installation
UUID=87f378ec-4a45-4113-b265-b803f9752f28 /boot ext4 relatime 0 2
# swap was on /dev/sda6 during installation
UUID=c0503f88-45b7-4a6b-8982-877c578954e7 none swap sw 0 0
blah, blah...

I hope the pretty colours make everything clear. :D