From owner-freebsd-questions@freebsd.org Sat Nov 30 21:33:31 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 E06E91B95F7; Sat, 30 Nov 2019 21:33:31 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47QPkf4zxBz4YYK; Sat, 30 Nov 2019 21:33:30 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.2.248]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPA (Nemesis) id 1Mo73N-1hzLqA19RL-00pfdM; Sat, 30 Nov 2019 22:33:25 +0100 Date: Sat, 30 Nov 2019 22:33:22 +0100 From: Polytropon To: Tomasz CEDRO Cc: FreeBSD Questions Mailing List , "freebsd-usb@FreeBSD.org" Subject: Re: pendrive clone impossible ? Message-Id: <20191130223322.1028feab.freebsd@edvax.de> In-Reply-To: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:GmuKjll3nLyHpBxijPvGbyL02FXco/JdrAa2fafQOye3OrmMazo RNsPQv+8BVr34d69EwnP0mz87VfygR3usRe5woQXMkG2Ak35+EEypFwa/WjfZktxQ+OkypZ dcbwmJ39MYjz+kf+dqTKgfcP5iovPAXCvyduys/IBvaFiS0Vb4U6MHFyIodlR3mYaSYoNQe 6FvTlW6wt97ErEeUit/Gg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:DX5oZzu46zo=:fYt7sG5LcHlDNpRxKDk5Up 76SyYNSyxFHIrVSUo4wUWv8AJvnQas0fa0/Y/GIxaG+XGBG3OWFG96arJLF2+v6eZbUcr19ow sEDr1LNpxFEPZ5cdmMBR6s/Aq/Hiz1FI2G7Y9mLyiF66Ff93jJB939KLEjZj/zUvriq11lxTt DUBXhqxa6Cwry50Cb+NQjU237ewzZTkwD4om03iSpBNio33I73KquPVJ8sAIgFG0meuh8qKEn 9H0dC09Bj0mtk5ncwr9c8NwvRIFot2CocU6A/pCE45+r5DG9lLCD+M+NY3q9G1e34R2uFz1FH shxrWW0WUmdj1f6bBSwWJ1Ry0UUQ3X8kg5uVx4prVVJBRHITwxujmEexHgWeXsxuS8fc+n/ff D2/PMhVAyOGFIBzsqHayVxPbrA6hUWl/SlFS3SfEdtrtBAfTECprflWtKi4Kbe0ZkpOUMCHMN bcqmJN4dgzUXfUGZZ28QVYQoV4XGYmI0GaHnhYB+h+Mz/OuNR8T3d3Z34IuMsp2rjUBvau638 fBKHc4DkTvUpKKudXxinqH7ceAX9FDmUd7jwlL5GXDaJ1qSBVSMAeYORhs9X4c6UzqIGt6fZR ApmGdThVnd6PN2PO3kAETE8ycMTz2v/68UePJEWAbb86apoq0A6NMBEvUebYhSAX8EsEAop9R tgb5cm4rRBNuhKuiGerUgHtoMJgW80ReGiZEU5W1+yWZBdRywyiSC1dly7wfe/0PxGiHX7hJi b7ahNXURRUE1OkwrU7v0mFxk0s2s+4QXf8/vh/HF1KnQA/OgILv0ENLhbaxU8CnPDiwwNzlLE mfC1AlZ+WVlMu0wtlR/Tw6720dYbgfz0cwpZlO2qE52sMEIKBGPHsR985EDV3uyCAhM7UmPHJ dhSvUxprvu61VHXiNIKA== X-Rspamd-Queue-Id: 47QPkf4zxBz4YYK X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.17.10) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [4.60 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[248.2.222.94.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.24)[0.238,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.92)[0.925,0]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[10.17.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.04)[ip: (-0.90), ipnet: 212.227.0.0/16(-1.18), asn: 8560(2.29), country: DE(-0.01)] 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: Sat, 30 Nov 2019 21:33:31 -0000 On Sat, 30 Nov 2019 22:08:21 +0100, Tomasz CEDRO wrote: > 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. What is the error message that dd provides? > 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. The last command seems to be a bit "damaged", I think it should read (separated into two commands for better readability): dd if=/dev/da0 of=da0.mbr bs=512 count=1 dd if=da0.mbr of=/dev/da0 bs=512 count=1 Again, what is the error message of the 2nd dd command? > 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!!! Have you tried copying more than just the first 512 bytes, let's say, the first whole MB? Of course the rest of the partitions would be "incomplete" and therefore not readable, but you should at least get the partition information when you use gpart or ye olde fdisk to read it. > 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. That should be no problem. Partitions can always be smaller than But... you're mentioning a FreeBSD Live CD image. Maybe that one is dedicated, i. e., doesn't actually have any partitions with the meaning of "DOS primary partitions" (which is what gpart or fdisk would list, as mentioned above). However, at least gpart should show at least _some_ information, or you use "disklabel /dev/da" and compare source and target data. In case of a dedicated partitioning (with partition meaning an _actual_ partition in the context of a BSD label, "the thing with the letters"), you should at least find one partition (the "a" partition, bootable). So it's no entirely clear if you try to deal with a MBR disk, something dedicated, or GPT? Everything is possible. :-) > Does GEOM in any way prevents me from using disk that has corrupt MBR? That is possible. Try "sysctl kern.geom.debugflags=0x16" which was, at least in the past, often a way to make things work again. :-) > Why I cannot write a MBR from a file but I can from a md0? To dd, a virtual node shouldn't be needed to operate on MBRs. The if= and of= parameters will (should!) accept plain files just like real devices. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...