LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-14-2008, 06:19 AM   #1
centguy
Member
 
Registered: Feb 2008
Posts: 390
Blog Entries: 1

Rep: Reputation: 35
"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.
 
Old 12-14-2008, 07:09 AM   #2
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 871
Blog Entries: 9

Rep: Reputation: 103Reputation: 103
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)

Serafean
 
Old 12-14-2008, 07:28 AM   #3
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by centguy View Post
Crucial question: Can I simply untar A.tar in the new partiton to recover A (hmmm ... Is / defined in the new partition?) ??
Yes, but you'll have to reinstall boot loader (using livecd). And you'll probably need to modify few configuration files (/etc/fstab, /etc/hostname, etc.). Make sure all permissions and timestamps are preserved.

Quote:
Originally Posted by centguy View Post
Is the new A bootable (okay, I am not a newbie, I know how to use grub to reinstall GRUB) ?
It won't be bootable with lilo until you reinstall lilo. Not sure about GRUB, but it probably will be same story.

Quote:
Originally Posted by centguy View Post
If there is a nice article somewhere that would be better.
Can't give the link, but you should try searching for clone linux with tar using google.

Quote:
Originally Posted by centguy View Post
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.
Partition table can't be broken by tar. That is - if you put contents of / directory into archive, not contents of /dev/hda or something similar (somehow) .

Last edited by ErV; 12-14-2008 at 07:40 AM.
 
Old 12-14-2008, 08:16 AM   #4
centguy
Member
 
Registered: Feb 2008
Posts: 390
Blog Entries: 1

Original Poster
Rep: Reputation: 35
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.

Question 2:
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
on "/dev/sda-partition-of-A-resides",
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) ?

Cheers!
 
Old 12-14-2008, 06:19 PM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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.
 
Old 12-14-2008, 07:58 PM   #6
centguy
Member
 
Registered: Feb 2008
Posts: 390
Blog Entries: 1

Original Poster
Rep: Reputation: 35
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.
 
Old 12-15-2008, 07:15 AM   #7
centguy
Member
 
Registered: Feb 2008
Posts: 390
Blog Entries: 1

Original Poster
Rep: Reputation: 35
Done. I managed to clone one CentOS5.1. Thanks for confirming the steps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 07:11 PM
k3b: To choose "normal" or "clone" copying grautu Linux - Software 1 01-09-2006 06:43 PM
Unable to mount windows harddrive in Linux: "already mounted" Xandor Linux - Software 10 11-28-2005 03:00 PM
Linux "Partition Magic" Clone needed? rootking Linux - Software 1 06-16-2004 04:20 PM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM


All times are GMT -5. The time now is 08:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration