From nobody@FreeBSD.org  Thu Apr  5 15:46:54 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 40C4C1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Apr 2012 15:46:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 211BE8FC1A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Apr 2012 15:46:54 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q35FkqtP085131
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 5 Apr 2012 15:46:52 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q35FkqPO085130;
	Thu, 5 Apr 2012 15:46:52 GMT
	(envelope-from nobody)
Message-Id: <201204051546.q35FkqPO085130@red.freebsd.org>
Date: Thu, 5 Apr 2012 15:46:52 GMT
From: Brett Wynkoop <wynkoop@wynn.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sade will not properly format 2TB disk (maybe other sizes as well)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         166673
>Category:       bin
>Synopsis:       sade(8) will not properly format 2TB disk (maybe other sizes as well)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 05 15:50:09 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu Apr 05 23:48:30 UTC 2012
>Originator:     Brett Wynkoop
>Release:        FreeBSD 9.0
>Organization:
>Environment:
FreeBSD dt0.int.harapartners.com 9.0-RELEASE FreeBSD 9.0-RELEASE #0 r230201: Mon Jan 16 10:10:05 CET 2012     root@box.vx.sk:/usr/obj/bsd/releng_9_0/sys/GENERIC  amd64
>Description:
1.  Connected USB disk to system and it appeared as /dev/da4.

2.  Started SADE and set the entire disk as a FreeBSD partation (165)

3.  Went to label section and tried to create a single partition.  Writing it resulted in failure and the device node was never created.

4.  sade also dumped core a couple of times.  I can not say exactly why.

Here is a session of trying to get a filesystem on the disk using sade:

---------------------------cut here---------------------------------------

[root@dt0 /home/wynkoop]# dd if=/dev/zero of=/dev/da4 bs=512 count=2048
2048+0 records in
2048+0 records out
1048576 bytes transferred in 0.840691 secs (1247279 bytes/sec)
[root@dt0 /home/wynkoop]# 
[root@dt0 /home/wynkoop]# sade



      +-------------- Disklabel and partitioning utility ---------------+
      | This is a utility for partitioning and/or labelling your disks. |
      | +-------------------------------------------------------------+ |
      | |        1 Partition  Managing disk partitions                | |
      | |        2 Label      Label allocated disk partitions         | |
      | +-------------------------------------------------------------+ |
      +-----------------------------------------------------------------+
      |                     [  OK  ]       Cancel                       |
      +--------------------------[ DISKUTIL ]---------------------------+


    +-------------------------- Select Drive(s) --------------------------+
    | Please select the drive, or drives, on which you wish to perform    |
    | this operation.  If you are attempting to install a boot partition  |
    | on a drive other than the first one or have multiple operating      |
    | systems on your machine, you will have the option to install a boot |
    | manager later.  To select a drive, use the arrow keys to move to it |
    | and press [SPACE] or [ENTER].  To de-select it, press it again.     |
    |                                                                     |
    | Use [TAB] to get to the buttons and leave this menu.                |
    | +-----------------------------------------------------------------+ |
    | |                         [ ] ada0  ada0                          | |
    | |                         [X] da4   da4                           | |
    | +-----------------------------------------------------------------+ |
    +---------------------------------------------------------------------+
    |                       [  OK  ]       Cancel                         |
    +---[ Press F1 for important information regarding disk geometry! ]---+


Disk name:      da4                                    FDISK Partition Editor
DISK Geometry:  243201 cyls/255 heads/63 sectors = 3907024065 sectors (1907726MB
)
Offset       Size(ST)        End     Name  PType       Desc  Subtype    Flags

         0         63         62        -     12     unused        0
        63 3907024002 3907024064    da4s1      8    freebsd      165
3907024065       5103 3907029167        -     12     unused        0          






The following commands are supported (in upper or lower case):

A = Use Entire Disk   G = set Drive Geometry   C = Create Slice
D = Delete Slice      Z = Toggle Size Units    S = Set Bootable   | = Expert m.
T = Change Type       U = Undo All Changes     W = Write Changes  Q = Finish


Use F1 or ? to get more help, arrow keys to select.

<NOTE>  The above works.  Failure happens at the label stage </NOTE>

<NOTE> Below is just before writing the changes </NOTE>

                         FreeBSD Disklabel Editor

Disk: da4       Partition name: da4s1   Free: 0 blocks (0MB)

Part      Mount          Size Newfs   Part      Mount          Size Newfs
----      -----          ---- -----   ----      -----          ---- -----
da4s1d    /ufs4        1863GB UFS2+S Y




The following commands are valid here (upper or lower case):
C = Create        D = Delete   M = Mount pt.            W = Write
N = Newfs Opts    Q = Finish   S = Toggle SoftUpdates   Z = Custom Newfs
T = Toggle Newfs  U = Undo     A = Auto Defaults        R = Delete+Merge

Use F1 or ? to get more help, arrow keys to select.

<NOTE> Writing the changes results in the following </NOTE>






      +---------------------------- Message ----------------------------+
      |Error mounting /dev/da4s1d on /ufs4 : No such file or directory  |
      +---------------------------------------------------------(100%)--+
      |                          [  OK  ]                               |
      +--------------------[ Press enter or space ]---------------------+


<NOTE> The following are the device nodes I see at this point </NOTE>

[wynkoop@dt0 ~]$ ls -l /dev/da4*
crw-r-----  1 root  operator    0, 164 Apr  5 11:38 /dev/da4
crw-r-----  1 root  operator    0, 166 Apr  5 11:38 /dev/da4s1
[wynkoop@dt0 ~]$ 

<NOTE> /ufs4 was created <?NOTE>

[wynkoop@dt0 ~]$ ls -ld /ufs4
drwxr-xr-x  2 root  wheel  2 Apr  5 11:18 /ufs4
[wynkoop@dt0 ~]$ 



>How-To-Repeat:
Attempt to partition a disk using sade.
>Fix:
Figure out what changed in 9.0 that was not taken into account in sade and make sade align with these changes.

>Release-Note:
>Audit-Trail:

From: "Brett E. Wynkoop" <wynkoop@wynn.com>
To: bug-followup@FreeBSD.org, wynkoop@wynn.com
Cc:  
Subject: Fwd: Re: misc/166673: sade will not properly format 2TB disk (maybe other sizes as well)
Date: Thu, 05 Apr 2012 12:54:47 -0400 (EDT)

 Greeting-
 
 Just attaching the comments by JKH to the PR.
 
 -Brett
 
 On 05/Apr/2012 12:42 Jordan K. Hubbard <jkh --AT-- freebsd.org> wrote ..
 > Hi Brett,
 > 
 > Yep, everything at Apple is going swimmingly (I see AAPL just hit $631 today -
 > no complaints! ;-) ).    I don't know much about sade, I'm afraid, the credit you
 > see apparently due to the fact that they took the code out of sysinstall (and,
 > now that I look at sade, I see that it does indeed appear to be pretty much the
 > very same code).  Given that, I would suspect one of two problems:
 > 
 > 1. Your geometry is not in fact correct.  You might try the suggested geometry,
 > or inspect the geometry under another OS (simply boot Linux or Windows off a thumb
 > drive and see how they report the drive geometry for a "2nd opinion") and try
 plugging
 > those numbers into sade, e.g. hit the "G" key in the Partition editor and manually
 > change them.
 > 
 > 2. You're hitting a bug in libdisk, which sade uses, possibly a 32 bit overflow
 > because they didn't have 2Tb disks when phk and I wrote the original code. :)
 > 
 > - Jordan
 
 
 --------------------------------------------------------------------------------
 email: wynkoop@wynn.com                                                         
 Phone: 917-642-6925
 
>Unformatted:
