From owner-freebsd-questions@freebsd.org Sun Dec 1 07:28:29 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79A2A1C2035 for ; Sun, 1 Dec 2019 07:28:29 +0000 (UTC) (envelope-from bennett@sdf.org) Received: from mx.sdf.org (mx.sdf.org [205.166.94.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx.sdf.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47Qfx829cQz4Xhx for ; Sun, 1 Dec 2019 07:28:27 +0000 (UTC) (envelope-from bennett@sdf.org) Received: from sdf.org (IDENT:bennett@otaku.sdf.org [205.166.94.8]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id xB17SQbn026571 (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits) verified NO); Sun, 1 Dec 2019 07:28:26 GMT Received: (from bennett@localhost) by sdf.org (8.15.2/8.12.8/Submit) id xB17SQkC019214; Sun, 1 Dec 2019 01:28:26 -0600 (CST) From: Scott Bennett Message-Id: <201912010728.xB17SQkC019214@sdf.org> Date: Sun, 01 Dec 2019 01:28:26 -0600 To: tomek@cedro.info Subject: Re: pendrive clone impossible ? Cc: FreeBSD Questions Mailing List User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 47Qfx829cQz4Xhx X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of bennett@sdf.org has no SPF policy when checking 205.166.94.20) smtp.mailfrom=bennett@sdf.org X-Spamd-Result: default: False [1.98 / 15.00]; ARC_NA(0.00)[]; FAKE_REPLY(1.00)[]; NEURAL_HAM_MEDIUM(-0.62)[-0.622,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; IP_SCORE(-0.32)[ip: (-1.00), ipnet: 205.166.94.0/24(-0.50), asn: 14361(-0.03), country: US(-0.05)]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[sdf.org]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[20.94.166.205.list.dnswl.org : 127.0.10.0]; NEURAL_SPAM_LONG(0.02)[0.015,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:14361, ipnet:205.166.94.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Dec 2019 07:28:29 -0000 On Sat, 30 Nov 2019 22:08:21 +0100 Tomasz CEDRO wrote: I will skip past all the irrelevant blather that was posted in response by those who, like you, ignored the error message. I am also trimming this response to just freebsd-questions because it is not a freebsd-usb issue and because you should be discouraged from posting to multiple lists without a good reason for doing so. >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: [much irrelevant stuff deleted --SB] > >Does GEOM in any way prevents me from using disk that has corrupt MBR? Yes, most likely. >Why I cannot write a MBR from a file but I can from a md0? > >Any hints welcome :-) See the last line of your messages below. >Tomek > ># gpart backup da0 | gpart restore -F da1 >gpart: size '17575936': Invalid argument > >ugen0.7: at usbus0 >umass0 on uhub0 >umass0: 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: 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 > >ugen0.8: at usbus0 >umass1 on uhub0 >umass1: 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: 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 >GEOM_PART: integrity check failed (da1, MBR) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ There is your hint, courtesy of ||||||||| |||||||||||||||||||||| FreeBSD's GEOM_PART kernel class. > >FreeBSD 0xCFMX4 12.1-RELEASE-p1 FreeBSD 12.1-RELEASE-p1 GENERIC amd64 > I'm on 11.3-STABLE, so I don't have a 12.1 man page in front of me, but the information is most likely identical. See the "SYSCTL VARIABLES" section of "man 8 gpart", specifically, kern.geom.part.check_integrity and kern.geom.part.mbr.enforce_chs. In my /boot/loader.conf I have kern.geom.part.check_integrity="0" kern.geom.part.mbr.enforce_chs=0 to avoid such problems. Apparently, by default the GEOM PART class often dislikes the MBR alignment used by fdisk(8) and however Windows does it. You *might* only need the second line of the above; I don't remember why I needed both, although the volume size mismatch may require the "check_integrity" line. I faintly recall only needing the latter for quite a while, but eventually had to add the other line, possibly because of some change when moving from one major release to the next. In any case, those should keep your flash drive from being rejected. Scott Bennett, Comm. ASMELG, CFIAG ********************************************************************** * Internet: bennett at sdf.org *xor* bennett at freeshell.org * *--------------------------------------------------------------------* * "A well regulated and disciplined militia, is at all times a good * * objection to the introduction of that bane of all free governments * * -- a standing army." * * -- Gov. John Hancock, New York Journal, 28 January 1790 * **********************************************************************