# Copy a mac HD in a x86 box, & sync on a LAN back to mac?

## turtles

I have a imac G3 rev B 233mhz running 2.6.14-gentoo-r5 #4 which can only have one hard drive. That drive is fullish and the little thing does a good job as a server.  I would like to replace the ext2 & ext3 4G drive with a much larger 100G that is formatted for best filesharing like nfs? I use the G3 as a server meaning I have no GUI just a cmd line and only log into it thru ssh, it does have a cd although I have never used it other than to install gentoo fom the live cd. Since I use it for testing and web DB server the only thing I really need to save is a sql-ledger DB alredy backed up onto my desktop. The rest is just gentoo, cups, postgress, apache, sql-ledger etc but it is pretty up to date. So I dont want lots of down time, I would rather not re compile everything.

 What is the best way to put in a bigger drive? what is the best filesystem for the new drive? If I get a old apple laptop could I sync just the server and use nfs to do updates to the laptop?

 I could follow one of these paths:

1) turn off the box swap dirves install a minimal cd format the new drive to nfs or ext3 and re install gentoo from scratch, reinstall the servers & sql-ledger.

2) could I turn off the box swap drives put the old 4G drive in my 2.6.14-gentoo-r5 #4 x86 desktop box as a slave (leaving it there as the /root back up destination for the ppc?) and copy 

```
scp
```

it back over to the newly formatted drive from ssh on the live cd? is ssh on the live cd? or sync to that drive on my desktop box some how?

3) log into the box over ssh tar the entire 4G drive (how do I save the output of tar to my desktop?) turn off the server swap drives untar the old drive from the live cd over the network on to the newly formatted 100g drive?

4) use 

```
dd
```

 over ssh some how?

I have spent a coupple of hours reading the forums, docs, manpages the web etc, but havent found the best direction or a good how to.

Any thoughts?

----------

## MEW

What I would recommend doing is this:

 Turn off the server, swap drives, put the old drive in your desktop

 Boot the gentoo livecd on the server.

 On the server's new disk, create the same partitions you had on the old drive (bigger, if you want). 

 Do not create filesystems on the partitions ("format" them). 

 Set the root password on the livecd environment, and start the ssh server

 Assuming that the server's old disk is /dev/hdb on the desktop, and the new hard disk is /dev/hda on the server, run these commands on the desktop (as a user): 

```
cat /dev/hdb1 | ssh root@yourserver "cat >/dev/hda1"
```

 and 

```
 cat /dev/hdb2 | ssh root@yourserver "cat >/dev/hda2"
```

 and so on. This will transfer the data from each partition on the old disk to its counterpart on the new disk, over the network.

 Resize the filesystem on each partition of the new disk to fill its partition: 

```
resize2fs /dev/hda1
```

 and so on (as root, on the server)

 Install GRUB

 Edit any necessary configuration files to match the new hard disk (e.g. /etc/conf.d/hdparm), then reboot. 

Actually, it would be faster (no network bottleneck) if you could put both the old AND the new hard disks in your desktop at the same time and transfer them there (create partitions, use dd or cat to copy the data from each partition to its new counterpart, resize filesystems, install grub, edit config, and put the new disk into the server), but transferring 4GB over a LAN shouldn't be too bad speed-wise. 

Oh, and FYI: NFS lets you use files stored on one computer on another; it is not a filesystem that you can format a partition with. [/code]

----------

## turtles

OMFG too cool thank you, thats the thing I like about gentoo simple practical advice. Now if I had not purchaced a refurbished hard drive that doesnt work i'd be done.

beers and cheers all around

----------

## MrUlterior

 *turtles wrote:*   

> OMFG too cool thank you, thats the thing I like about gentoo simple practical advice. Now if I had not purchaced a refurbished hard drive that doesnt work i'd be done.
> 
> beers and cheers all around

 

Follow MEWS advice, but instead of ssh -- use netcat. You're on a LAN, what's the point in wasting cpu cycles encrypting then decrypting data? It'll be significantly faster.

----------

## voytas

My advise: use TAR  :Exclamation: 

this way you'll defragment partitions during data move...

you can use tar over ssh eg:

```
tar cp /mnt/olddrive/hda1 | ssh login@server tar xp -C /mnt/newdrive/hda1
```

the only difference is that you'll have to format new hd partitions first, but that leaves you the opurtinity to change FS type  :Smile: 

hopefully you understood what I am writing about...

EDIT:

yes, netcat could save you some time  :Smile: 

on the server do:

```
netcat -c -l -p port_number | tar xpv -C /mnt/newdrive/hda1
```

and on the workstation:

```
tar cp /mnt/olddrive/hda1 | netcat host port_number
```

never tried that, but it should do its job  :Smile: 

EDIT2:

removed netcat -c option in second code block (when i've tested it, it broke tar, so when finished just press ctrl+c on the  workstation to close both netcats)

----------

## MEW

If you're looking for speed, even faster than netcat would probably be local copying (if you have enough IDE slots in your desktop).

EDIT: And if you want to defragment the files while you copy them locally, you can format the filesystem on the new hard disk, then mount both old and new, and use something like 'cp -a /mnt/hdb1/* /mnt/hdd1/' or 'rsync -a /mnt/hdb1/ /mnt/hdd1/' (both as root) to copy the files (be sure to use -a to cp or rsync so that all permissions, owners, etc. get preserved ("archive" mode)).

----------

## turtles

so I removed the old drive and installed it as a master in place of my cd on hdc and I get 

```
parsons turtle # fsck.ext3 /dev/hdc

e2fsck 1.38 (30-Jun-2005)

Couldn't find ext2 superblock, trying backup blocks...

fsck.ext3: Bad magic number in super-block while trying to open /dev/hdc

The superblock could not be read or does not describe a correct ext2

filesystem.  If the device is valid and it really contains an ext2

filesystem (and not swap or ufs or something else), then the superblock

is corrupt, and you might try running e2fsck with an alternate superblock:

    e2fsck -b 8193 <device>

parsons turtle # mount -t ext3 /dev/hdc4 /mnt/hdc4

mount: special device /dev/hdc4 does not exist
```

the 2 partitions I need are 4 and 6 

I added all the partitions of the drive to my fstab 

```
dev/hdc1      /mnt/hdc1   auto      noatime      0 0

/dev/hdc2      /mnt/hdc2   auto      noatime      0 0

/dev/hdc3      /mnt/hdc3   auto      noatime      0 0

/dev/hdc4      /mnt/hdc4   auto      noatime      0 0

/dev/hdc5      /mnt/hdc5   auto      noatime      0 0   

/dev/hdc6      /mnt/hdc6   ext3      noatime      0 0
```

do I need anything elce?

It is a drive from a mac and there are those little partitions (hdc1 is that apple somthing or the other 32megs and hdc2 Is 800 megs apple this or that or so) can the drive not be read by my gento x86 box because the super block is in the apple partitions?

----------

## voytas

give us results of

```
fdisk -l
```

----------

## MEW

I think the problem with fsck is where you ran it; fsck is supposed to be run on a partition that has a filesystem on it; Try "fsck /dev/hdc3", for example. 

As well as "fdisk -l", please post "fdisk -l /dev/hdc".

----------

## turtles

```
parsons turtle # mount /dev/hdb6 /mnt/hdb6

mount: special device /dev/hdb6 does not exist

parsons turtle # fdisk -l /dev/hdb

Disk /dev/hdb: 4310 MB, 4310433792 bytes

9 heads, 63 sectors/track, 14848 cylinders

Units = cylinders of 567 * 512 = 290304 bytes

Disk /dev/hdb doesn't contain a valid partition table

```

 partition table is 1p on a mac how can I tell it to look there?

Extra info:

```
# <fs>                  <mountpoint>    <typ$

# NOTE: If your BOOT partition is ReiserFS, $

/dev/hda1               /boot           ext2$

/dev/hda3               /               ext3$

/dev/hda2               none            swap$

/dev/hdb1               /mnt/hdb1       auto$

/dev/hdb2               /mnt/hdb2       auto$

/dev/hdb3               /mnt/hdb3       auto$

/dev/hdb4               /mnt/hdb4       ext2$

/dev/hdb5               /mnt/hdb5       auto$

/dev/hdb6               /mnt/hdb6       ext3$

/dev/cdroms/cdrom0      /mnt/cdrom      auto$

/dev/fd0                /mnt/floppy     auto$

# NOTE: The next line is critical for boot!

proc                    /proc           proc$

```

Any Ideas? You all are too cool.

----------

## MEW

I think that you need support for macintosh partition tables compiled into your kernel to be able to use a hard disk from a mac. The option is in "File Systems"/"Partition Types" (you have to turn on "Advanced Partition Selection" there before you the other options show up).

----------

