From thz@Lennartz-electronic.de  Tue Jul 16 07:12:51 2002
Return-Path: <thz@Lennartz-electronic.de>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F1AD237B400
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Jul 2002 07:12:50 -0700 (PDT)
Received: from smtp.www-service.de (smtp.www-service.de [212.77.161.16])
	by mx1.FreeBSD.org (Postfix) with ESMTP id DCEAF43E31
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Jul 2002 07:12:49 -0700 (PDT)
	(envelope-from thz@Lennartz-electronic.de)
Received: from swd2.tue.le (pD95033C1.dip.t-dialin.net [217.80.51.193])
	by smtp.www-service.de (8.11.6/8.11.6) with ESMTP id g6GFVrX20483
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Jul 2002 17:31:53 +0200
Received: from mezcal.tue.le (mezcal.tue.le [192.168.201.20])
	by swd2.tue.le (8.12.3/8.12.3) with ESMTP id g6GECdD0049749
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Jul 2002 16:12:39 +0200 (CEST)
	(envelope-from thz@mezcal.tue.le)
Received: from mezcal.tue.le (localhost [127.0.0.1])
	by mezcal.tue.le (8.12.3/8.12.3) with ESMTP id g6GECdUM072884
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Jul 2002 16:12:39 +0200 (CEST)
	(envelope-from thz@mezcal.tue.le)
Received: (from thz@localhost)
	by mezcal.tue.le (8.12.3/8.12.3/Submit) id g6GECcss072883;
	Tue, 16 Jul 2002 16:12:38 +0200 (CEST)
	(envelope-from thz)
Message-Id: <200207161412.g6GECcss072883@mezcal.tue.le>
Date: Tue, 16 Jul 2002 16:12:38 +0200 (CEST)
From: Thomas Zenker <thz@Lennartz-electronic.de>
Reply-To: Thomas Zenker <thz@Lennartz-electronic.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: patch: sysinstall: scripted deletion of slices
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         40656
>Category:       bin
>Synopsis:       [patch] [sysinstall] scripted deletion of slices
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-qa
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 16 07:20:01 PDT 2002
>Closed-Date:    Sat Jul 30 00:43:35 GMT 2005
>Last-Modified:  Sat Jul 30 00:43:35 GMT 2005
>Originator:     Thomas Zenker
>Release:        FreeBSD 4.6-RELEASE i386
>Organization:
>Environment:
System: FreeBSD mezcal.tue.le 4.6-RELEASE FreeBSD 4.6-RELEASE #8: Mon Jun 10 11:22:51 CEST 2002 thz@mezcal.tue.le:/usr/obj/usr/src/sys/MEZCAL i386


	all versions of sysinstall
>Description:
	for automated installations it is often necessary to delete
	the previously existing fdisk partitions (slices) from the
	script, otherwise the results are not as expected.
>How-To-Repeat:
	a previously fdisk partitioned disk prevents successfull
	re-partitioning of a disk.
>Fix:

	introduce a new variable for sysinstall "deletePartition".
	For the moment it is only possible to give a argument of "all",
	which means to delete all slices. For deleting of a specific
	slice, it would be necessary to figure out how to a access it.
	The patch applies to current and stable. Man page update included.

Index: usr.sbin/sysinstall/disks.c
===================================================================
RCS file: /usr/cvs/FreeBSD/src/usr.sbin/sysinstall/disks.c,v
retrieving revision 1.132
diff -u -r1.132 disks.c
--- usr.sbin/sysinstall/disks.c	31 May 2002 17:03:01 -0000	1.132
+++ usr.sbin/sysinstall/disks.c	16 Jul 2002 13:12:09 -0000
@@ -869,6 +869,16 @@
 	d->bios_sect = strtol(cp + 1, 0, 0);
     }
 
+    cp = variable_get(VAR_DELPARTITION);
+    if (cp) {
+	if (strcmp(cp, "all") == 0) {
+	    for (i = 0; chunk_info[i]; i++)
+		Delete_Chunk(d, chunk_info[i]);
+	    variable_unset(VAR_DELPARTITION);
+	    record_chunks(d);
+	}
+    }
+
     cp = variable_get(VAR_PARTITION);
     if (cp) {
 	if (!strcmp(cp, "free")) {
Index: usr.sbin/sysinstall/sysinstall.h
===================================================================
RCS file: /usr/cvs/FreeBSD/src/usr.sbin/sysinstall/sysinstall.h,v
retrieving revision 1.228
diff -u -r1.228 sysinstall.h
--- usr.sbin/sysinstall/sysinstall.h	1 Jun 2002 14:50:14 -0000	1.228
+++ usr.sbin/sysinstall/sysinstall.h	16 Jul 2002 13:12:09 -0000
@@ -91,6 +91,7 @@
 #define VAR_BROWSER_PACKAGE		"browserPackage"
 #define VAR_CPIO_VERBOSITY		"cpioVerbose"
 #define VAR_DEBUG			"debug"
+#define VAR_DELPARTITION		"deletePartition"
 #define VAR_DESKSTYLE			"_deskStyle"
 #define VAR_DISK			"disk"
 #define VAR_DISKINTERACTIVE		"diskInteractive"
Index: usr.sbin/sysinstall/sysinstall.8
===================================================================
RCS file: /usr/cvs/FreeBSD/src/usr.sbin/sysinstall/sysinstall.8,v
retrieving revision 1.53
diff -u -r1.53 sysinstall.8
--- usr.sbin/sysinstall/sysinstall.8	14 Jul 2002 14:46:26 -0000	1.53
+++ usr.sbin/sysinstall/sysinstall.8	16 Jul 2002 13:12:09 -0000
@@ -287,6 +287,11 @@
 Default: none.
 .It diskInteractive
 If set, bring up the interactive disk partition editor.
+.It deletePartition
+can be set to
+.Ar all
+to delete all previously existing partitions.
+Default: nothing deleted.
 .El
 .Pp
 Note: Nothing is actually written to disk by this function, a explicit call to
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->re 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Wed Jul 17 09:36:28 PDT 2002 
Responsible-Changed-Why:  
Release engineers are looking after sysinstall. 

Patch to allow deleting of existing partition in scripted installs. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40656 
Responsible-Changed-From-To: re->qa 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Fri Jul 19 04:10:31 PDT 2002 
Responsible-Changed-Why:  
re@ feel that qa@ is a better list to assign sysinstall PRs to. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40656 

From: Thomas Zenker <thz@Lennartz-electronic.de>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/40656: patch: sysinstall: scripted deletion of slices
Date: Wed, 28 May 2003 10:26:02 +0200

 Perhaps helps to get an ear explaining this a bit further: In
 automated installations (embedded devices in instruments) via
 sysinstall scripts, it is impossible to make a script which does a
 complete installation and works on hard disks which have fdisk
 partitions already. The most simple solution is to give sysinstall
 scripts the ability to delete all fdisk partitions, so we can do a
 new install. In embedded devices clobbering the fdisk partition 
 manually is not an option.
 
 Thomas
State-Changed-From-To: open->feedback 
State-Changed-By: jhb 
State-Changed-When: Mon Aug 2 18:46:24 GMT 2004 
State-Changed-Why:  
Sent submitter an example of an install script that works as requested 
without patching sysinstall. 


Responsible-Changed-From-To: qa->freebsd-qa 
Responsible-Changed-By: jhb 
Responsible-Changed-When: Mon Aug 2 18:46:24 GMT 2004 
Responsible-Changed-Why:  
Canonicalize responsible. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40656 

From: John Baldwin <jhb@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, thz@lennartz-electronic.de
Cc:  
Subject: Re: bin/40656: patch: sysinstall: scripted deletion of slices
Date: Mon, 2 Aug 2004 14:50:23 -0400

 Where I work I use install scripts to install onto a disk and have no problem 
 overwriting disks with existing fdisk(8) tables.  This is an excerpt of what 
 I use:
 
 # setup a FreeBSD slice
 disk=ad0
 partition=all
 bootManager=standard
 #diskInteractive=yes
 diskPartitionEditor
 
 # setup partitions in the slice
 # 512mb /
 # 1gb swap
 # 2gb /tmp
 # 2gb /var
 # 60gb /usr
 # rest /media
 #rootSize=512
 #tmpSize=2048
 #varSize=2048
 
 ad0s1-1=ufs 1048576 /
 ad0s1-2=swap 2079832 /
 ad0s1-3=ufs 4194304 /tmp 1
 ad0s1-4=ufs 4194304 /var 1
 ad0s1-5=ufs 125829120 /usr 1
 ad0s1-6=ufs 0 /media 1
 diskLabelEditor
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org
State-Changed-From-To: feedback->closed 
State-Changed-By: kris 
State-Changed-When: Sat Jul 30 00:43:13 GMT 2005 
State-Changed-Why:  
No response from submitter, assuming John's script was acceptable 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40656 
>Unformatted:
