Link to home
Start Free TrialLog in
Avatar of viki2000
viki2000Flag for Germany

asked on

Cloning a part of HDD MIPS Linux

My question is related with the next one:
https://www.experts-exchange.com/questions/28910923/dd-vs-ddrescue.html

Gheist said “there is small difference -MBR is first disk block of 512 bytes, partition start at 63rd block or 2048th block, that space in between was once used by bootloaders like lilo”

Why to start at 63rd or 2048th? What makes/causes to start at 63rd or at 2048th? When do we know that is at 63rd or 2048th?

When I use the command “fdisk -l” I got:
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63     2008118     1004028   83  Linux
/dev/sdb2         2281230     6297477     2008124   83  Linux
/dev/sdb3         6297480   234436543   114069532   83  Linux

That shows that starts at 63rd as mentioned above by gheist.
If I know that the 1st partition starts at 63 and ends at 2008118, I know for sure is /dev/sdb1, I know the number of blocks 1004028, then we can calculate:
2008118 – 63 = 2008055
1K = 1024 bytes
512 bytes = ½ K
1 Sector = 512 byte = ½ K
2008055/2 = 1004027.5 K
1MB=1024KB
1004028 Blocks/1024K = 980.49609375 MB
And this is what I see in Windows as size for partition1, around 980MB.

Now, if I know that partition1 starts exactly ta 63 and ends at 2008118 and I know that from beginning of the disk up to 63 is MBR + eventually a boot loader, so if everything is known exactly, then my question is:
- What uncertainty stops me to clone only from beginning of the disk up to 2008188 and obtain an image file smaller than 1GB and work only with that?
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of viki2000

ASKER

I just bought the 2nd similar receiver, a used one with 32€.
I hope will have no bad sectors, at least at the beginning of the disk and there where is the missing info/file from first one.
I will try "dd rescue" cloning on a 3rd PATA as destination. In this way I hope what is missing from 1st source HDD maybe is on the 2nd source HDD.
The receiver will be sent Friday and hopefully I will get it next week. Then at the end of the following week I hopefully will have some time to try the cloning.
I will not close the question until I try the cloning procedure.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your input.
If you watched my struggle, then you should know I asked few more questions related with the same subject, in this order:
1)      https://www.experts-exchange.com/questions/28901979/Repair-special-Boot.html
2)      https://www.experts-exchange.com/questions/28903401/Linux-HDD-partitions-and-boot-recovery.html
3)      https://www.experts-exchange.com/questions/28905320/Identify-Linux-loader.html
4)      https://www.experts-exchange.com/questions/28910923/dd-vs-ddrescue.html
5)      https://www.experts-exchange.com/questions/28917199/HDD-IDE-vs-SATA-USB.html
6)      The present question
One thing I have learned: this is a special application with a special Linux and I do not mess around anymore with Windows cloning programs. I burnt my fingers once and now I have to pay for it.

I do not have any 57GB partition.
My 3rd partition is 109GB as seen here:
http://filedb.experts-exchange.com/incoming/2015/12_w52/1059164/Partitions_Active.jpg
http://filedb.experts-exchange.com/incoming/2015/12_w52/1059162/Partitions_Windows.jpg
Linux is 100% on the first partition, that one with 980MB, because I have access to its files.
Actually I know what contains each partition. The 2nd one is just with “lost and found”, some settings, shows files and the 3rd one contains the video recordings.
Here is shown the contents of the portions as pictures. I used Active@ Partition Recovery
https://drive.google.com/open?id=0BwXmKaSw75eKandmNE5neE9EMXM
I made once one stupid mistake and was enough: cloning with Acronis.
From now on, for this HDD, if I get another one, I will play only with Linux:. "dd", "dd rescue", CloneZilla.
In this question, you list /dev/sdb3 as having a total of 114069532 sectors which is about 57 GB.  In the image you just posted, you say it has 228139064 which is 109GB!  Something is hinky here or there are two different drives in question.
Several of the "image backup" programs skip what they think is unused space to speed up the process and/or shrink the backup which results in a bad clone or one which is defective in many possible ways.  That is why I mentioned choosing the physical devices with RawCopy.  WinHex probably offers a similar feature; but, having started doing data recovery in the 1970's, the only option then was a physical copy of the media/device.  Having been handed numerous "forensic images" that had skipped the unused (read everything which had been erased) areas of the device, I have learned to always created sector by sector copies.
To answer one of your earliest questions, Gheist too was in error.  The change from 63 sectors (which was originally 17 and has been several other numbers) to 2048 was due to the advent of SSD's and their internal structure. Almost every SSD is organized into 4KB chunks (8 sectors) and, if the partition starts in a nonaligned location, the SSD has to do a read. modify, write operation every time a block is changed (read all of block 1, change the last 1024 bytes, write it back, read all of block 2, change the first 3072 bytes, write it back) because of the misalignment.  Sector 2048 (1MB) happens to line up either way.
Hands on, I could tell you exactly how Acronis screwed up; but, short of being able to inspect the original and the copy, I can't.
Thank you for clarifying the 63 sectors vs. 2048.
Now I will clarify your confusion with 57GB.
If you look in the main question you see how I calculated the size of partition 1.
Then for the 3rd partition you do like this:
114069532/(1024*1024) = 108.78GB

And regarding Acronis, at the time of cloning, I did not know that is not a true cloning. I used Acronis True Image 2015 and the name made me think is a true bit by bit copy.
Looking at the next table:
https://en.wikipedia.org/wiki/Comparison_of_disk_cloning_software
we see at file by file that EXT3 is not included, which is my HDD, but anyway I wanted sector by sector and did not work properly.
What I never understood is: why and how come is possible that Acronis changed something in my source disk if they say it is working also sector by sector?
Viki,
With extremely rare exceptions (some old scsi devices used 256 byte sectors), every hard disk drive since the 1970's has used 512 byte sectors and every partition table has always listed the number of sectors. So, its 114069532*512/1024 to derive the size of the partition you listed which is 57,034GB.
"2008118 – 63 = 2008055
 1K = 1024 bytes
 512 bytes = ½ K
 1 Sector = 512 byte = ½ K
 2008055/2 = 1004027.5 K
 1MB=1024KB
 1004028 Blocks/1024K = 980.49609375 MB"
Floppy disks have almost all been 1024 byte sectors and some, very new, "advance format drives" are 4096.
Bear in mind that I designed, built, and then wrote the assembly language drivers for an S-100 hard disk controller in 1981.  My company regularly created custom EPROM's to replace the BIOS in IBM's and Compaq's which would allow us to set the drive type as hard disk drives changed their geometry (and in those days there was no user defined or auto).  I also keep one PC in my shop expressly because it will let me manually enter the heads, cylinders, and sectors when I need to get the data and the BIOS gets it wrong.
Did you know there was an older LBA translation of 15 which resulted in 240 heads rather than the standard 255?
Read this: http://thestarman.pcministry.com/asm/mbr/PartTables.htm
I do not pretend 1 second or 1 bit that I know more than you do, based on your mentioned experience, but my calculation explains what Linux command “fdisk -l” lists and matches with other software used under Windows and Linux.

Remember that my HDDD is PATA (IDE) Seagate 120GB ST3120025ACE.
http://www.seagate.com/staticfiles/support/disc/manuals/ata/100271705f.pdf

Keep in mind that is a special application for embedded electronics, a Panasonic satellite receiver with recording capabilities and OS is Linux MIPS.
The way how the byes are allocated per sectors was not important for me up to now, but we can find out later for your curiosity.

And by the way, the number 114069532 represents Blocks. How do we know that 1 Block is not in fact 2 Sectors ? , because 1 Sector is 512 bytes. Then everyone would be happy with the calculation.
Because my bold font calculation above is wrong with "K" letter at the end.
Should be written then  2008055 Sectors / 2 = 1004027.5 Blocks
The sector size is hard coded in the firmware on the drive and that drive is 512 bytes per sector with only one way to change it and that is to rewrite the firmware in the drive.
What fdisk -L is showing you is only part of what is contained in the partition table entry.  The entry also has the beginning and ending head, cylinder, and sector of the partition.  It is also the total number of sectors not the total number of blocks.  After the operating system begins to load, it starts to address things as blocks (which is now almost universally 4096 characters or 8 sectors); but, the low level handler for the storage device still translates it into a request for a specific head, cylinder, and sector.
Well, I stand corrected and learned my new thing for the day; Linux's fdisk output means blocks and that is, most probably, why Acronis screwed up!  There is a good chance that; because every DOS based O/S would have report the number of sectors, Acronis only copied PART (half) of the partition.
FYI; though, this won't be true with older versions ( I was SCO Unix authorized in 1993 ) and may not be universal.
I have only one problem with the explanation above about Acronis.
A wrong interpretation of the sectors vs. blocks or any other wrong interpretation from Acronis side would imply a wrong clone, meaning the destination disk is wrong cloned/copied.
Acronis copied the entire disk 120GB. I know for sure because I can check the destination disk with its content and partition 3 is 109GB full of files with different recordings and they are the same as in the source disk. Acronis just met Linux EXT3 and did not like it and messed up the booting, the loader, the beginning of the disk.
My understating problem is how and why the source disk was changed by Acronis?

I asked that question also on Acronis forum and I got no answer.
I asked next:
"
Before I clone it on another HDD I got next warning message:
https://drive.google.com/open?id=0BwXmKaSw75eKLV83VnhITFdiMUE
Does that warning refer only to the destination disk? Or refers also to the source disk?
In other words, when a clone HDD function is performed, does Acronis any changes also on the source disk?
The problem is that my source disk worked prior clone function and does not work anymore after that. The files are there, but is not proper initialized anymore.

"
I would have to say that Acronis was warning you about the source disk which would then also be on the clone after the copy operation.  I've already said I don't use Acronis; but, I would have cancelled at that message.  With RawCopy, for example, the choice for the source has two sections; one for the partitions (logical) and one for the physical drive which is what I have always used.
The utilities I use and the choices I make within them will only do direct physical copies as any alteration destroys its forensic validity.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry to hear about your illness. You should use more ginger, onion and garlic. Garlic is one of the strongest natural antibiotic.

Very informative your post.
My 2nd bought receiver was paid 2 weeks ago, but not yet received. It is a private deal. Maybe next week.
Last week I received the 2nd receiver. I had not time to open the box and try if it is working.
If it will work, then I will try ddrescue to copy 1st to a cloned image.
If I go in troubles, I will come back with a new question and I will suggest it here to as a link.
Thank you for you thought and advice.