Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jun 1996 00:04:44 -0700 (PDT)
From:      Jake Hamby <jehamby@lightside.com>
To:        "Jordan K. Hubbard" <jkh@time.cdrom.com>
Cc:        current@freebsd.org
Subject:   Useful sysinstall patch.
Message-ID:  <Pine.AUX.3.91.960603235506.24737A-100000@covina.lightside.com>
In-Reply-To: <22630.833740975@time.cdrom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On my home PC, I usually have lots of OS's installed (for example NT, 
Win95, FreeBSD, and Solaris/x86), so a good FDISK program is essential.  
The other day I decided to repartition things, so after backing everything
up, I discovered NT's Disk Manager had trashed Solaris' boot loader,
then while trying to fix Solaris, a bug in their install program hosed
the first HD's FDISK!  Trying to repair things, I discovered FreeBSD's
Sysinstall FDISK will only allow you to create FreeBSD partitions, and
what's worse, if you decide to be clever like I did, and create a FreeBSD 
partition the same size as the underlying DOS partition I was trying to 
recover, when you commit the changes, libdisk writes lots of nasty 
FreeBSD boot code into the partition, ruining the chances of trying to 
get at the old DOS partition!

Anyway, as necessity is the mother of invention, here is a patch which
prompts you to enter the partition type when you create a partition. 
Pressing Enter chooses the default, a FreeBSD native partition, or you can
type a different ID, for example 6 is a DOS partition, and 131 creates a
Linux partition.  The explanation should be understandable, I hope it won't
confuse any new users.  I think that people who intend to install multiple
OS's on a new disk (for example DOS and FreeBSD) will really benefit from
this change, as will the small number of hackers (basically myself) who
would actually try to use Sysinstall to restore a hosed FDISK partition to
old values.  :-)  If you choose anything other than FreeBSD, libdisk will 
not do ANYTHING to the underlying partition, but it is a simple matter, 
for example, to reboot and run DOS FORMAT if that's what you want.  Enjoy!

---Jake

*** disks.c.orig	Mon Jun  3 22:32:35 1996
--- disks.c	Mon Jun  3 23:54:02 1996
***************
*** 271,277 ****
  		msg = "Partition in use, delete it first or move to an unused one.";
  	    else {
  		char *val, tmp[20], *cp;
! 		int size;
  
  		snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
  		val = msgGetInput(tmp, "Please specify the size for new FreeBSD partition in blocks, or append\n"
--- 271,278 ----
  		msg = "Partition in use, delete it first or move to an unused one.";
  	    else {
  		char *val, tmp[20], *cp;
! 		int size, subtype;
! 		chunk_e partitiontype;
  
  		snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
  		val = msgGetInput(tmp, "Please specify the size for new FreeBSD partition in blocks, or append\n"
***************
*** 279,288 ****
  		if (val && (size = strtol(val, &cp, 0)) > 0) {
  		    if (*cp && toupper(*cp) == 'M')
  			size *= ONE_MEG;
! 		    Create_Chunk(d, chunk_info[current_chunk]->offset, size, freebsd, 3,
  				 (chunk_info[current_chunk]->flags & CHUNK_ALIGN));
  		    variable_set2(DISK_PARTITIONED, "yes");
  		    record_chunks(d);
  		}
  	    }
  	    break;
--- 280,307 ----
  		if (val && (size = strtol(val, &cp, 0)) > 0) {
  		    if (*cp && toupper(*cp) == 'M')
  			size *= ONE_MEG;
! 		    strcpy(tmp, "165");
! 		    val = msgGetInput(tmp, "Enter type of partition to create."
! 			"  Pressing Enter will choose the default,\na native"
! 			" FreeBSD partition (type 165).  You can choose other"
! 			" types, for\nexample, enter 6 for a DOS partition, or 131"
! 			" for a Linux partition.\nNote:  If you choose a non-FreeBSD"
! 			" partition type, it will not be\nformatted or otherwise"
! 			" prepared, it will simply reserve space for you to use"
! 			"\nanother tool, such as DOS FORMAT, to format the"
! 			" partition.");
! 		    if (val && (subtype = strtol(val, NULL, 0)) > 0) {
! 			if (subtype==165)
! 				partitiontype=freebsd;
! 			else if (subtype==6)
! 				partitiontype=fat;
! 			else
! 				partitiontype=unknown;
! 		    Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype,
  				 (chunk_info[current_chunk]->flags & CHUNK_ALIGN));
  		    variable_set2(DISK_PARTITIONED, "yes");
  		    record_chunks(d);
+ 		    }
  		}
  	    }
  	    break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.AUX.3.91.960603235506.24737A-100000>