From owner-freebsd-usb@freebsd.org Sun Dec 1 16:45:35 2019 Return-Path: Delivered-To: freebsd-usb@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 2C0721B0BF8 for ; Sun, 1 Dec 2019 16:45:35 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47QvHx11Hgz40h8 for ; Sun, 1 Dec 2019 16:45:32 +0000 (UTC) (envelope-from tomek@cedro.info) Received: by mail-oi1-x244.google.com with SMTP id l20so30221677oie.10 for ; Sun, 01 Dec 2019 08:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cedro.info; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vvnm+YwnOcSsu7Jrhb7VP1vqRW2h+tAKlAI7YxRxit8=; b=gTi/7w5hFd5OmCP6KX2moEMz/Xekv0/YKQtv5r5va8EZQpkK2sZ2QuTGJYaumUVcq3 B7k4Dk8uy2GOn/Bp8olZMkxMtQe5Au3gVi5aGjAHIs74Dw24WQu+GsaiLPQyN8Wab8Yd GB0Sz4gPQ+xWQ7HnfhITC50lTXxhpe8rcswMdPCNgbktOoXEVkAORCiVGwoTsvROr9nb lmoPe1fOnLRWrcxXvllA2rUQlN3zEVxmWFcZuo/Moa1AiXnznzvd/gZ9h7mhQiF0AHI/ FRP/GCFGjqbXXjlOwldCJVsijLvSE3oLnfPWcsG56RR7nCBDe7ZryYWtPcfZE2aMHcsO iWTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vvnm+YwnOcSsu7Jrhb7VP1vqRW2h+tAKlAI7YxRxit8=; b=cgaLZejrqasjDTSXk/X67oopAnj6hNftJmCBT/P4GqsrXdOaCBZy3f1idNp7tobcd5 hk2bvwJezZdLOJIeMihEc+NuwjwR465Uf/FI+SqSX69ZE4etu7rieGsJhgOeFno4HJmz WZrG1Mxl5QxPdYjP+h6S3cmmlezNtX9rC1Drth0rQyZDwtS0GPgLSD5tBHIyCeyE2UaP L8RUZ3tXw5HCUHICIJbQM8CQYebA71JUnZu2WNMlSAkBizgxMuL8ThuvRVLSShg0xaVg iH7Ljwjv19Bn/J6PkuIi0fhofVAnuVHI+sx8arzausUNg7XdmXPo1NOHSAaQJiIrJiXg Br5A== X-Gm-Message-State: APjAAAVHL93W/kTixo6CTxcfRvH8Cjkj/ndY2n+CiCOHv3wa5u4kcdpd YLpaIRfKlPZQJsPBV7ETq2C04tLfLmo= X-Google-Smtp-Source: APXvYqzEU7xkmQWhxUcj3J6VZ5IuuRjFgs2MAtgSW8+1vIUcc4RLUd+dRw6jwgT9WRe4lTgCI/Ajfg== X-Received: by 2002:aca:5091:: with SMTP id e139mr19807192oib.41.1575218731383; Sun, 01 Dec 2019 08:45:31 -0800 (PST) Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com. [209.85.167.175]) by smtp.gmail.com with ESMTPSA id 64sm5169850oth.31.2019.12.01.08.45.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Dec 2019 08:45:30 -0800 (PST) Received: by mail-oi1-f175.google.com with SMTP id c16so8093402oic.3; Sun, 01 Dec 2019 08:45:29 -0800 (PST) X-Received: by 2002:aca:5cc4:: with SMTP id q187mr5810235oib.45.1575218729332; Sun, 01 Dec 2019 08:45:29 -0800 (PST) MIME-Version: 1.0 References: <201912010728.xB17SQkC019214@sdf.org> In-Reply-To: <201912010728.xB17SQkC019214@sdf.org> From: Tomasz CEDRO Date: Sun, 1 Dec 2019 17:45:17 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: pendrive clone impossible ? To: Scott Bennett Cc: FreeBSD Questions Mailing List , Polytropon , Anatoly , gljennjohn@gmail.com, "freebsd-usb@FreeBSD.org" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 47QvHx11Hgz40h8 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=cedro.info header.s=google header.b=gTi/7w5h; dmarc=none; spf=none (mx1.freebsd.org: domain of tomek@cedro.info has no SPF policy when checking 2607:f8b0:4864:20::244) smtp.mailfrom=tomek@cedro.info X-Spamd-Result: default: False [-1.67 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[cedro.info:s=google]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-usb@freebsd.org]; DMARC_NA(0.00)[cedro.info]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[cedro.info:+]; RCVD_IN_DNSWL_NONE(0.00)[4.4.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_TLS_ALL(0.00)[]; IP_SCORE(-0.37)[ip: (2.37), ipnet: 2607:f8b0::/32(-2.25), asn: 15169(-1.94), country: US(-0.05)] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Dec 2019 16:45:35 -0000 On Sun, Dec 1, 2019 at 8:28 AM Scott Bennett wrote: > >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. > (..) > >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. Hello Scott and thank you for your valuable input. If you are sure that this is NOT a problem of a pendrive or anything USB related with that particular pendrive (i.e. some quirk required for valid operations), and you ARE sure that this is a matter of GEOM, then: 1. OS / GEOM is hiding things from operator. It does not write bytes as instructed to fix the disk, instead, it considers disk invalid and silently discards _only_some_of_the_data_ with no clear error/warning indication. Unacceptable!!! 2. OS / GEOM lies to operator. It does return a SUCCESS code while _some_ data goes to /dev/null. Unacceptale!!! 3. If disk is _considered_ broken then access should be _fully_ blocked. But how am I supposed to fix it when OS silently blocks essential part of the fix? Who allows writing over a corrupted disk anyway? 4. OS / GEOM is broken and incoherent in this area and proves system unreliable / not trustworthy. This needs to be fixed please. Will report a bug. That "irrelevant blather" just proves above. OS cannot silently interfere with operator actions and do whatever it likes. Other people also noticed this problem. This is not the FreeBSD way, looks more like Linux way. Now it looks like the factory pre-format pendrive was considered invalid by GEOM, this is why the initial `dd if=/dev/da0 of=/dev/da1` copied _almost_ whole data but without MBR. Then the situation escalated - MBR dumped to a file could not be written to a target drive, but it could be written from a md0 device, and all sorts of black magic. It THIS IS UNACCEPTABLE!!! When I DD something from IF then it must get untouched into OF, unless missing privilege or hardware failure error is clearly reported preventing further actions. Damn, the DD is the simplest thing in Unix. Either I get the command executed exactly as instructed, or not executed at all. The return code is here to say what happened. Error is here to show me something is wrong. As simple as that. Now it looks like the disk is okay, just GEOM did some interpretation, knew better what I want to, and did, without telling me that. Imagine there were some really sensitive backups on the drive and system decided only to copy selected parts of them with no error. Not a problem for you? Tomek -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info