LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-14-2006, 11:34 AM   #1
d00bid00b
Member
 
Registered: Aug 2005
Location: London, UK
Distribution: Debian Testing
Posts: 157

Rep: Reputation: 31
Question Installing a new HDD & transferring data


Greetings one and all

I have been running a 40GB HDD for a number of years now, and every now and then burn data to a CD and then refill it again with new data. I bought a Seagate 200GB HDD today and want to install it onto my existing system, but have a few questions around that as well as around the most effective and secure (i.e. reliable) way of transferring data between the two HDDs.

1. My current, 20GB drive is installed as the primary master drive (/dev/hda). If I want to transfer my data files onto the new 200GB drive, where should I install the 200GB drive to do this effectively and reliably?

2. I will then be removing the 20GB drive and installing that into a second machine. If the 200GB drive has been partitioned, and now has the data from the 20GB drive, can I change the position of the new 200GB to primary master or will that destroy/scramble the data and the partitions?

3. Given the above, is there a preferred or optimal way of accomplishing my objectives, which are to:
(a) transfer existing data from the 20GB to the 200GB
(b) uninstall the 20GB and install it into a second machine

I hope this makes sense, but if not, let me know and I'll try to be more clear.

Thanks in advance.

Cheers
 
Old 08-14-2006, 01:04 PM   #2
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Running only linux?? If so here is what I usually do get a Knoppix boot disk and at the opening splash screen use knoppix 2 dma once at the # prompt.

Code:
cfdisk /dev/[hs]d?
To partition the new drive changing the [hs] to h or s depending on whether new drive is IDE or SATA the ? to the drive letter of new drive partition then reboot to make sure the new partition(s) are read properly use the knoppix command again.

Code:
mkfs.???? /dev/[hs]d??
Code:
mkswap /dev/[hs]d??
Changing again to the proper values for the new partitions b1,b2,c1 .... using either resierfs, ext3, ext2 ... for the file system so you format the partitions and setup the swap space. Then you.

Code:
mount /dev/[hs]d??  /mnt/[hs]d??
mount /dev/[hs]d??  /mnt/[hs]d??
Mount the original then new partitions that will be copied to from again changing to proper drive letter/partition number drive type h or s.

Code:
cp -Rp /mnt/[hs]d??/* /mnt/[hs]d??/
Copy all the data from original drive/partition to new drive/partition again changing to proper drive letter/partition number drive type h or s. Repeat the mount and cp commands for any other partitions with data you want copied. Now hopefully you are using grub for your boot loader otherwise it can get complicated with LILO (and I forget most of that) so if grub.

Code:
chroot /mnt/[hs]d??/
grub
setup (hd1)
exit
This chroots (changes root) to your new drive root partition and sets up grub to the MBR and exits grub. Now if this an IDE drive and it is going to be detected as the hda then no further changes need to be made if SATA the you need to.

Code:
vi /mnt/[hs]d??/etc/fstab
vi /mnt/[hs]d??//boot/grub/menu.lst
Changing the hd to sd references in both files to reflect the SATA drive and you would need to change both files if you changed the partition numbers of where your /home, /root (in menu.lst) were residing. You would then shutdown disconnect the old drive install then new in its place boot and hopefully go right into your install as it was on the new drive. You may want to use this script I found to make a grub boot floppy just in case so you can get back into your system.

Code:
#!/bin/sh
# Script For Creating Debian Boot Floppy (1st line in file)
# Contributed by Bob Plett
# Changed by Stephen Cormier to reflect the new /media/floppy instead of /mnt/floppy
# Copy fron just after the above dotted line to a text editor
# name the file makegrubfloppy (no extention)
# ------------------------------------------------
# * As root save the file to your /sbin/ directory
# * Right click on /sbin /makegrubfloppy file and select Properties
# * Select the Permissions tab of the Properties dialog
# * Click on the check box for Is executable
# * Click OK
# * Close File Manager
# ------------------------------------------------
# You can now insert a floppy disk into the drive, open KMenu > System > Terminal - Super User 
# Mode and execute the command makegrubfloppy to create a bootable floppy disk that will provide 
# exactly the same boot menu you have when booting from your hard drive.
# ------------------------------------------------

#
# This script formats the floppy and writes the current grub configuration to floppy.
#
mkfs.ext3 /dev/fd0
mount /dev/fd0 /media/floppy
cd /media/floppy
mkdir boot
cd boot
mkdir grub
cd /boot/grub
cp * /media/floppy/boot/grub
umount /dev/fd0
grub --batch --device-map=/dev/null <<EOF
device (fd0) /dev/fd0
root (fd0)
setup (fd0)
quit
<<EOF

Now you need to change the /media/floppy parts in the file to where your floppy drive gets mounted after making changes to use save file then as root chmod +x makegrubfloppy and sh ./makegrubfloppy in the directory where you saved the file with a floppy in your drive. I would recommend making the floppy first then rebooting using it to boot from to confirm that it works before trying anything else. Now if everything goes bad and neither grub on the mbr or the floppy want to boot your install you can try from either splash screen hitting the c key to take you to the grub command prompt where you can type in.

Code:
root (hd0,?)
Changing the ? to one number less than your root partition number of the install eg. /dev/[sh]da2 would be 1, [sh]da3 would be 2 with no need to change the 0 if it is the first HD in the system. Then type in then enter key again.

Code:
kernel /boot/vmlinuz???? root=/dev/[sh]d? ro
Changing to proper values for the new drive in the root= and the vmlinuz part to reflect your kernel naming once you have typed in the /boot/ part use the hit TAB key for the list of available kernels. Now

Code:
boot
Tell the system to boot hopefully I have not left out anything.

Last edited by HappyTux; 08-14-2006 at 01:06 PM.
 
Old 08-15-2006, 02:31 AM   #3
d00bid00b
Member
 
Registered: Aug 2005
Location: London, UK
Distribution: Debian Testing
Posts: 157

Original Poster
Rep: Reputation: 31
Stephen

Thanks for your extensive, comprehensive and detail response. That was wonderful. I appreciate you having taken so much time and effort.
Your post did leave me with some questions though:

1. When you wrote
Quote:
To partition the new drive changing the [hs] to h or s depending on whether new drive is IDE or SATA the ? to the drive letter of new drive partition
as the drive is an IDE, the command would be cfdisk /dev/hd? the "?" being because part of my question referred to whether it makes any difference whether or not the drive is installed as a primary master (which I am taking to be hda) or a primary slave (which I think is hdb). Because the current HDD is hda, the new drive should be hdb, but (a) does this make any difference to performance and (b) if I configure the new drive as hdb now can this be changed to hda later or won't it matter one way or another. As you might tell, I am a little clueless about this stuff

2. You suggest using a Knoppix boot disk. Is this the same as a "live" CD or are you talking about a floppy disk with Knoppix on that? If I don't have a Knoppix boot disk, I presume this is something that I can download from either distrowatch or from Knoppix's home-page? What would I be looking for exactly?

3. Just to be sure I have this step correctly: when it comes to mounting both the drives, if the existing 40GB (sorry, in my original post I kept referring to it as a 20GB !!) if the original drive is /dev/hda and the new drive is /dev/hdb then I would type in:
Code:
mount /dev/hda /mnt/hda
mount /dev/hdb /mnt/hdb
And then copying data over would be:
Code:
cp -Rp /mnt/hda/* /mnt/hdb
Would this copy the data over and locate it in the appropriate partitions so in effect it would be /dev/hda1 /dev/hdb1 (for the / partition) and hda2 hdb2 for the swap and hda3 hdb3 for the /home?

I will be loading Slackware as my primary distro, but want to load up a couple of other distros for the experience of playing around with other Linux flavours as well as would like FreeBSD loaded too. IIRC, Slackware uses LILO, but others might use GRUB. Any suggestions on reconciling that?

The rest of your reply looks reasonably straight forward (famous last words??), so will pursue that closer to the time.

Once again Stephen, this has been a really helpful response. Many thanks to you.
 
Old 08-15-2006, 01:28 PM   #4
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by d00bid00b
Stephen

Thanks for your extensive, comprehensive and detail response. That was wonderful. I appreciate you having taken so much time and effort.
Your post did leave me with some questions though:
Your welcome.
Quote:
1. When you wrote as the drive is an IDE, the command would be cfdisk /dev/hd? the "?" being because part of my question referred to whether it makes any difference whether or not the drive is installed as a primary master (which I am taking to be hda) or a primary slave (which I think is hdb). Because the current HDD is hda, the new drive should be hdb, but (a) does this make any difference to performance and (b) if I configure the new drive as hdb now can this be changed to hda later or won't it matter one way or another. As you might tell, I am a little clueless about this stuff
It would not matter for what your doing the primary slave would show up as hdb for an IDE drive for SATA it does not matter there is no primary/slave drives they each get their own channel. To check for sure how the drive gets detected use the fdisk -l or dmesg |less it will show the drives in the system in the output. For the cfdisk command use the second (new) drive eg if it shows as hdc then cfdisk /dev/hdc will open it for partitioning which should show you a drive of ~200gb with no partitions on it. You need to choose the New option when creating partitions (use the down/up arrow if the unpartitioned space is not selected, right/left to move among the options at bottom of screen then enter to select them) if you will have less than/= to 4 partitions on the drive then you can choose Primary for all the partitions created, choose the size by typing in the size you want it is in mb so if you wanted ~10gb type in 10000 then Enter and take the option to put it at the beginning it will then show the newly created partition to create another use the arrow to select the remaining unpartitioned space then the New again to create another. Now when you get to doing the Swap you need to highlight it again after creating then use the right/left arrows to get to the Type option then Enter key to select and type in 82 then Enter again it will then show up in the list as Linux Swap and for the partition that is / you should select it again then go to the Boot option and hit Enter key you will see an * appear in the column that says Boot this makes it bootable not really necessary for Linux but always good to do to stop the complaining that cfdisk will do without it.

Now when creating more than 4 partitions you need to make the 4th and all higher partitions are what is called Extended which is just a fancy term for a logical partition (a partition that is contained within another special partition) an example,

Code:
HappyTux:/home/stephen# fdisk -l

Disk /dev/sda: 203.9 GB, 203928109056 bytes
255 heads, 63 sectors/track, 24792 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         122      979933+  82  Linux swap / Solaris
/dev/sda2   *         123        1277     9277537+  83  Linux
/dev/sda3            1278        2432     9277537+  83  Linux
/dev/sda4            2433       24792   179606700    5  Extended
/dev/sda5            2433       24792   179606668+  83  Linux
Here you see a drive with 3 primary partitions sda1 to 3 with the sda4 being the Extended partition container which has my sda5 partition taking up the entire Extended space I could have made the sda5 a Primary but I did it to match the partitions I have on another drive so when I am doing as you are going to they match and not have to mess around to much when copying. Now I could have made a sda6,7,8 ... in this extended partition if I had wanted but if the drive will have less than/= to 4 I make them all Primary most of the time it is easier to keep track of.

Quote:
2. You suggest using a Knoppix boot disk. Is this the same as a "live" CD or are you talking about a floppy disk with Knoppix on that? If I don't have a Knoppix boot disk, I presume this is something that I can download from either distrowatch or from Knoppix's home-page? What would I be looking for exactly?
Yes a Knoppix live CD you can get it from either place download then burn, there is usually an option in burning programs to make a bootable CD from ISO image you do not want to just burn the .iso file to the CD.
Quote:
3. Just to be sure I have this step correctly: when it comes to mounting both the drives, if the existing 40GB (sorry, in my original post I kept referring to it as a 20GB !!) if the original drive is /dev/hda and the new drive is /dev/hdb then I would type in:
Code:
mount /dev/hda /mnt/hda
mount /dev/hdb /mnt/hdb
And then copying data over would be:
Code:
cp -Rp /mnt/hda/* /mnt/hdb
It would be,
Code:
mount /dev/hda1 /mnt/hda1
mount /dev/hdb1 /mnt/hdb1
cp -Rp /mnt/hda1/* /mnt/hdb1/
Quote:
Would this copy the data over and locate it in the appropriate partitions so in effect it would be /dev/hda1 /dev/hdb1 (for the / partition) and hda2 hdb2 for the swap and hda3 hdb3 for the /home?
When copying you need to specify the partitions numbers as I show above there is no need to copy /swap there is nothing there until it is in use on a running system, you just use the mkswap /dev/hdb2 to set it up as swap space and if you wanted too swapon /dev/hdb2 then it would be mounted and available for use during the copying if needed.

Quote:
I will be loading Slackware as my primary distro, but want to load up a couple of other distros for the experience of playing around with other Linux flavours as well as would like FreeBSD loaded too. IIRC, Slackware uses LILO, but others might use GRUB. Any suggestions on reconciling that?
Well you are going to definitely need the extended partitions as I mention above then so make your 3 primary for your install now do the copying then later in the space you can leave unpartitioned or make the partitions if you know what sizes you want to make available as Extended space for these installs. Now with LILO being installed at least in Debian you used to get the option as to where to install the MBR, into the / of your install, install to floppy or not even install it could be the same with Slack. Your best option would probably be install to MBR for now then install Grub if possible it is much easier to deal with. With FreeBSD I am not sure how that would work I only installed a **BSD a couple of times on a spare machine I do seem to remember there being a limitation as to how far into the disk the partitions could be though eg above so many GB it would not boot IIRC.

Ok since you have LILO here are the extra steps to do once the copying is done. Once copied you need to remove old HD setup the new as Primary master then assuming you copied the new partitions to the same locations as the old there should be no need to edit anything you just boot again with the Knoppix CD and,

Code:
mount /dev/hda1 /mnt/hda1
chroot /mnt/hda1/ /sbin/lilo -v
This would mount the / then chroot into it and run LILO to set it up on the MBR, that is assuming that is how it is setup now which I would think it is. Now when installing other Distros that use Grub your probably best off letting one of them install it into the MBR then you will always be able to get to the Grub command shell which I mention in my first post as a recovery option. This will allow you to use the command line to be able to tell the system which install to boot into it would really be best though if you can have it installed in Slack though that way you only would need to edit the /boot/grub/menu.lst in its install to add entries for any other installs you wanted to boot. Hopefully your not totally confused at this point.
 
Old 08-16-2006, 01:40 AM   #5
d00bid00b
Member
 
Registered: Aug 2005
Location: London, UK
Distribution: Debian Testing
Posts: 157

Original Poster
Rep: Reputation: 31
Once again - a fine post Stephen. Thanks - this gives me loads of info to work with. This is something that I am going to tackle when I have a few days off at the end of the month, so have printed out your post and will use it as a guide.
If I have further questions, I'll come back to you, but I think with the info you have provided so far, it looks like the next best thing is to just jump in and work through it.

Once again, thanks for all your help. It is very much appreciated.

Best wishes to you.
 
  


Reply



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
configuration to max data transferring Rednameless Linux - Networking 1 04-28-2006 08:00 PM
Advice needed on transferring data from HDD to HDD denimglen Linux - Newbie 3 03-04-2006 07:33 PM
Transferring data from Linux to Windows satyatechie Linux - Newbie 1 07-13-2005 08:24 AM
Installing a second HDD (with old data) conn-fused Linux - Hardware 2 10-08-2004 06:01 PM
Transferring to new HDD slackmagic Linux - General 6 08-07-2003 08:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:39 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
Open Source Consulting | Domain Registration