Bug 31306

Summary: sysinstall fails to create non-root partitions
Product: Base System Reporter: david
Component: binAssignee: freebsd-qa (Nobody) <qa>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description david 2001-10-16 01:10:01 UTC
	After using the Disk Label Editor to specify the characteristics
	of the fileesystems to be used and the partitions where they
	reside, sysinstall creates the device entries in /dev for the
	root and swap partitions, but none of the others.

	In cases where significant parts of the system are intended to be
	installed on a non-root filesystem, this tends to cause the install
	to fail.

Fix: 

I haven't actually done this code (yet), but....  Looking at install.c,
	rev. 1.308, starting at line 953:


    /* Now buzz through the rest of the partitions and mount them too */
    devs = deviceFind(NULL, DEVICE_TYPE_DISK);
    for (i = 0; devs[i]; i++) {
	if (!devs[i]->enabled)
	    continue;

	disk = (Disk *)devs[i]->private;
	if (!disk->chunks) {
	    msgConfirm("No chunk list found for %s!", disk->name);
	    return DITEM_FAILURE | DITEM_RESTORE;
	}
	if (RunningAsInit && root && (root->newfs || upgrade)) {
	    Mkdir("/mnt/dev");
	    if (!Fake)
		MakeDevDisk(disk, "/mnt/dev");
	}
	else if (!RunningAsInit && !Fake)
	    MakeDevDisk(disk, "/dev");

	for (c1 = disk->chunks->part; c1; c1 = c1->next) {
	    if (c1->type == freebsd) {
		for (c2 = c1->part; c2; c2 = c2->next) {
		    if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
			PartInfo *tmp = (PartInfo *)c2->private_data;

			/* Already did root */
			if (c2 == rootdev)
			    continue;

			if (tmp->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name)))
			    command_shell_add(tmp->mountpoint, "%s %s/dev/%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name);
			else
			    command_shell_add(tmp->mountpoint, "fsck -y %s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
			if (tmp->soft)
			    command_shell_add(tmp->mountpoint, "tunefs -n enable %s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
			command_func_add(tmp->mountpoint, Mount, c2->name);
		    }
		    else if (c2->type == part && c2->subtype == FS_SWAP) {
			char fname[80];
			int i;

			if (c2 == swapdev)
			    continue;
			sprintf(fname, "%s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
			i = (Fake || swapon(fname));
			if (!i) {
			    dialog_clear_norefresh();
			    msgNotify("Added %s as an additional swap device", fname);
			}
			else {
			    msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
			}
		    }
		}
	    }
	    else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) {
		char name[FILENAME_MAX];

		sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint);
		Mkdir(name);
	    }
	}
    }


	We see that there's a call to MakeDevDisk() for the root case, but
	not for the non-root case.  (Indeed:  there are a couple of them,
	for different situations.  And those 2 MakeDevDisk() calls are the
	only ones in /usr/src/usr.sbin/sysinstall/*.)  It's been quite a
	while since I actually programmed for a living, but that appears
	a tad suspect to me.  And note that the first things we try to do
	(in the non-root case) is a newfs command, which corresponds to
	the empirical evidence.
How-To-Repeat: 	Grab the kern.flp & msroot.flp images from a -CURRENT snapshot; copy
	them to appropriate media.  When you boot, it may be instructive to
	interrupt the boot sequence and specify "boot -v" (in order to get
	sysinstall debug information on vty2).

	Go through the install process.  At the Disk Label Editor, specify a
	modestly-sized root filesystem -- say, 160 MB or less.  Specify a
	reasonable (separate) filesystem for /usr, such as 2 GB.  You might
	specify a separate filesystem for /var, but the /usr one is the
	critical part, here.

	Select a distribution; for simplicity, I suggest "Developer" (not
	"X-Developer", as that requires a bit more interaction).  I declined
	the ports, as I was going to do that via CVSup anyhow.

	Affirm that you do, indeed, wish to Commit.  :-)

	A window is displayed, reading something on the order of

	Error mounting /mnt/dev/ad0s2f on /mnt/usr : No such file or directory

	Use Alt+F2 to see the debug messages.  Note that the first mention
	of ad0s2f we see is an attempt to do a "newfs".  See below for evidence
	that we should have seen that a mknod() call was issued; available
	evidence indicates that this was, in fact, not done.
Comment 1 Murray Stokely freebsd_committer freebsd_triage 2002-03-27 12:06:10 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-qa

This PR provides a thorough description of the problem.  Can anyone on 
the qa@ list provide (and test) a patch?
Comment 2 Johan Karlsson freebsd_committer freebsd_triage 2002-08-25 03:20:42 UTC
Responsible Changed
From-To: freebsd-qa->qa

Use short names for mailing list to make searches    
using the web query form work with the shown responsible. 

This also makes open PRs show up in the summery mail.
Comment 3 John Baldwin freebsd_committer freebsd_triage 2002-11-12 18:56:53 UTC
State Changed
From-To: open->closed

install's now work again on 5.0.  This was most likely an interaction between 
devfs, geom, and libdisk that has been fixed in the past few weeks.