LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-05-2005, 10:30 PM   #1
TheOneAndOnlySM
Member
 
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987

Rep: Reputation: 30
copying root system to another partition


I think I've grown Too attached to my current setup...

I want to copy my current entire install onto another disk partition (not just /home because the other directories have modifications I would rather recycle), but it seems that cp does not preserve symlinks

Is there way to cause cp to copy symlinks as symlinks?

I could possibly use makepkg to create a .tgz of root and have it preserve the symlinks, but since I've used 30 gigs and only have 25 gigs of free space left, I'm not sure how plausible it would be to squeeze in the space needed to dump a .tar file and then have it compressed

Any comments on that idea? Is it possible to have the .tgz file saved on an empty partition and let the work try to complete within the limited 25 gigs?


Lastly, aside from changing paths in fstab and altering lilo.conf, are there any possible problems I'll face in this endeavor?

Thanks in advance!
 
Old 02-06-2005, 12:22 AM   #2
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
When I switched drives a while back I booted from the install CD and copies over with these options:

Code:
cp -rp /path/to/source /path/to/destination
My system did have one boo boo when it booted. I then rebooted and all was fine. May have been a coinadence though. It's been running ever since.

Code:
root@smoker / # uptime
 00:22:23 up 87 days, 17:58,  4 users,  load average: 0.00, 0.14, 0.29
root@smoker / #
Seems to work anyway.

Later

 
Old 02-06-2005, 12:32 AM   #3
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
you can still use tar if you want like this..

cd /
tar -cv <other options you want> --exclude=./mnt/new . | ( cd /mnt/new; tar -x )
 
Old 02-10-2005, 06:31 PM   #4
TheOneAndOnlySM
Member
 
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987

Original Poster
Rep: Reputation: 30
Awesome thanks, I'll update this post when I get everything transferred. It looks like booting from the install cd or any live cd and mounting both drives would be the cleanest option.
 
Old 06-01-2005, 02:48 PM   #5
TheOneAndOnlySM
Member
 
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987

Original Poster
Rep: Reputation: 30
hmm, well, finally got around to performing the transfer... wow i'm a procrastinator...

The specifics: moving the entire linux install root from an ATA harddisk located on hdb5 to a SATA harddisk partition located at sda5 ; all file attributes needed to be preserved (ownerships, times, symlinks, etc).

First, (in the hdb5 install), I recompiled my kernel to include the necessary SATA options into the kernel as opposed to modules (initrd is another option); these options/modules were configured in - sg (scsi generic), sd_mod, scsi_mod, ata_piix (the controller for my intel motherboard)

Second, I updated my lilo.conf to include a new entry with root = /dev/sda5 . Since the kernel included support for the ata and sata drives, both hdb5 and sda5 used the same image = /boot/vmlinuz . Run lilo to install these new configuration options.

Third, booted up knoppix (any live cd with (c)fdisk and mke2fs would work) to reformat the sda drive. As advice, do not use qtparted to do partitioning and formatting work becauses it had some tendencies to incorrectly write partition data.
As root, I ran cfdisk to delete all parititions. I create a separate primary partition for /boot, an logical partition for swap, and a logical partition taking the rest of the space for / . Rebooted the live cd (to have the partition table re-read correctly), I then created the filesystems with mkfs.ext3 /dev/sda1 , mkfs.ext3 /dev/sda5 , mkswap /dev/sda6 .

Fourth, mounted all the necessary partitions with suid and dev permissions. For example, mount /dev/hdb5 and /dev/sda5 with -o dev,suid as they are corresponding partitions. In knoppix, I changed directory as root into the hdb5 mount at /mnt/hdb5. I then issued cp -a . /mnt/sda5/ ; the -a flag stands for "archive" and preserves as much about the files as possible. The "." states that the current directory's contents are to be used and the destination area is provided. The total time it took to copy 40 gigs of info on a 3.0 ghz processor with 512 meg ram was about 4 hours. The same approach was used to copy the contents of /boot .

Fifth, edited the /mnt/sda5/etc/fstab file to change where /boot , / , and swap to be located at /dev/sda1 , /dev/sda5 , and /dev/sda6 respectively. Edit /mnt/sda5/etc/lilo.conf to change the boot parameter to boot = /dev/sda . Other minor cleanups can be done, such as editing rc.modules to comment out unneeded entries, etc.

Sixth, reboot, remove the live cd, and the lilo screen will be read from the old harddisk (hdb5 in this case). Choose the entry for booting from the SATA drive. There should be no problems. Once booted and everything checks ok, rerun lilo to place the loader on the new drive. Reboot, go into the BIOS and have it boot from the new drive before the old drive. With that, and you've successfully transferred to a new harddrive.


The transfer was extremely smooth and I had no troubles (once I stopped using qtparted... ) . The steps seem long, but once you get going, the process will feel more natural and sensical . Also, you can transfer to a new filesystem should you desire (I somewhat wish I had created a reiserfs filesystem).

Thanks again!

Last edited by TheOneAndOnlySM; 06-03-2005 at 01:25 PM.
 
Old 06-01-2005, 04:03 PM   #6
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
Glad things went so well. I'm sure it was better than a reinstall from scratch.

Later

 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the difference between real root system and normal root system zameer_india Linux - Newbie 17 07-04-2012 12:18 PM
Root partition damaged, system will not boot- How to repair? applewax Linux - General 1 05-27-2005 11:53 AM
Copying Partition? dun_noe Debian 4 10-16-2004 01:23 PM
I updated the system and now only root can see a mounted partition ganninu Linux - General 15 11-15-2003 03:30 PM
copying the root filesystem Nevion Linux - General 4 09-01-2003 02:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration