pendrive clone impossible ?
freebsd at edvax.de
Sat Nov 30 22:49:11 UTC 2019
On Sat, 30 Nov 2019 23:28:04 +0100, Tomasz CEDRO wrote:
> It looks like either GEOM is hiding something from application/me, or
> pendrive itself is preventing MBR to be modified, or some sort of
That is possible (but unlikely), and there's another (equally
unlikely) possibility that your computer has some "boot sector
virus protection" activated in the BIOS which prevents writes
to block 0 of a device...
> I guess the first is more probable because DD'ing from /dev/md0,
> /dev/zero, /dev/random devices always works, while DD'ing from da0.mbr
> file never works. If pendrive was defending itself none of them would
> be possible, right?
Yes, that's at least my impression. Can you provide an error
message of dd, or does it say "blocks copied", but no MBR data
actually arrived on the USB stick?
> The Source pendrive was MBR. This is why I did /dev/zero -> /dev/da1
> just to make sure there is no GPT of any sort on the Target pendrive,
> nor MBR, also I could see where write was skipped.
Okay, so you can _confirm_ that there is MBR (partition table
with "DOS primary partitions") in it - good. In that case,
using gpart or fdisk to read the MBR should work definitely
for the source stick - and should also work for the target stick
after the MBR has been written correctly.
> This is the first time ever dd if=/dev/da0 of=/dev/da1 did NOT copy
> the entire drive (the da1 attached GEOM noted inegrity checked MBR was
> left blank the rest seems to be there).
If you use something like
# dd if=/dev/da0 of=/dev/da1 bs=1M
i. e., a block size typical for such media, does it make any
difference? Not copying 512 bytes is one thing, but not copying
a much larger block - 1 MB - with the 512 bytes at its beginning,
that would be _really_ strange.
Maybe - even though I cannot imagine why - the target stick does
not accept being written smaller amounts of data, which of course
is nonsense, as you said that 512 bytes of zeroes or random data
_will_ be written.
> DD reported NO ERROR.. in fact
> I got a standard summary on transferred bytes as operation was
> completed successfully. I did not count all bytes transferred because
> I never had to before. Is the OS hiding something from me? And from
> DD? Is Penrdive messing with the GEOM / OS?
If you dd the 1st 512 bytes out of the source and the target and
compare them, are they identical? They _should_, according to what
# dd if=/dev/da0 of=/dev/da1 bs=512 count=1
# dd if=/dev/da0 of=da0.mbr bs=512 count=1
# dd if=/dev/da1 of=da1.mbr bs=512 count=1
# diff da0.mbr da1.mbr
You can then repeat this test with a bigger block:
# dd if=/dev/da0 of=/dev/da1 bs=1m count=1
# dd if=/dev/da0 of=da0.1mb bs=1m count=1
# dd if=/dev/da1 of=da1.1mb bs=1m count=1
# diff da0.1mb da1.1mb
In any case, there should be _no_ difference (no matter if the
partitions themselves are incomplete and unreadable on the target
> Because I need to finish quickly, I have used GPART to create and add
> partitions by hand and I am DD'ing partition by partition. So far so
In case they are UFS partitions, you could newfs the target
partition, and then use dump | restore - I don't know if this
is faster, but it would work as well.
> The Target pendrive is Kingston 128GB DTSE9 G2 USB3.0. Be careful with
> that fellow!
> Below is a Kingston's response cut-and-paste found on a forum where
> another folk tried to install bootable system on a 32GB DTSE9 G2 ;-)
> The first thing to point out is that a USB drive needs to be set as a
> fixed drive which requires a tweak in the firmware, commonly refereed
> to as "flipping the RMB". Not every firmware is suitable for such an
> operation and since we use different flash controller providers to
> meet the supply and demand for our products, we cannot check the
> suitability of every firmware to be altered to accomodate booting from
> Furthermore a standard USB drive is designed for sequential read and
> writes, rather than random read and write speeds.
> Booting from the USB will be very slow and will be a detriment to the
> product, affectively its longevity.
> Therefore we cannot guarantee the longevity and reliability of the
> drive within the warranty period, and could offer no further support
> in case of a drive failure.
> This is the reason why we at Kingston do not support the bootability
> of our commodity USB products.
> If you purchased the DTSE9G2/32GB to be used specifically for this
> purpose, we can only recommend that you return it to your supplier for
> a refund and we apologise for any inconvenience this may cause.
> WELL, KINGSTON LOOKS LIKE A LOTTERY AND I FEEL LIKE A WINNER! ;-)
Next idea is for them to put some "AI/ML anti virus malware" into
the firmware of the USB stick that accepts data, returns "written"
to the writer, but doesn't actually write anything to its storage,
because... we need to protect the users! :-)
If it stops you to do stupid things, it also stops you to do clever
things, and most things we do in UNIX world are usually not invented
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions