From nobody Fri Jan 26 15:21:30 2024 X-Original-To: freebsd-current@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 4TM1d63vP6z58K2J for ; Fri, 26 Jan 2024 15:21:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (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 4TM1d61pcRz4RCB for ; Fri, 26 Jan 2024 15:21:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-5101f2dfd97so679400e87.2 for ; Fri, 26 Jan 2024 07:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1706282504; x=1706887304; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KpVcOQMjlRPnvqNhp1Xp5bcniG5NujtrkAFBj0ynLrw=; b=0HK3t9yfp2xoF2FCdWqMws8LPu9uCjHUEstV8JF7M9t6UBXJM4E66HAKSfm4uz1XrC tskLWUrTblU+COAz5sMenjotOO0NHvq+IYSJHlOMjfs1VNyU9simWu7Lrc6EzpFNSMCT k6gumriX4ooqMivqpy01e0YumyFt6xdLI7L1f7YVLWJDP5qHH1C4hOFIoQtsLKhhZDIQ md5uesPFhoz/JcUo1GzpbApyY5CG7MDKwVXapwS1tS/ldGlCEOXCjg6dHoOhzM5Vo6FD k5zrWeGzeS+pwXB2J4T2Y/RBKx+0P2tSm1kWgSktgTZM3ZiVBVFHh+zvrXk19QNvZT8g t1dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706282504; x=1706887304; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KpVcOQMjlRPnvqNhp1Xp5bcniG5NujtrkAFBj0ynLrw=; b=qtHaFozIrOjv8E3hjqwZ3l8LxYAmvAEFqNc9fANtrNlroWxjKIcieXnMhb7Zcj2roF U1EhyD+rCWhRZNM0CejJIRCDlA9V/Ve8roTE5VLdyKerQfer1IJeUVbcbUI4N5u9DHoo f7C0nF3B0PAbSGkytGUI4fqcc5E9ZHO+1ArvT/zKx16Yba6hydCGGo6Z4V1FpMLPVw/Y JHtVzS8ocwCAZ4bJafK0wlmz554cYPWoxj/5sFu0UQYvFyeoQPLRskNmmPRlUdxP7shg V3sAfdj7Io7EhNQSZ9ZrIefsJe2Hkm3taKQy/vhZzUqkHXNEz7xmd7+ePt51cDGcHeNW D/QQ== X-Gm-Message-State: AOJu0YzdIoikkUGenC/Pu/7SsKXkeHb3CnUm7AiBhIb6HoG7R/0duB6Y hPkArz/VfMaHYrhVV31nk/TCSqUob7xTuvz3Da6hEGoSJWa8t9iGzTORPF7ySCTzrACyhQ1pKGf su5cZdi4/kAFFT4KbwEANJRQEAnqpBtOLxhsr5td3yHDaJpzA84fEXw== X-Google-Smtp-Source: AGHT+IEIHQYyA27oxE44/G117Px9ezIUg6yKaIv2z+DA3gQXBdFgQ1C5vyo6PjZyD4lLpQmIEiMlhCFVRImpM6VJG6U= X-Received: by 2002:a05:651c:32f:b0:2cf:457e:61fa with SMTP id b15-20020a05651c032f00b002cf457e61famr873500ljp.37.1706282503805; Fri, 26 Jan 2024 07:21:43 -0800 (PST) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 References: <202401251749.40PHnu4E002568@gndrsh.dnsmgr.net> In-Reply-To: <202401251749.40PHnu4E002568@gndrsh.dnsmgr.net> From: Warner Losh Date: Fri, 26 Jan 2024 08:21:30 -0700 Message-ID: Subject: Re: Removing fdisk and bsdlabel (legacy partition tools) To: "Rodney W. Grimes" Cc: Ed Maste , FreeBSD Current Content-Type: multipart/alternative; boundary="00000000000086b18b060fdadaa8" X-Rspamd-Queue-Id: 4TM1d61pcRz4RCB X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] --00000000000086b18b060fdadaa8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 25, 2024, 10:49=E2=80=AFAM Rodney W. Grimes < freebsd-rwg@gndrsh.dnsmgr.net> wrote: > > On Thu, Jan 25, 2024, 9:11?AM Ed Maste wrote: > > > > > On Thu, 25 Jan 2024 at 11:00, Rodney W. Grimes > > > wrote: > > > > > > > > > These will need to be addressed before actually removing any of > these > > > > > binaries, of course. > > > > > > > > You seem to have missed /rescue. Now think about that long > > > > and hard, these tools classified as so important that they > > > > are part of /rescue. Again I can not stress enough how often > > > > I turn to these tools in a repair mode situation. > > > > > > I haven't missed rescue, it is included in the work in progress I > > > mentioned. Note that rescue has included gpart since 2007. > > > > > > > What can fdisk and/or disklabel repair that gpart can't? > > As far as I know there is no way in gpart to get to the > MBR cyl/hd/sec values, you can only get to the LBA start > and end values: > In the last 20 years when have you needed this? LBA start/end is all that's relevant these days. The CHS values are completely ignored by FreeBSD. We use packet mode in the boot loader since about Pentium 150MH= z or so. I did have to change these back in the day when we inferred what the CHS geometry was from the drive by looking at the MBR's partitions that you knew (assumed really) started on a cylinder value. This hasn't mattered in FreeBSD since sos rewrote ata the second time. DOS had to do these things because old-school MFM, RLL, et= c disks couldn't return their CHS, so DOS had to enshrine them in the MBR to get a hint (or have the drive type BIOS to just know). Since we use LBA exclusively, none of this matter to FreeBSD. I've certainly never needed to tweak these in single user mode on an emergency basis. Why? Because you can't get to single user mode because the kernel won't even load if you have these wrong. So either you are booting some rescue disk to fix that (in which case you can craft it for your special environment)., or you are creating a special thing in multi-user, so you can install For all these use cases, fdisk as a port is fine. sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) > start 63, size 8388513 (4095 Meg), flag 80 (active) > beg: cyl 0/ head 1/ sector 1; > end: cyl 1023/ head 15/ sector 63 > > gpart show ada0 > =3D> 63 8388545 ada0 MBR (4.0G) > 63 8388513 1 freebsd [active] (4.0G) > 8388576 32 - free - (16K) > > Now I have learned that gpart backup/restore CAN get me > at least basic bsdlabel -e function, but again it has > no access to all the stuff stored that showsup with > bsdlabel -A. Which this is now the third time I have > asked "how do I do bsdlabel -A -e with gpart"? One > person at least answered that with: > gpart backup GEOM >backup > vi backup > gpart restore GEOM > OK Let's look at these extra fields: # /dev/md0: type: unknown disk: amnesiac label: flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 255 sectors/cylinder: 16065 cylinders: 130 sectors/unit: 2097152 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # milliseconds track-to-track seek: 0 # milliseconds drivedata: 0 type isn't used at all in FreeBSD. disk is for /etc/disktab, something we've not really needed since FreeBSD 3 or so. label can be set with gpart add/modify -l. I've never used flags. Can't speak to that. bytes/sector: This is a physical property of the drive, not the label. You can find it with gpart list: % gpart list md0 .... Consumers: 1. Name: md0 Mediasize: 1073741824 (1.0G) Sectorsize: 512 The rest of this/that are reported or you can do math: fwheads: 255 <- tracks/cylinder fwsectors: 63 <-- sectors/track last: 2097151 <-- sectors/unit - 1 now, cylenders and sectors/cylinder you can compute. geom does this for reading/writing disk labels. rpm is hard coded to 3600 these days. FreeBSD doesn't care. The rest are for interleaving, which FreeBSD doesn't do, so we don't care. So you can influence the values, but they aren't used for anything by FreeBSD that matters. What if you need them for something else? Then just use the disklabel port. You'll never need to hack them tn single user mode, so you can use the port for all use cases. Warner > Warner > -- > Rod Grimes > rgrimes@freebsd.org > --00000000000086b18b060fdadaa8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Jan 25, 2024, 10:49=E2=80=AFA= M Rodney W. Grimes <freebsd-rwg@gndrsh.dnsmgr.net> wrote:
> On Thu, Jan 25, 2024, 9:11?AM Ed Maste <em= aste@freebsd.org> wrote:
>
> > On Thu, 25 Jan 2024 at 11:00, Rodney W. Grimes
> > <freebsd-rwg@gndrsh.dnsmgr.net> wrote:
> > >
> > > > These will need to be addressed before actually removin= g any of these
> > > > binaries, of course.
> > >
> > > You seem to have missed /rescue.=C2=A0 Now think about that = long
> > > and hard, these tools classified as so important that they > > > are part of /rescue.=C2=A0 Again I can not stress enough how= often
> > > I turn to these tools in a repair mode situation.
> >
> > I haven't missed rescue, it is included in the work in progre= ss I
> > mentioned. Note that rescue has included gpart since 2007.
> >
>
> What can fdisk and/or disklabel repair that gpart can't?

As far as I know there is no way in gpart to get to the
MBR cyl/hd/sec values, you can only get to the LBA start
and end values:

In the last 20 years when have you needed this?

= LBA start/end is all that's relevant these days. The CHS values are com= pletely ignored
by FreeBSD. We use packet mode in the boot loader= since about Pentium 150MHz
or so.

I did= have to change these back in the day when we inferred what the CHS geometr= y
was from the drive by looking at the MBR's partitions that = you knew (assumed really)
started on a cylinder value. This hasn&= #39;t mattered in FreeBSD since sos rewrote ata
the second time. = DOS had to do these things because old-school MFM, RLL, etc
disks= couldn't return their CHS, so DOS had to enshrine them in the MBR to g= et
a hint (or have the drive type BIOS to just know). Since we us= e LBA exclusively,
none of this matter to FreeBSD.
=
I've certainly never needed to tweak these in single use= r mode on an emergency
basis. Why? Because you can't get to s= ingle user mode because the kernel won't
even load if you hav= e these wrong. So either you are booting some rescue disk
to fix = that (in which case you can craft it for your special environment)., or you= are
creating a special thing in multi-user, so you can install= =C2=A0 For all these use cases, fdisk
as a port is fine.

<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex"> sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
=C2=A0 =C2=A0 start 63, size 8388513 (4095 Meg), flag 80 (active)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 beg: cyl 0/ head 1/ sector 1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end: cyl 1023/ head 15/ sector 63

gpart show ada0
=3D>=C2=A0 =C2=A0 =C2=A063=C2=A0 8388545=C2=A0 ada0=C2=A0 MBR=C2=A0 (4.0= G)
=C2=A0 =C2=A0 =C2=A0 =C2=A063=C2=A0 8388513=C2=A0 =C2=A0 =C2=A01=C2=A0 free= bsd=C2=A0 [active]=C2=A0 (4.0G)
=C2=A0 8388576=C2=A0 =C2=A0 =C2=A0 =C2=A032=C2=A0 =C2=A0 =C2=A0 =C2=A0 - fr= ee -=C2=A0 (16K)

Now I have learned that gpart backup/restore CAN get me
at least basic bsdlabel -e function, but again it has
no access to all the stuff stored that showsup with
bsdlabel -A.=C2=A0 Which this is now the third time I have
asked "how do I do bsdlabel -A -e with gpart"?=C2=A0 One
person at least answered that with:
gpart backup GEOM >backup
vi backup
gpart restore GEOM

=
OK Let's look at these extra fields:

# /d= ev/md0:
type: unknown
disk: amnesiac
label:
flags:
bytes/se= ctor: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder:= 16065
cylinders: 130
sectors/unit: 2097152
rpm: 3600
interleav= e: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # millisecondstrack-to-track seek: 0 # milliseconds
drivedata: 0

t= ype isn't used at all in FreeBSD.
disk is for /etc/disktab, s= omething we've not really needed since FreeBSD 3 or so.
label= can be set with gpart add/modify -l.
I've never used flags. = Can't speak to that.
bytes/sector: This is a physical propert= y of the drive, not the label.=C2=A0 You can find it with gpart list:
=
=C2=A0=C2=A0 % gpart list md0
=C2=A0=C2=A0 ....
= =C2=A0=C2=A0 Consumers:
=C2=A0=C2=A0 1. Name: md0
=C2=A0 =C2=A0=C2=A0= =C2=A0 Mediasize: 1073741824 (1.0G)
=C2=A0 =C2=A0 =C2=A0 Sectorsize: 512=
The rest of this/that are reported or you can do math:
=
=C2=A0=C2=A0=C2=A0 fwheads: 255 <- tracks/cylinder
=C2=A0=C2=A0= =C2=A0 fwsectors: 63 <-- sectors/track
=C2=A0=C2=A0=C2=A0 last: 20971= 51 <-- sectors/unit - 1
now, cylenders and sectors/cylinder yo= u can compute. geom does this for reading/writing disk labels.
rp= m is hard coded to 3600 these days. FreeBSD doesn't care.
The= rest are for interleaving, which FreeBSD doesn't do, so we don't c= are.

So you can influence the values, but they are= n't used for anything by FreeBSD
that matters.

=
What if you need them for something else? Then just use the disk= label port.
You'll never need to hack them tn single user mod= e, so you can use the port for all use cases.
=
Warner


> Warner
--
Rod Grimes=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rgrimes@freebsd.org
--00000000000086b18b060fdadaa8--