From nobody Wed Jan 12 01:44:23 2022 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 70BE519426AB for ; Wed, 12 Jan 2022 01:44:36 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JYVjc2b2fz3wMK for ; Wed, 12 Jan 2022 01:44:36 +0000 (UTC) (envelope-from tomek@cedro.info) Received: by mail-ot1-x32e.google.com with SMTP id i5-20020a05683033e500b0057a369ac614so870784otu.10 for ; Tue, 11 Jan 2022 17:44:36 -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=7+JWNawKjUQsxdCGXZmFT6fZIY5NcASh9JgYHJiLcvc=; b=EP4lAW5JrvwQbomFGYwzImwP0e+EEBoVKMy3l+KaPZxTjEorFSsr9ZrJB9LYhjIQj7 UuMz55CVyxbf7ESlBYSg56yHPjols5ClNwl2DqodnYyMWnKMpSyUdxv7xj/9J466Q1Im dIFmWlTHD5u1QyLhPQhKhpo5kLCXOHWSiT3eudzVvbQmkEIHy/s9cFtPoGdg0qQtkIns 2QRX9d0iFwUM2YXqBA4/HsFpdRpO7lxIfrWPszaR31xsI+V1l2W3U8ie8vDdUS68oGme Jz6GWk/+4Soi5JRFbcm3KhhCBaloPYq9BXx01fFtL3NFq33HPgdowPXsIyod7NjB8XLd ynqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7+JWNawKjUQsxdCGXZmFT6fZIY5NcASh9JgYHJiLcvc=; b=s9Jy9XmybxTAaNvxONIanoPBd1CzDYW4STv1pBmhKyWhtV8rVhV6coaP4R8kOe7M2l tep6nxqUZgrWilnKMq3BGLq2lUih5oUkxY2u2/fJJzRuXDOValE+c2FycLp9Yr8ib8lJ t4QzBePPkLFa2V0Kn5Ql3iIlfeWz7LHi8zUHAYrGeHwTJQcvSV965YnClySxZQtCHiqD 3nwd662PmzYHLre562EDUDK7cE/CtXAJx5chgg36wJIJQJKEFTlWM2a/LYaT+vgBNk++ bQM1V3mWSksyRnNXLOooLw5tcODKY2rvkeHPbKCw7riIR3jWGR0jARZA1HP9U2kMTE2t AjrQ== X-Gm-Message-State: AOAM533K3hWmJWSyPzGK5IhY1VQ7/0hGlFqMNj6lubLSZmV9+zA3YoZg DV/xAOABqXXt04Mx61FgwIyv2n0PFxUgRV/iHN8R+w== X-Google-Smtp-Source: ABdhPJy4RLKKLunxeJAiblpyQ7OIS0ywaAxbJqLSXHOE0DyalluZi8M/tM+rFZrZlXGwVOW1llHJc5XZXexhQu2EZtE= X-Received: by 2002:a9d:710c:: with SMTP id n12mr5358693otj.22.1641951875410; Tue, 11 Jan 2022 17:44:35 -0800 (PST) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 References: <4af920fc-eff1-a92e-d36e-1ba97079864c@gmail.com> <20220112010402.GG61872@eureka.lemis.com> In-Reply-To: <20220112010402.GG61872@eureka.lemis.com> From: Tomasz CEDRO Date: Wed, 12 Jan 2022 02:44:23 +0100 Message-ID: Subject: Re: dd and mbr To: "Greg 'groggy' Lehey" Cc: Roderick , FreeBSD Questions List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4JYVjc2b2fz3wMK X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Wed, Jan 12, 2022 at 2:04 AM Greg 'groggy' Lehey wrote: > > On Tuesday, 11 January 2022 at 15:04:33 +0100, Tomasz CEDRO wrote: > > On Tue, Jan 11, 2022 at 11:05 AM Roderick wrote: > >> The command: > >> dd if=/dev/zero of=/dev/da0 > >> does not delete the mbr, I still see the partition table with > >> fdisk. My questions: > > I'll address these issues at the bottom of this reply. > > >> (1) What does this command do? > >> (2) How to delete the mbr with dd? How to address the whole disk with dd? > >> In OpenBSD is simply > >> dd if=/dev/zero of=/dev/rsd0c > >> with perhaps a count argument. > >> Rod. > > > > There seems to be a tricky sysctl introduced some time ago that > > prevents some operations on mbr.. I got into that issuse some time ago > > but don't remember details sorry.. > > Thanks. Yes, this is what I recall too. > (..) > The background: FreeBSD has been through many iterations of disk > labeling. Once there was a program called disklabel(8) which laid out > the partition table. It was a real pain, and since then it has > morphed into bsdlabel(8), still a pain. And since then we have GPT > partition tables, which are the most modern iteration. But on the way > there have been many mechanisms to protect the first sector on the > disk from accidental overwriting, and the current one is to set > kern.geom.debugflags. It's not really intended for end users, which > is no excuse for not being documented more prominently. > > > I also do not like that FreeBSD system hides something from me like > > Linux then requires searching for a magic solution.. I would prefer > > to stay OpenBSD way you presented :-( > > I don't think that any of these are good solutions. > > Back to Rod: > > Where did you get the dd approach? As others have said, at the very > least you should have limited the length, otherwise you would > overwrite the entire disk, one sector at a time. Thanks Greg :-) That was exactly my case, "I just wanted to dd one disk to another byte-to-byte"^TM no partitions play no data play just raw copy from slower bootable (both mbr+uefi) pendrive to faster bootable pendrive.. and then surprise surprise it turned out that new disk did not have the first sector copied.. this is why I do not like that approach to hide anything in the background or set some defaults that was not there before.. I asked to dd whole disk but the disk was not copied byte-to-byte.. I could not even later copy the first 512 bytes until some magic sysctl was changed :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info