"best" way to clone a working linux system for backup, repartition harddrive, etc
This is a hypothetical question that is bothering me quite a lot.
I have a linux system A that is working perfectly fine.
I have another linux system B on the same physical machine
that is also working perfectly fine.
However, the partition table for the whole hard disk is not setup in the most efficient way (well, sometimes we just stuck with all the layout as we experiment the linux systems..)
Now, I would like to log on to B, mount the filesystem of A so that B
can access it.
I would like to tar all files from / of B and keep the tar file in A.
The purpose of doing this so that I can use gparted from B to remove the partition where A
resides so that I can create an extended partition out of it.
Then I create a new partition so that I can put A back to the computer.
Crucial question: Can I simply untar A.tar in the new partiton to recover A (hmmm ... Is / defined in the new partition?) ?? Is the new A bootable (okay, I am not a newbie, I know how to use grub to reinstall GRUB) ?
I guess my concern is that I want to be 99.99 percent sure that
it works because any failure would mean reinstalling A (if the partition table is screwed up, I might not be able to boot to B) from scratch and update everything.
If there is a nice article somewhere that would be better.
Thanks for sharing your thoughts.
Hi, I don't see why this shouldn't work, I did something similar : Having a small partition on a small disk, I just copied the / directory to another drive, modified GRUB and fstab and was back up and running.
Untaring a precompiled system works : the gentoo installation is based on this (stage3 tarball to untar in the partition you want, the compile the kernel and one can boot).
Bootable partitions can be defined by fdisk, so its up to you to make it bootable.
Personal comment : I would do this operation from a LiveCD, but thats just me, no special reason for it (except having something to boot in the event of a partition table screwup)
Thanks a lot people. At least I am assured that my idea is not too wild.
Question 1: Is "tar -cvf A.tar /*"
okay to preserve the time stamp and the integrity of the working OS ?
I guess it should be okay. Just to confirm.
About reinstalling GRUB (or lilo, which I am not familiar): Do I need to
issue the grub command that is native to system A rather than any LiveCD ?
Can a Knoppix LiveCD (never use it before, I have come across it on internet a lot) be used to install the grub bootloader for another system A, say Fedora 9, to be specific ?
I am pushing the idea of logging on to B, do "something" (still not too sure how to do yet.. if someone can spell out the explicit steps I appreciate your help!!) to make the new
/ is on system A (i.e, not / of B anymore),
run "/sbin/grub" of system A to install the bootloader
after that I add a stanza in menu.lst of system B, and I should be done (of course, after setting the UUID or LABEL that may
have changed, and messing with /etc/fstab and other stuff) ?
You don't want to backup /dev or /sys. To backup /tmp or /var/tmp would be a waste of time.
You might want to read the section of the tar info manual dealing with incremental dumps. That would allow you to backup only the changes since your first backup. Backing up your first drive while it is running from the second is a good idea, because the files won't be modified during the backup.
Assuming that the installation from both drives have entries in your grub menu. If you boot up the system on /dev/sdb, and only change the sizes of the partitions on /dev/sda, you may not even need to change grubs menu.lst file. You could also update grub to the mbr of /dev/sdb giving you a second drive you can boot from. That would allow you to boot up by selecting the second drive from your computer's quick boot menu. This could be insurance that you can boot up even if you damage the mbr of the first drive.
You can also boot up to a live distro, and instead of booting, go to the grub shell instead. Grub has auto-completion which allows you to locate the kernel and initrd file easily. You don't need to memorize where they are.
I think I have not made myself very clear at the beginning. I have only ONE harddrive on my laptop, and an optional portable hard drive (connected through USB port) to store the tar file if there is not enough disk space on the laptop. But I guess the idea of not storing /dev, and /sys, or /tmp, or /var/tmp is a good way to trim unnecessary files.
Thanks for the reply.
Done. I managed to clone one CentOS5.1. Thanks for confirming the steps.
|All times are GMT -5. The time now is 04:18 AM.|