Cloning an Ubuntu installI've got a Xubuntu 7.10 install on a drive. You gotta have Youtube and that means Adobe's Flash player. Ubuntu's Flash intaller doesn't work so I used alien(8) to install the current flash player which Adobe distributes for Linux in RPM format. And I invested some time in other customizations. Now I want to copy the whole thing onto another drive so I don't have to go through that whole procedure again. The new drive is slightly smaller, so just imaging the drive won't work. I'll partition the new drive and make a file system and a swap area. Then I'll copy all the files. Then I'll make the new drive bootable. I'll do all this with the CD I installed from. First I put the new drive on the same PATA cable as the old one. If you're using SATA each has its own cable but the device names are the same. Booted the Xubuntu CD. Ubuntu calls the old one /dev/sda and the new one /dev/sdb. I use cfdisk(8) which is in the util-linux package. You might like the graphical partition editor GParted better. Both drives have the whole system in partition 1 and swap in partition 2. Don't forget to make partition 1 bootable. Once the new drive is partitioned, reboot. That's because the kernel doesn't know about the new partition table and it will tell mkfs and mkswap the wrong sizes. Make EXT3 file system and swap area: mke2fs -j -L newroot /dev/sdb1 Next I make directories for mount points and mount the source and destination file systems, and copy everything. Both file systems have empty lost+found directories. I remove /t/lost+found so cp(1) won't complain it can't copy a directory onto another with the same name. mkdir /f /t You may be wondering why I'm using the live CD instead of just letting system f copy itself to system t. Directories /dev, /proc, and /sys are funny on a live system, even in init S when only a shell is running. This way system f is not running, so I can just copy it all instead of picking and choosing which directories are funny and which are not. Now the files /f/etc/fstab and /t/etc/fstab are identical. Ubuntu uses unique unit identifiers (uuids) to tell which file system is which, and the uuids in /t/etc/fstab do not match the uuids in the new drive. I'll edit /t/etc/fstab and replace the old uuids with the new volume labels I just made. I use vim(1). You might like gedit(1) or nano(1) better. The lines that look like this: UUID=fc9fe5f3-669f-4344-818f-0c5720b1b04e / ext3 defaults,errors=remount-ro 0 1 change to look like this: LABEL=newroot / ext3 defaults,errors=remount-ro 0 1 The file /t/boot/grub/menu.lst has that UUID in it, too. Change all instances of UUID=fc9fe5f3-669f-4344-818f-0c5720b1b04e (or whatever your uuid is) in that file to LABEL=newroot. Now I'm all done, except the new drive doesn't have a boot sector. I'll use the grub-install script on the live CD. GRUB is fairly OS independent, and it really shouldn't matter if the GRUB on the live CD is different from the one on the system you're cloning. grub-install --recheck --root-directory=/t /dev/sdb That's the only part that took some figuring out. When the grub-install manpage says "images" it means the stage1 and stage2 files. So the --root-directory argument wants to know where to look for the boot directory. By default it will copy the images to boot/grub/ in there. The --recheck was necessary when /dev/sdb was on USB. Adjusting Xorg.confWhen you install the cloned drive in a new machine, The X Window System probably won't work. That's because X.org has its video card drivers in modules, and one of the modules is named in /etc/X11/xorg.conf. Use the lspci(1) commandlspci | grep VGA
to find out what video chip is in the new machine. Then look in /usr/lib/xorg/modules/drivers and find the one that matches your hardware. Edit /etc/X11/xorg.conf. Find the paragraph that begins Section "Device" and has BusID in it. If you've only got one video device, comment out the BusID line. In the Driver line, replace the module name with the one that matches your hardware. |
||