[Nottingham] dd and partitions (Re: Very slow dd if=/dev/random)
Martin
nottingham at mailman.lug.org.uk
Tue Jul 29 12:47:08 2003
Jon Masters wrote:
[...]
> Not surprising since Linux uses the standard IDE register set directly
> rather than making BIOS calls...
Yes, with Linux, rather nice for removing any BIOS vagueries. Also nice
that I don't have to reflash this BIOS hence saving time and hassle.
>>However, on another system that I flashed the BIOS to support >136GB,
>>Win2k trashed the partitions.
>
> Please provide some more information about what it did precisely.
> It might have installed a Windows Logical Disk Manager Dynamic Disk
> <whatever term they use for the global table> configuration which your
> Linux did not recognise. See http://linux-ntfs.sf.net/ldm/.
The story
=========
The disk had been in use for 'some long time' by Win2k as just one big
partition. The user was using it for data backup. After eventually
having added about 40GB-ish of data, the next time the machine was
rebooted, a disk check reported 'lots of bad files'...
On checking further, Win2k couldn't see the full 200GB. There was a
driver floppy for supporting the disk which hadn't been installed...
Installed the driver into Win2k and on rebooting got a never ending list
of bad clusters. Considered that disk's data unuseable. Next, backed up
his current work data. Then, to back up his Win2k system and misc data,
used Linux and dd to copy across his C: drive (two partitions - C: and
F:, dd if=/dev/hda of=/dev/hdh bs=1M), but the copy took a lot longer
than expected. Finally used ^c to stop. All the data looked to be
there... Used a disk utility to check the hard disk and all checks
passed ok. Rebooted into Win2k and in the usual rush, all was forgotten
for a week or few for that disk to be looked at again.
The system got rebooted and got into a strange mess. Looking in from
Linux, there was about 100MB of data from another disk unexpectedly
added to the 200GB drive's primary partition and a corrupt system
registry! The registry on the working C: was also corrupt...
Made for a very good test of the backups! Linux retrieved that day's
data and email for the win partitions.
I'm guessing that the system booted up from the wrong 'C:' and got badly
confused. Don't know the full detail of what the user did or tried to fix!
> What commands did you use and were you aware that this can have
> complications when moving from one device to another?
The Fix
=======
dd if=/dev/hda bs=1M | dd bs=1M | dd bs=1M | dd of=/dev/hdh bs=1M
(The idea of the multiple buffering is to let the slowest device stream.
CPU usage is about 60%.)
And yes, hence the questions and experimenting.
All a question of how exactly the partition tables are chained wrt the
superblock and logical partions:
Relative or absolute addressing?
Block addressing or something specific to each drive?
(LBA I'm hoping will be a lot more consistent between different drive
types than if CHS was still being used...)
And how the LBA32 to LBA48 translation occurs...
>>So still wondering whether dd is completely immune from disk drive
>>geometries when using /dev/hdg for example...
>
> Utilities go through the block device layer in the kernel and so the
> limitiations are only those exposed in the IDE low level Linux support.
So the disk is seen as one long string of addressable blocks (LBA) of
n-bytes per block? The lower level stuff then physically arranges them
on the disk in sequence?
>>(eg: the source hda1 will be copied over but its link to the next
>>partion will now be wrong for the destination disk...? Does this work ok
>>for primary partions but not logical partitions??)
>
> Try it and be prepared to go in to the advanced mode in fdisk to fix any
> breakage in the partition tables. Try not doing this on the system disk.
I'm expecting to have to do something rather hairy...
Very pleased that I put Linux on the system! Might even be moving over
to using it full time for the server...
Comments on all welcome.
Martin
--
----------------
Martin Lomas
martin@ml1.co.uk
----------------