I’m trying to use dd to clone my Windows partitions from linux. I want to get rid of Windows and put it on another harddrive. Do not want to delete Windows since it is a OEM version.
Anyway the two first partitions on my harddrive belongs to Windows. I have connected a secondary harddrive to linux and executed dd.
username@localhost:~> sudo dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=notrunc,noerror
106422+1 records in
106422+1 records out
435907584 bytes (436 MB) copied, 0,958252 s, 455 MB/s
username@localhost:~> sudo dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=notrunc,noerror
dd: writing «/dev/sdb2»: No space left on device
894515+0 records in
894514+0 records out
3663929344 bytes (3,7 GB) copied, 8,3846 s, 437 MB/s
The first partition seems to go OK, but for the second it doesn’t. Drive sdb is twice the size of sba1+sda2.
I have even tried to create two partition sdb1 and sdb2 before running dd, but with same result.
Some additional information. As you can see the drive sda has my linux partition along with the Windows partition.
I have created /dev/sdb1 and /dev/sdb2 on the drive /dev/sdb with adequate disk space for the cloning.
However /dev/sda1 begins a 63, while my /dev/sdb1 begins at 2048.
Disk /dev/sda: 480.1 GB, 480103981056 bytes
255 heads, 63 sectors/track, 58369 cylinders, total 937703088 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdac9de00
Device Boot Start End Blocks Id System
/dev/sda1 63 851444 425691 7 HPFS/NTFS/exFAT
/dev/sda2 851445 308118208 153633382 7 HPFS/NTFS/exFAT
/dev/sda3 * 308119552 937701375 314790912 f W95 Ext’d (LBA)
/dev/sda5 308121600 312336383 2107392 82 Linux swap / Solaris
/dev/sda6 312338432 442365951 65013760 83 Linux
/dev/sda7 442368000 937682943 247657472 83 Linux
Disk /dev/sdb: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9a09bb3d
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1124351 561152 7 HPFS/NTFS/exFAT
/dev/sdb2 1124352 625141759 312008704 7 HPFS/NTFS/exFAT
Useless, the layout is gone and can not be reconstructed by putting CODE tags later. You should copy direct from your terminal in between the tags. Which you managed to do in your last post
I tried to assess this using your first two posts, but either the clue is not there, or I still am misreading because of the failing columns. Also I see a blank line somewhere where it shouldn’t be.
Now it seems that it is of not much use to ask you to show in one unitnerrupted sweep the fdisk -l and the two dd commands because you already changed the situation by using all sorts of other tools. So I am completely lost on what your present situation is.
On 2013-02-15 15:26, DJViking wrote:
>
> I’m trying to use dd to clone my Windows partitions from linux. I want
> to get rid of Windows and put it on another harddrive. Do not want to
> delete Windows since it is a OEM version.
I would attempt a blunt dd of the entire disk. It will fail at some
point because of the different size, at which point you have to remove
the extra partition entries beyond sdb2.
Why your dd of sda2 fails I can not see. It should work, I believe.
–
Cheers / Saludos,
Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)
>
> I tried to assess this using your first two posts, but either the clue
> is not there, or I still am misreading because of the failing columns.
> Also I see a blank line somewhere where it shouldn’t be.
>
> Now it seems that it is of not much use to ask you to show in one
> unitnerrupted sweep the fdisk -l and the two dd commands because you
> already changed the situation by using all sorts of other tools. So I am
> completely lost on what your present situation is.
>
>
I may be wrong about this but was your b drive partitioned in any way. If I
recall correctly I had much the same problem. If your b drive had only one
partition that occupied the drive dd will copy your partition from a to be
but will not truncate the b drive partition to the size of the partition on
the a drive therefore it doesn’t find any free space on the b drive. You
might try dd if=/dev/sda of=/dev/sdb instead of trying each partition
separately.
What I read from his (distorted) fdisk listing in post #2 is that sdb has two partitions that are both bigger then the partitions with the same sequence number on sda. I might misread as I said earlier, but I do not understand how you see that there are no parttitions at all on sdb. The more so because the dd of sda1 to sdb1 is successfully, thus there must be at least one partition.
Also when there isn’t a partition sdb2 at all there would be an error message from dd that /dev/sdb2 doesnot exist, which is not the case. tehre is even a lot of blocks copied.
Also dd does not “truncate” partitions. dd simply copies blocks from the input file to output file. It does not even have any real knowledge about partitions. When there are no more blocks to copy (End-of-file on input from the kernel) it stops and does not do anything whether there are more blocks available out the output file or not. When, during writing, it gets an End-of file from the kernel it then says: No space left.
Will try cloning the entrie sda drive on monday when I get back to work. I hate unfinished work before weekend.
Anyway when it will fail due to lack of space will not the sdb drive have a incomplete partition table?
Since linux had problems creating the sdb drive I could perhaps try create the sdb1 and sdb2 drive formatted in NTFS within Windows before I try to clone it.
The reason fdisk -l showed 2 partitions on /dev/sdb is because I created them before I preceded with the cloning with the same size as the /dev/sda partitions I was trying to clone. As stated I have tried the cloning with or without partitions on /dev/sdb. That time I tried without partitions and the first clone worked without problems there was none on the receiving end.
Trying to copy the whole disk and see how it does is not a bad advice given above. But be prepared for the same error message because disk sdb is smaller then sda.
It will have exactly the same partition table. You copied is with dd (do you have any idea what dd is supposed to do?). That will mean that sdb is not realy usable before you used e.g. fdisk to remove the not need partitions db3 and upwards (as Carlos clearly explained in his post).
That is nonsense.
That is clear to me. But they are NOT of the same size (both are a bit larger then need I guess). And what you planned to do is correct:
. create on another disk two partitions with the same size (or larger, but same size is best);
. dd both partitions.
But I am a bit at the end as long as you do not post in one sweep the complete terminal session using
I want a complete, unabridged, not thinkered with and readable listing of what happens. As Carlos once said: we are non-=believers, we want computer facts. This is the last time I ask.
Just a thought…
Depends on what your personal objective is -
Although I’m sure anyone following this thread woudl be interested why you’re encountering difficulties, if your objective is to just get the job done instead of how it’s done, there are many tools out there which will clone/copy the partitions and content for you (eg Gparted, Clonezilla, more) which are easy to use and might even do a theoretically better job (eg checksum and other verifications) than dd.
But, if you really want to learn how dd works, it’d certainly be useful to understand why you’re seeing your problem and overcome it.
On 2013-02-15 20:56, DJViking wrote:
>
> Will try cloning the entrie sda drive on monday when I get back to work.
> I hate unfinished work before weekend.
> Anyway when it will fail due to lack of space will not the sdb drive
> have a incomplete partition table?
No, the table will be complete, the table is at the start of the disk.
Do you really know what ‘dd’ does?
Also, the contents of the first and second partitions will be correct
and the same. The content beyond that will be truncated at some point,
but we don’t care about that. You will have to use a partitioner and
delete partition 3, 4, etc.
It is also possible to concoct a dd command that copies sda into sdb
stopping at a point just beyond sda2 and save time, but I feel lazy to
try it just now.
> Since linux had problems creating the sdb drive I could perhaps try
> create the sdb1 and sdb2 drive formatted in NTFS within Windows before I
> try to clone it.
Irrelevant, format is destroyed. Again, do you really know what ‘dd’ does?
Also, please repeat your original session and post the results inside
code tags. What you posted is contaminated and distorted, specially for
those readers using hhtp and not nntp like me.
–
Cheers / Saludos,
Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)
Will post the complete output from fdisk and dd on monday, unless I get in the mood to go back to work tomorrow.
Anyway, used dd and dd_rescue before, but only in the capacity to put OpenSuse DVD ISO on a USB stick. Knowing just that it copies data from one drive/file to another, perhaps I’ll read up on dd this weekend.
On 2013-02-15 22:26, DJViking wrote:
>
> Will post the complete output from fdisk and dd on monday, unless I get
> in the mood to go back to work tomorrow.
>
> Anyway, used dd and dd_rescue before, but only in the capacity to put
> OpenSuse DVD ISO on a USB stick. Knowing just that it copies data from
> one drive/file to another, perhaps I’ll read up on dd this weekend.
It is really simple, it works “dumb”. It just copies bytes one by one
from input file to output file. If the files are “disks”, it copies from
the first byte of the disk to the last, be it boot sector, partition,
empty useless space… it copies everything without thinking, to the
destination. Thus:
dd if=/dev/sda of=/dev/sdb
clones the disks exactly equal byte by byte. If the destination is
smaller and will not fit, it will simply copy till the byte that fills
the destination.
It does not clever things like resizing partitions, etc.
And that makes it a very powerful tool.
–
Cheers / Saludos,
Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)
On Fri, 15 Feb 2013 14:26:01 +0000, DJViking wrote:
> I’m trying to use dd to clone my Windows partitions from linux. I want
> to get rid of Windows and put it on another harddrive. Do not want to
> delete Windows since it is a OEM version.
>
> Anyway the two first partitions on my harddrive belongs to Windows. I
> have connected a secondary harddrive to linux and executed dd.
I would use something like Clonezilla (indeed, I have) rather than dd.
dd will give you a sector-by-sector image, which can be useful, but is
essentially an “all or nothing” restore option.
If you needed to restore the OEM installation for some reason, you’d be
wiping out the entire hard drive. Using a better tool will make for a
smaller image and will let you be more selective in your restore if you
need to be.
I can now confirm that /dev/sda1 has been successfully cloned to /dev/sdb1. Although the size of /dev/sdb1 is a little more than /dev/sda1, that should not be any problem.
Output from fdisk -l
Disk /dev/sda: 480.1 GB, 480103981056 bytes
255 heads, 63 sectors/track, 58369 cylinders, total 937703088 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdac9de00
Device Boot Start End Blocks Id System
/dev/sda1 63 851444 425691 7 HPFS/NTFS/exFAT
/dev/sda2 851445 308118208 153633382 7 HPFS/NTFS/exFAT
/dev/sda3 * 308119552 937701375 314790912 f W95 Ext'd (LBA)
/dev/sda5 308121600 312336383 2107392 82 Linux swap / Solaris
/dev/sda6 312338432 442365951 65013760 83 Linux
/dev/sda7 442368000 937682943 247657472 83 Linux
Disk /dev/sdb: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b2459
Device Boot Start End Blocks Id System
/dev/sdb1 63 867509 433723+ 7 HPFS/NTFS/exFAT
/dev/sdb2 867510 625137344 312134917+ 7 HPFS/NTFS/exFAT
Output from dd
username@pluto:~> sudo dd if=/dev/sda2 of=/dev/sdb2 bs=2M conv=notrunc,noerror
dd: writing «/dev/sdb2»: No space left on device
1942+0 records in
1941+0 records out
4072189952 bytes (4,1 GB) copied, 10,7451 s, 379 MB/s
Last week when I ran the dd command, it would only copy 3.7GB and now it copied 4.1GB.
Output from dd without any extra options
username@pluto:~> sudo dd if=/dev/sda2 of=/dev/sdb2
dd: writing to «/dev/sdb2»: No space left on device
7953545+0 records in
7953544+0 records out
4072214528 bytes (4,1 GB) copied, 10,9205 s, 373 MB/s
To recap: you have two partitions on sdb that are both a little bit larger then needed.
Copying sda1 to sdb1 allways is flawless.
Copying sda2 to sdb2 stops every time at a different point with apparently dd getting and End-of-File indication from the kernel. Now this is strange (as it was from the beginning and you being baffledd about it is no wonder). I would interprete it as a hardware problem when it would have been on the same spot every time. But it isn’t. It may still be a hardware problem, but more difficult to pin down. As every error that comes and goes or, like here, jumps around is very difficult to pin down.
I think we could try several approaches here, but I am not sure which one will lead us along the shortest way to a solution.
run a disk check program (preferable the manufacturer’s one) on the disk to see if it is broken.
repartition the diks in a way that you have only one parttiotion (that will then be sdb1) large enough to accomodate sda2 and then dd sda2 to sdb1 to see if we get the error again. I am not sure if it will brings us much as the “new” sdb1 will partly overlap with the “old” sdb2 and thus the error could be in the overlap. But maybe we can then prove that it is possible to do the copy (albeith to another place).
that brings another test to my mind. We could copy sda2 into the dustbin to prove that the problem is not on the input side:
dd if=/dev/sda2 of=/dev/null
Other suggestions from others following this thread are of course very welcome.
EDIT: I am also wondering why dd every time after the error message and after telling it copied “only” so many records says:
The content of /dev/sdb2 was corrupt. I tried to mount it but unsuccessful.
I am now running the following command
sudo dd if=/dev/sda of=/dev/sdb
It has been running for 20 minutes and still running without any errors so far. Overall size of /dev/sda is much larger than /dev/sdb, but not all space is used on /dev/sda. The totalt amount of used space on /dev/sda is less than the free space on /dev/sdb, so perhaps dd will succeed without any insufficient space error (assuming my assumption about dd that it only copies used data).
Edit: I wanted to run that with dd_rescue instead of dd. I do not like the lack of verbosity/progress information with dd. However dd_rescue returned an error that it could not find /dev/sda, but that file clearly did exist.