AWS95 & A/UX: Disk/Disk or Directory/Directory Copy

This article tells how to copy all the files in the root (/) partition from one disk to another without losing access privileges and without having to recreate the /dev directory.

The following sequence of commands creates a duplicate of the directory structure of the source disk onto the target disk. The same basic command sequence can be used to copy a directory tree from one directory to another.

To Copy The Complete Contents Of A Partition

While logged in as root:

Step 1

Mount the partition you want to copy to (target) on /mnt:

mount /dev/dsk/c5d0s0 /mnt

(Replace SCSI ID and partition as appropriate)

Step 2

Go to the / directory:

cd /

Step 3

Perform the copy preventing the copy from becoming recursive and without overwriting the lost+found directory in the target partition:

find . -print | grep -v /mnt | grep -v /lost+found | cpio -pdlmuv /mnt

Step 4

Create the mnt directory in /mnt:

mkdir /mnt/mnt

chmod 777 /mnt

Step 5

Unmount the target disk and perform an fsck:

umount /mnt

fsck /dev/dsk/c5d0s0

Now you have a copy of the source disk, complete with the /dev directory.

To Create A Duplicate Copy Of A Directory Structure

Step 1

Go to the directory containing the source directory to be copied:

cd /a_directory

Step 2

Perform the copy of the source_dir to the directory where you want the source_dir structure to be moved to:

find source_dir -print | cpio -pdlmuv /target_dir

This results in a directory named source_dir inside of target_dir.

Published Date: Feb 19, 2012