Copying disks with Linux: Difference between revisions

From Try-AS/400
Jump to navigation Jump to search
(→‎Weblinks: +Link)
(Updated with information from Friedkiwi)
Line 15: Line 15:
* use <code>lsscsi -g</code> to identify the disk(s) on the bus, and also list their SCSI Generic device node,
* use <code>lsscsi -g</code> to identify the disk(s) on the bus, and also list their SCSI Generic device node,
* Duplicate the Disks's content with sg_dd (example):
* Duplicate the Disks's content with sg_dd (example):
  sg_dd if=/dev/sg0 bs=522 of=outfile_522.dd
  sg_dd blk_sgio=1 if=/dev/sg0 bs=520 of=outfile_520.dd verbose=2 sync=1 -p


If is very important to know that (with some exceptions)
If is very important to know that (with some exceptions)
Line 22: Line 22:


If in doubt, use <code>dmesg</code> to scroll through the kernel message buffer and locate the position where the SCSI disk(s) is/are identified with their block size. It is important to use the correct blocksize in the <code>bs=</code> parameter.
If in doubt, use <code>dmesg</code> to scroll through the kernel message buffer and locate the position where the SCSI disk(s) is/are identified with their block size. It is important to use the correct blocksize in the <code>bs=</code> parameter.
== Reformat ==
You can reformat drives to matching block size like this:
sg_format -v -v -6 --format --size=520 /dev/sg0


== Restore ==
== Restore ==
First, make sure the new target disk has been formatted to the correct block size. The best way to do this is to IPL the target system via CD or tape, and use the DST provided utilities to do the formatting.
First, make sure the new target disk has been formatted to the correct block size. A proven way to do this is to IPL the target system via CD or tape, and use the DST provided utilities to do the formatting.
 
In theory, the <code>dd</code> statement from the backup just needs to be reversed to copy back the image file to the disk.
sg_dd if=outfile_522.dd bs=522 of=/dev/sg0
 
In practice, the copy command exits quickly with
31+1 records in
32+0 records out


Further investigation is necessary to provide a reliable way to copyback.
Then you can write back the image to a given disk:
sg_dd blk_sgio=1 bs=520 of=/dev/sg1 if=outfile_520.dd verbose=2 sync=1 -p


== See also ==
== See also ==

Revision as of 11:04, 30 June 2023

Qsicon Fixme.png This article isn't finished yet or needs to be revised. Please keep in mind that thus it may be incomplete.

Reason: How to restore

PXE booted PC as SCSI Attachment Station

Since (mainly) older machines are very picky about Tape Drives, and existing tape drives either become defective, or working tape cartridges become more and more scarce, an alternative to regular full backups on tape is needed. Offline backups become more and more a viable alternative, despite the higher effort of (temporarily) extracting the disk(s) to hook them up to a SCSI equipped Linux PC.

IBM "blessed" AS/400 disks are different in some ways, which makes it difficult do cope with them on Linux. Fortunately, most problems can be avoided by using the SCSI Generic facilities to talk to the device(s) in question. For this, it's mandatory to have the sg3 utils package installed. In addition, the lsscsi package is also mandatory for checking devices on the bus from within Linux.

This article assumes basic knowledge about SCSI:

  • How to avoid duplicate device IDs,
  • proper bus (cable ends) termination.

Please see the articles in the See also section for further details.

Backup

  • Attach the disk and boot the PC,
  • use lsscsi -g to identify the disk(s) on the bus, and also list their SCSI Generic device node,
  • Duplicate the Disks's content with sg_dd (example):
sg_dd blk_sgio=1 if=/dev/sg0 bs=520 of=outfile_520.dd verbose=2 sync=1 -p

If is very important to know that (with some exceptions)

  • PowerPC based AS/400's use 522 Bytes per sector, and
  • CISC architecture AS/400's use 520 Bytes per sector.

If in doubt, use dmesg to scroll through the kernel message buffer and locate the position where the SCSI disk(s) is/are identified with their block size. It is important to use the correct blocksize in the bs= parameter.

Reformat

You can reformat drives to matching block size like this:

sg_format -v -v -6 --format --size=520 /dev/sg0

Restore

First, make sure the new target disk has been formatted to the correct block size. A proven way to do this is to IPL the target system via CD or tape, and use the DST provided utilities to do the formatting.

Then you can write back the image to a given disk:

sg_dd blk_sgio=1 bs=520 of=/dev/sg1 if=outfile_520.dd verbose=2 sync=1 -p

See also

Weblinks