LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 01-18-2007, 09:21 PM   #1
mlitty
Member
 
Registered: Nov 2004
Posts: 40

Rep: Reputation: 15
How to move installation to a new Hard Drive?


I need to move my installation from two separate HDs to a single HD. The new drive is a different size and partition setup from the other two drives. The two originating drives, we'll call them hda and hdb each hold multiple partitions. I need only one partition from each. They will go on to a target partition, sde. So how do I get hda2 (bootable system) and hdb3 (data) onto sde1 and sde3 respectively?

I've tried
>rsync -av /media/hda2 /media/sde1
and
>rsync -av /media/hdb3 /media/sde3

But for some reason, the target size ends up being larger than the source size.

so I did a
> dd if=/dev/hdb3 of=/dev/sde3 conv=noerror,sync

hdb3 is larger than sde3 even though the data contained in hdb3 is much smaller than the size of sde3, dd totally messed up the partition table of sde. So I've repartitioned with gparted and I'm ready to take another swing at it.

I also realize that I'll have a little editing to do to the fstab and a few other files on the new drive (sde1), and reinstalling grub, before it will boot.

So, to sum up, I'd like to take a partition from hda (ubuntu) and a partition from hdb (mythtv data), and migrate them seamlessly to sde into a bootable working system.


Need more details?
hda2 is a bootable ubuntu system with Mythtv installed, using the partition on hdb3 to store it's files. I've been using it as a multi-purpose system. I now have enough parts to build a second system, and dedicate one to Mythtv and one to a 64 bit linux playground.

I need to move the mythtv-ready ubuntu to sde1 and move 160GB of mythtv data files to sde3 (sde2 is a swap partition)
hda2 is 15GB with 9GB of data
hdb3 is 280GB with 116GB of data
sde1 is 10GB
sde3 is 200GB

All of the other hardware will be the same.
Thanks in advance!
 
Old 01-18-2007, 09:36 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
I just copied my boot drive onto a smaller drive. If I had to do it again, I'd first use dd to copy just the first sector (the master boot record) onto the target drive. This gets the issue of a broken partition table out of the way up front. Then, boot up a liveCD, partition the target drive the way you want, mount the from and to partitions, and run "cp -a /from/* /to".

There are probably better ways, and someone will probably point them out. But this seems the safest to me.
 
Old 01-18-2007, 09:59 PM   #3
mlitty
Member
 
Registered: Nov 2004
Posts: 40

Original Poster
Rep: Reputation: 15
Quakeboy,
Thanks for the fast reply. I have some time, so I'll give it a try.

Well, it turns out that part of my backup problem was due to a failing hard drive. It was a Wester Digital Caviar 250GB, less than a year old, maybe only six months old, and it spent most of its time unused! Well, at least it's under waranty. I sent it back RMA.

Anyway, the cp -a seemed to be working well until the fatal crash. Thanks again
Quakeboy. I've been using linux so long, that I've forgotten that there are simple solutions.

Forall,
Just in case this doesn't go as planned, any other ideas?

Oh, and sorry about the double post. There was a hickup in my browser, so I didn't think the first post was posted.
My bad.

Last edited by mlitty; 01-21-2007 at 11:08 PM.
 
Old 05-01-2007, 02:55 PM   #4
hetOrakel
LQ Newbie
 
Registered: Apr 2005
Location: /dev/home
Distribution: debian etch 2.6.18-4-k7
Posts: 5

Rep: Reputation: 0
from 40gig to 200gig

Hi all,

i want something similar.

My sourcedrive =40 and dest.drive =200 Gig.

You mention dd to copy the first sector, could you help me some more on that? I 'm a real newby!


thanks!
 
Old 05-01-2007, 03:03 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
AwsomeMachine has an Awesome tutorial on "dd" somewhere on LQ. Use the search function.

To copy the MBR, use "dd if=/dev/hda of=/dev/hdb bs=446 count=1". Substitute hda and hdb as appropriate for your machine. Also, use "cp -axu" for the copy command. If I were you, I'd consider setting up 10GB for the "/" drive, and a separate partition with the rest for "/home". You might even consider setting up just 5GB for "/home" and leaving the rest for a separate "/data" partition. You could also look into using LVM to manage your non-root disk space. I have no experience with LVM, though, so I can't help you with that.
 
Old 05-01-2007, 03:34 PM   #6
rob.rice
Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 795

Rep: Reputation: 119Reputation: 119
plug your new hard drive in to your computer
login as root
parttion your new hard drive
mkswap /dev/the swap parttion on your new hard drive
mkbootdisk
"mkdir /hd2"
"mkfs what_ever /dev/your new hard drive "
"mount /dev/your new hard drive /hd2"
"cp -rpf /boot /hd2"
"cp -rpf /bin /hd2"
"cp -rpf /etc /hd2"
so on and so on
do not copy /hd2
edit /hd2/etc/fstab to point to your new swap parttion
pluge the new hard drive in to the place your old hard drive was in
boot from the boot disk your boot disk may not boot to the new hard disk file system and may boot to a ram filesystem so you may need to know how to install the boot loader to another file system than the one root is on run lilo or grub or what ever
reboot your old system on a new hard drive

I have done this 3 times and I have even used this to save me from installing on another
computer

Last edited by rob.rice; 05-01-2007 at 03:49 PM.
 
Old 05-01-2007, 03:54 PM   #7
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
You should not copy /proc, /sys, /dev, or /tmp to the new drive, but you should make directories for them.
 
Old 05-01-2007, 04:11 PM   #8
rob.rice
Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 795

Rep: Reputation: 119Reputation: 119
OR if you have the space to do it you could tar up the old system
and untar it to the new system this is how victor linus is installed
 
Old 05-01-2007, 04:20 PM   #9
rob.rice
Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 795

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by Quakeboy02
You should not copy /proc, /sys, /dev, or /tmp to the new drive, but you should make directories for them.
/tmp , /dev and /sys have a directorie structure that needs to be moved to the new system
and it dose copy the nodes udev will delete the unneeded nodes on shut down

Last edited by rob.rice; 05-01-2007 at 04:26 PM.
 
Old 05-01-2007, 04:22 PM   #10
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 4.0 Etch
Posts: 1,349

Rep: Reputation: 49
The options I've used successfully for copying are "cp -vax ..."
 
Old 05-01-2007, 04:31 PM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Quote:
Originally Posted by rob.rice
/tmp , /dev and /sys have a directorie structure that needs to be moved to the new system
and it dose copy the nodes udev will delete the unneeded nodes on shut down
I do not believe that this is true. As an experiment, try the following:
Code:
mount -t sysfs sysfs /mnt
Then, take a look at /mnt. You will see the stuff you expect.

/tmp is just temp stuff. There shouldn't be anything in there that needs to be transferred.

But, for /dev, I have to admit that I'm not 100% sure. I believe that udev will properly populate it, but I'd have to actually try it to be sure.
 
Old 05-01-2007, 06:01 PM   #12
rob.rice
Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 795

Rep: Reputation: 119Reputation: 119
with out /dev how would / ever get mounted
a lot of user programs need directories set up
in /tmp and will delete some or all of the user
settings if they don't find them I have had
older versions of mozilla do this it created
a new default profile after I did a "rm -r /tmp/*"
to get rid of a lock file

Last edited by rob.rice; 05-01-2007 at 06:23 PM.
 
Old 05-01-2007, 06:21 PM   #13
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Quote:
with out /dev how would / ever get mounted
Good question. One of my systems has a dmraid RAID0 for a boot device. Dev mapper creates the contents of /dev/mapper; they are not constant. So, how is my machine able to boot if /dev/mapper/pdc_bghhiabi1 doesn't exist?

I've just booted that particular machine under knoppix and mounted the linux partition to /mnt. /mnt/dev, /mnt/proc, and /mnt/sys are empty. You are right in that /tmp does have a couple of directories.

Added:
Still and all, if it's not actually temporary, it shouldn't be in /tmp. One of the backup utilities I've tried gives fair warning that /tmp won't be backed up. So I dunno.

Last edited by Quakeboy02; 05-01-2007 at 06:24 PM.
 
Old 05-01-2007, 07:07 PM   #14
rob.rice
Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 795

Rep: Reputation: 119Reputation: 119
I think the dierectories in /tmp are used as a flag so some programs can tell wether they have been configured of not
your right about /sys
 
Old 05-01-2007, 09:42 PM   #15
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by Quakeboy02
I just copied my boot drive onto a smaller drive. If I had to do it again, I'd first use dd to copy just the first sector (the master boot record) onto the target drive. This gets the issue of a broken partition table out of the way up front. Then, boot up a liveCD, partition the target drive the way you want, mount the from and to partitions, and run "cp -a /from/* /to".

There are probably better ways, and someone will probably point them out. But this seems the safest to me.
Won't work. When grub sets up the drive, it sets locates the absolute physical address of the second stage bootloader on the HD and hardcodes that address into the MBR. When you copy an MBR, then use cp to move files, you can be sure that the stage 2 bootloader won't be in the right place.

Using cp to move the files in is OK, but then run grub to set up the drive for boot.

Assuming your boot partition is hda1, then you set up grub as follows:

From a shell command line, as root, enter the command: grub

This will give you a command line in the grub program. Enter the command: "root (hd0,1)" (with no quotes). Grub will respond telling you what the file system on the partition is.

Then enter the command "setup (hd0)" . This will cause grub to rewrite the MBR with the proper information.

Then enter the command "exit" to exit grub.

Note that grub identifies hda as hd0, hdb as hd1,and so forth. Partitions count from 1, so hda1 is (hd0,1); hdb4 is (hd1,4) and so forth.

If you are using SCSI drives, they are identified by their order on the SCSI bus.
 
  


Reply

Tags
migrate, mirror, partition


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
Move Suse installation to new drive sirmerced Suse/Novell 1 02-07-2006 03:12 AM
Hard drive dying. Need to move Linux partition over. Fear58 Linux - General 3 01-29-2005 06:14 PM
Move an existing partition to a new hard drive? vdemuth Linux - Hardware 9 06-04-2004 03:29 AM
can i move my hard drive to a different computer citrus Linux - General 5 04-12-2004 04:30 AM
Can I move my linux installation to another Hard Drive? enderjm Linux - Newbie 7 03-11-2004 03:00 AM


All times are GMT -5. The time now is 10:18 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration