Sunday, June 02, 2013

Transferring partitions from one Amiga HDD to another

     Well, you will probably ask - whats the potential problem ? Yes, no problem if there are only Amiga partitions on source drive, but what if there are also Linux and Mac partitions?
     In this case you will probably experience problems how to transfer this partitions. I found the solution.
     First of all,  create partitions on new drive using Amiga HD toolbox to make the RDB  partition table structure and decide what partitions will be used for Linux and/or Mac.
Remember - you have to reserve two partitions for Linux - one main (root) partition and other swap partition.
 After that you will have to save changes and exit HDtoolbox , power off and take  hard drives off the Amiga and connect both - source and destination drives to Linux system. I used a PC with Ubuntu live CD boot disk.Boot into Linux, open Gparted 

and and check that both hard drives - source and target are available. You will see Amiga partitions as Unknown, but Linux partition and Mac will be shown with their filesystem names.  For Linux- root partition Ext2 and Swap partition as swp. So we have to format destination partitions also as Ext2 filesystem for root partition and swap for swap partition. You can do this simply in the same program Gparted or other built in disk utility in Linux.

Now  write down root partition names - source and destination e.g. /dev/sda5  - source and /dev/sdb8 - destination. Swap partitions are not need to be copied( but you can try to avoid swap service problems). Destination partition should have size >= then source.
So we have necessary information to start copy:
  1. if (input file): /dev/sda5
  2. of (output file): /dev/sdb8
(you have to change source and destination to yours partition names!)
So you need to open Terminal windows and type:

 sudo dd if=/dev/sda5 of=/dev/sdb8   

Next, if you source and destination partitions are NOT exactly the same size you will need to make corrections on filesystem on the destination drive to suit new size of the partition. So do the command in Terminal:

sudo resize2fs /dev/sdb8

Again, use yours destination name instead ! Now, we have our partition copied, but we have to make changes in /etc/fstab  file on new drive to be able to boot from this partition. Since it have a new name, without changes in fstab it will not boot correctly.
    Mount your  new Linux partition (you may do this directly from Gparted or Ubuntu disk utility or command line) and open it in file explorer. We need to edit fstab file.

su gedit /etc/fstab

 (Superuser permission is needed to be able to save changes)
Find and replace /dev/sda5 to /dev/sda8 (in my example of course) - usually it is the first line.
Please, notice,  I use sda8 NOT sdb8 because when you boot this partition on Amiga it will be the first  hard drive - sda! sdb is for CD-ROM drive. Save changes, turn off PC and put your drives back to Amiga.
If you partition numbers are the same e.g. sda8 and sdb8 (since on Amiga you used to have only one hard disk there are will be only /dev/sda partitions)  in this case no changes needed in fstab.

    Boot Amiga OS from source drive and start HDtoolbox again.  Check that now your new drive have Linux partitions ! But they are not bootable yet.

At this point you can format other partitions - Amiga OS and copy files from source to destination partitions just using DOpus !
    Macintosh partitions - if you have those - are easy to clone under Mac emulation. When you starting Fusion or ShapeShifter from original drive , add partition from new drive as well. Mac will let you format it and then copy files from old partition to new using Mac files copy.

After all - when you will have only new drive connected and successful boot, start 
 HDtoolbox to check the linux partition name - it should be the same as you set in fstab !

I did that to transfer files from my old ATA HD to CF card  and everything work fine!

 There are many cloning software that able to clone Linux drives, but most of the do not understand RDB partition table that is used by Amiga OS, that's why I made this tutorial.

If you would like to make an image file of your partition (to be able to restore from it lately instead of transferring once again ) I suggest you to use PartImage software. It has a nice bootable CD, its free and you will easily made all steps described above using only partimage CD !

P.S.  I`m not sure but sometimes you may notice warning about SWAPON while booting Linux.
I saw this in several cases but don't know how to fix swapping on new drive so any help will be appreciated ! )

No comments: