Bug 228322 - [patch] bsdinstall(8) and sade(8) lose the last block of disk in creating partition.
Summary: [patch] bsdinstall(8) and sade(8) lose the last block of disk in creating par...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.1-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-sysinstall (Nobody)
URL:
Keywords: install, patch
Depends on:
Blocks:
 
Reported: 2018-05-17 19:06 UTC by Rikiya YONEMOTO
Modified: 2022-10-13 17:48 UTC (History)
1 user (show)

See Also:


Attachments
diff-1: required to fix the bug / diff-2: additional could be wrong (491 bytes, application/x-gzip)
2018-05-17 19:06 UTC, Rikiya YONEMOTO
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rikiya YONEMOTO 2018-05-17 19:06:27 UTC
Created attachment 193495 [details]
diff-1: required to fix the bug / diff-2: additional could be wrong

Affected releases: 9.x, 10.x, 11.0, 11.1, 11.2-BETA1
Affected architectures: all(not verified)
Found(verified) release: 11.1
Found(verified) architecture: i386


* Description(summary)

It leads the last block to be lost that bsdintall(8)/sade(8) create a partition(or slice) including the last block of the disk.


* Description(detail)

See attached conceptual patches rather than my bad English.

Look at the attached diff-1 for the point of this problem.

The attached diff-2 is an application to similar point.
This is not required to fix the problem, but it looks like unexpectedly working good in wrong code...
Just for your information.

Attached diffs are for Revision 328410.


* Example step to reproduce the problem

 + Use VirtualBox.
 + Create new VM.
 	type: BSD
 	version: FreeBSD (32-bit)
 	memory-size: 256MB
 	virtual-hdd(VDI): 2.00GB
 + Set(mount) the FreeBSD-11.1-RELEASE-i386-disc1.iso to cd-drive of VM.
 + Start the VM. (boot from the iso image)
 + Do FreeBSD install
 	"Partitioning": "Auto (UFS)" -> <Entire Disk> -> "MBR" -> <Finish> -> <Commit>
 + Reboot into the installed FreeBSD.
 + Login as root.
 	# /sbin/gpart list

Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 4194303
first: 63
entries: 4
scheme: MBR
Providers:
1. Name: ada0s1
   Mediasize: 2147450368 (2.0G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 32768
   Mode: r2w2e3
   attrib: active
   rawtype: 165
   length: 2147450368
   offset: 32768
   type: freebsd
   index: 1
   end: 4194302
   start: 64
(snip)

 + Look at "last" @ ada0 and "end" @ ada0s1.


* Workaround:

Use gpart(8), fdisk(8) or bsdlabel(8) on runnning management.
Choose "Shell" mode for initial install and do it without bsdinstall(8) nor sade(8).


* Attention:

Fixing(updating) bsdinstall(8) does NOT solv the partition already created by the affected versions.
Comment 1 commit-hook freebsd_committer freebsd_triage 2018-05-18 17:43:23 UTC
A commit references this bug:

Author: nwhitehorn
Date: Fri May 18 17:43:16 UTC 2018
New revision: 333803
URL: https://svnweb.freebsd.org/changeset/base/333803

Log:
  Fix math error in the computation of the free space after the last partition
  on a disk. This resulted in one sector always remaining free at the end.

  PR:		bin/228322
  Submitted by:	Rikiya Yonemoto
  MFC after:	2 weeks

Changes:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c
Comment 2 Rikiya YONEMOTO 2018-06-05 02:06:36 UTC
Affected releases additional: 11.2-BETA2, 11.2-BETA3, 11.2-RC1
Comment 3 Rikiya YONEMOTO 2018-06-18 03:56:07 UTC
Affected releases additional: 11.2-RC2, 11.2-RC3
Comment 4 Rikiya YONEMOTO 2018-06-18 03:57:31 UTC
I tested a snapshot iso nearest to the r333803 on the HEAD.
I verified that it has been fixed on the HEAD.

ftp6.jp.freebsd.org/pub/FreeBSD/snapshots/ISO-IMAGES/12.0/FreeBSD-12.0-CURRENT-i386-20180521-r333982-disc1.iso

# uname -a
FreeBSD foobar 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r333982: Mon May 21 17:02:00 UTC 2018     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/i386.i386/sys/GENERIC  i386
# /sbin/gpart list
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 4194303
first: 63
entries: 4
scheme: MBR
Providers:
1. Name: ada0s1
   Mediasize: 2147450880 (2.0G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 32768
   Mode: r2w2e3
   efimedia: HD(1,MBR,0x90909090,0x40,0x3fffc0)
   attrib: active
   rawtype: 165
   length: 2147450880
   offset: 32768
   type: freebsd
   index: 1
   end: 4194303
(snip)