Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Nov 2019 22:08:21 +0100
From:      Tomasz CEDRO <tomek@cedro.info>
To:        FreeBSD Questions Mailing List <freebsd-questions@freebsd.org>,  "freebsd-usb@FreeBSD.org" <freebsd-usb@freebsd.org>
Subject:   pendrive clone impossible ?
Message-ID:  <CAFYkXjkHobPfNwCL3ssL98TgUjE=jvojXACH%2BiR0EV-tzK-pxA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hello world :-)

I have to clone a pendrive, the same one to another almost the same
(number of sectors differs a bit). The problem is that DD does not
seem to do the job. It always worked for me.

Also I am not really able to clone the MBR:
1. dd if=/dev/da0 of=/dev/da1 bs=512 count=1 does not copy anything.
2. dd if=/dev/zero of=/dev/da1 bs=512 count=1 zeroes the mbr.
3. dd if=/dev/random of=/dev/da1 bs=512 count=1 randoms the mbr.
4. dd if=/dev/da0 of=da0.mbt bs=512 count1; dd if=da0.mbr bc=512
count=1 does NOT copy the mbr.
5. mdconfig -a -tvnode da0.mbr; dd if=/dev/md0 of=/dev/da1 bc=512
count=1 does put the data into mbr, but still da1 seems to have no
partitions!!!

In such Black Magic situations I usually put /dev/zero on a target
disk, just to make sure MBR and GPT are not messed/mixed up, then
re-tried and things worked. Not this time.

While size of the drives differs a bit, the last partition contains
FreeBSD LiveCD image and is much smaller than the partition so it can
be truncated with no problem because there are zeros after.

Does GEOM in any way prevents me from using disk that has corrupt MBR?
Why I cannot write a MBR from a file but I can from a md0?

Any hints welcome :-)
Tomek

# gpart backup da0 | gpart restore -F da1
gpart: size '17575936': Invalid argument

ugen0.7: <Kingston DataTraveler 3.0> at usbus0
umass0 on uhub0
umass0: <Kingston DataTraveler 3.0, class 0/0, rev 3.20/1.10, addr 6> on usbus0
umass0:  SCSI over Bulk-Only; quirks = 0x8100
umass0:2:0: Attached to scbus2
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
da0: Serial Number BLAHBLAH
da0: 400.000MB/s transfers
da0: 118368MB (242417664 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>

ugen0.8: <Kingston DataTraveler 3.0> at usbus0
umass1 on uhub0
umass1: <Kingston DataTraveler 3.0, class 0/0, rev 3.20/1.10, addr 7> on usbus0
umass1:  SCSI over Bulk-Only; quirks = 0x8100
umass1:3:1: Attached to scbus3
da1 at umass-sim1 bus 1 scbus3 target 0 lun 0
da1: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
da1: Serial Number BLAHBLAH
da1: 400.000MB/s transfers
da1: 118272MB (242221056 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>
GEOM_PART: integrity check failed (da1, MBR)

FreeBSD 0xCFMX4 12.1-RELEASE-p1 FreeBSD 12.1-RELEASE-p1 GENERIC  amd64

--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFYkXjkHobPfNwCL3ssL98TgUjE=jvojXACH%2BiR0EV-tzK-pxA>