diff --git a/distrib/utils/sysinst/Makefile.inc b/distrib/utils/sysinst/Makefile.inc
index ec9252e..6353721 100644
--- a/distrib/utils/sysinst/Makefile.inc
+++ b/distrib/utils/sysinst/Makefile.inc
@@ -45,7 +45,7 @@ CPPFLAGS+=	-I. -I${.CURDIR}/../.. -I${.CURDIR} \
 		-DMACH_${MACHINE} -DARCH_${MACHINE_ARCH}
 
 .if (defined(DEBUG))
-CPPFLAGS+=-DDEBUG
+CPPFLAGS+=-DDEBUG -g -O0
 .endif
 
 .if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
diff --git a/distrib/utils/sysinst/arch/acorn32/md.c b/distrib/utils/sysinst/arch/acorn32/md.c
index 2e51b1c..efa9de6 100644
--- a/distrib/utils/sysinst/arch/acorn32/md.c
+++ b/distrib/utils/sysinst/arch/acorn32/md.c
@@ -66,19 +66,19 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 	static unsigned char bb[DEV_BSIZE];
 	struct filecore_bootblock *fcbb = (struct filecore_bootblock *)bb;
 	int offset = 0;
 
-	if (strncmp(diskdev, "wd", 2) == 0)
+	if (strncmp(pm->diskdev, "wd", 2) == 0)
 		disktype = "ST506";
 	else
 		disktype = "SCSI";
 
-	snprintf(dev_name, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
+	snprintf(dev_name, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -86,7 +86,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf(stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -173,33 +173,33 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
-	ptstart = offset;
+	pm->ptstart = offset;
 /*	endwin();
-	printf("dlcyl=%d\n", dlcyl);
-	printf("dlhead=%d\n", dlhead);
-	printf("dlsec=%d\n", dlsec);
-	printf("secsz=%d\n", sectorsize);
-	printf("cylsz=%d\n", dlcylsize);
-	printf("dlsz=%d\n", dlsize);
-	printf("pstart=%d\n", ptstart);
+	printf("pm->dlcyl=%d\n", pm->dlcyl);
+	printf("pm->dlhead=%d\n", pm->dlhead);
+	printf("pm->dlsec=%d\n", pm->dlsec);
+	printf("secsz=%d\n", pm->sectorsize);
+	printf("cylsz=%d\n", pm->dlcylsize);
+	printf("dlsz=%d\n", pm->dlsize);
+	printf("pstart=%d\n", pm->ptstart);
 	printf("pstart=%d\n", partsize);
-	printf("secpun=%d\n", disklabel.d_secperunit);
+	printf("secpun=%d\n", pm->disklabel.d_secperunit);
 	backtowin();*/
 
 	return 1;
diff --git a/distrib/utils/sysinst/arch/alpha/md.c b/distrib/utils/sysinst/arch/alpha/md.c
index 1114462..b481739 100644
--- a/distrib/utils/sysinst/arch/alpha/md.c
+++ b/distrib/utils/sysinst/arch/alpha/md.c
@@ -63,11 +63,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf (dev_name, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
+	snprintf (dev_name, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
 
 	fd = open (dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -75,7 +75,7 @@ md_get_info(void)
 		fprintf (stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -83,21 +83,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -151,12 +151,12 @@ md_post_newfs(void)
 	char *bootxx;
 	int error;
 
-	printf(msg_string(MSG_dobootblks), diskdev);
+	printf(msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot", "/boot");
 	bootxx = bootxx_name();
 	if (bootxx != NULL) {
 		error = run_program(RUN_DISPLAY | RUN_NO_CLEAR,
-		    "/usr/sbin/installboot /dev/r%sc %s", diskdev, bootxx);
+		    "/usr/sbin/installboot /dev/r%sc %s", pm->diskdev, bootxx);
 		free(bootxx);
 	} else
 		error = -1;
diff --git a/distrib/utils/sysinst/arch/amd64/md.h b/distrib/utils/sysinst/arch/amd64/md.h
index 6f4325e..e5ce41d 100644
--- a/distrib/utils/sysinst/arch/amd64/md.h
+++ b/distrib/utils/sysinst/arch/amd64/md.h
@@ -89,7 +89,7 @@
  * On amd64, we allow "wd"  ST-506/IDE disks,  "sd" scsi disks, "ld" logical
  * disks and "raid" raidframe disks.
  */
-#define DISK_NAMES "wd", "sd", "ld", "raid:no_mbr", "xbd:no_mbr"
+#define DISK_NAMES "wd", "sd", "ld", "raid:pm->no_mbr", "xbd:pm->no_mbr"
 
 /*
  * Machine-specific command to write a new label to a disk.
diff --git a/distrib/utils/sysinst/arch/amiga/md.c b/distrib/utils/sysinst/arch/amiga/md.c
index c74334a..1b6a976 100644
--- a/distrib/utils/sysinst/arch/amiga/md.c
+++ b/distrib/utils/sysinst/arch/amiga/md.c
@@ -107,9 +107,9 @@ int
 md_post_newfs(void)
 {
 	/* boot blocks ... */
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	return run_program(RUN_DISPLAY,
-	    "/usr/mdec/installboot -v /usr/mdec/xxboot /dev/r%sa", diskdev);
+	    "/usr/mdec/installboot -v /usr/mdec/xxboot /dev/r%sa", pm->diskdev);
 }
 
 int
diff --git a/distrib/utils/sysinst/arch/arc/md.c b/distrib/utils/sysinst/arch/arc/md.c
index 5e4ccf9..e0a93c4 100644
--- a/distrib/utils/sysinst/arch/arc/md.c
+++ b/distrib/utils/sysinst/arch/arc/md.c
@@ -88,62 +88,62 @@ md_make_bsd_partitions(void)
 	 * Initialize global variables that track space used on this disk.
 	 * Standard 4.4BSD 8-partition labels always cover whole disk.
 	 */
-	if (ptsize == 0)
-		ptsize = dlsize - ptstart;
-	if (dlsize == 0)
-		dlsize = ptstart + ptsize;
+	if (pm->ptsize == 0)
+		pm->ptsize = pm->dlsize - pm->ptstart;
+	if (pm->dlsize == 0)
+		pm->dlsize = pm->ptstart + pm->ptsize;
 
-	partstart = ptstart;
-	ptend = ptstart + ptsize;
+	partstart = pm->ptstart;
+	ptend = pm->ptstart + pm->ptsize;
 
 	/* Ask for layout type -- standard or special */
 	msg_display(MSG_layout,
-		    ptsize / (MEG / sectorsize),
+		    pm->ptsize / (MEG / pm->sectorsize),
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE,
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB);
 
 	process_menu(MENU_layout, NULL);
 
 	/* Set so we use the 'real' geometry for rounding, input in MB */
-	current_cylsize = dlcylsize;
+	pm->current_cylsize = pm->dlcylsize;
 	set_sizemultname_meg();
 
 	/* Build standard partitions */
-	memset(&bsdlabel, 0, sizeof bsdlabel);
+	memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);
 
 	/* Set initial partition types to unused */
 	for (part = 0 ; part < maxpart ; ++part)
-		bsdlabel[part].pi_fstype = FS_UNUSED;
+		pm->bsdlabel[part].pi_fstype = FS_UNUSED;
 
 	/* Whole disk partition */
 	part_raw = getrawpartition();
 	if (part_raw == -1)
 		part_raw = PART_C;	/* for sanity... */
-	bsdlabel[part_raw].pi_offset = 0;
-	bsdlabel[part_raw].pi_size = dlsize;
+	pm->bsdlabel[part_raw].pi_offset = 0;
+	pm->bsdlabel[part_raw].pi_size = pm->dlsize;
 
 	if (part_raw == PART_D) {
 		/* Probably a system that expects an i386 style mbr */
 		part_bsd = PART_C;
-		bsdlabel[PART_C].pi_offset = ptstart;
-		bsdlabel[PART_C].pi_size = ptsize;
+		pm->bsdlabel[PART_C].pi_offset = pm->ptstart;
+		pm->bsdlabel[PART_C].pi_size = pm->ptsize;
 	} else {
 		part_bsd = part_raw;
 	}
 
-	if (bootsize != 0) {
-		bsdlabel[PART_BOOT_FAT12].pi_fstype = FS_MSDOS;
-		bsdlabel[PART_BOOT_FAT12].pi_size = bootsize;
-		bsdlabel[PART_BOOT_FAT12].pi_offset = bootstart;
-		bsdlabel[PART_BOOT_FAT12].pi_flags |= PART_BOOT_FAT12_PI_FLAGS;
-		strlcpy(bsdlabel[PART_BOOT_FAT12].pi_mount,
+	if (pm->bootsize != 0) {
+		pm->bsdlabel[PART_BOOT_FAT12].pi_fstype = FS_MSDOS;
+		pm->bsdlabel[PART_BOOT_FAT12].pi_size = pm->bootsize;
+		pm->bsdlabel[PART_BOOT_FAT12].pi_offset = pm->bootstart;
+		pm->bsdlabel[PART_BOOT_FAT12].pi_flags |= PART_BOOT_FAT12_PI_FLAGS;
+		strlcpy(pm->bsdlabel[PART_BOOT_FAT12].pi_mount,
 		    PART_BOOT_FAT12_PI_MOUNT,
-		    sizeof bsdlabel[PART_BOOT_FAT12].pi_mount);
+		    sizeof pm->bsdlabel[PART_BOOT_FAT12].pi_mount);
 	}
 
 #ifdef PART_REST
-	bsdlabel[PART_REST].pi_offset = 0;
-	bsdlabel[PART_REST].pi_size = ptstart;
+	pm->bsdlabel[PART_REST].pi_offset = 0;
+	pm->bsdlabel[PART_REST].pi_size = pm->ptstart;
 #endif
 
 	/*
@@ -153,24 +153,24 @@ md_make_bsd_partitions(void)
 	 * partitions on a multiboot i386 system.
 	 */
 	 for (i = maxpart; i--;) {
-		if (bsdlabel[i].pi_size != 0)
+		if (pm->bsdlabel[i].pi_size != 0)
 			/* Don't overwrite special partitions */
 			continue;
-		p = &oldlabel[i];
+		p = &pm->oldlabel[i];
 		if (p->pi_fstype == FS_UNUSED || p->pi_size == 0)
 			continue;
 		if (layoutkind == 4) {
 			if (PI_ISBSDFS(p))
 				p->pi_flags |= PIF_MOUNT;
 		} else {
-			if (p->pi_offset < ptstart + ptsize &&
-			    p->pi_offset + p->pi_size > ptstart)
+			if (p->pi_offset < pm->ptstart + pm->ptsize &&
+			    p->pi_offset + p->pi_size > pm->ptstart)
 				/* Not outside area we are allocating */
 				continue;
 			if (p->pi_fstype == FS_SWAP)
 				no_swap = 1;
 		}
-		bsdlabel[i] = oldlabel[i];
+		pm->bsdlabel[i] = pm->oldlabel[i];
 	 }
 
 	if (layoutkind == 4) {
@@ -184,7 +184,7 @@ md_make_bsd_partitions(void)
 	 * edit it and verify it's OK, or abort altogether.
 	 */
  edit_check:
-	if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) {
+	if (edit_and_check_label(pm->bsdlabel, maxpart, part_raw, part_bsd) == 0) {
 		msg_display(MSG_abort);
 		return 0;
 	}
@@ -192,10 +192,10 @@ md_make_bsd_partitions(void)
 		goto edit_check;
 
 	/* Disk name */
-	msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname);
+	msg_prompt(MSG_packname, pm->bsddiskname, pm->bsddiskname, sizeof pm->bsddiskname);
 
 	/* save label to disk for MI code to update. */
-	(void)savenewlabel(bsdlabel, maxpart);
+	(void)savenewlabel(pm->bsdlabel, maxpart);
 
 	/* Everything looks OK. */
 	return 1;
@@ -214,7 +214,7 @@ md_check_partitions(void)
 	 * something stupid, like move it away from the MBR partition.
 	 */
 	for (part = PART_A; part < MAXPARTITIONS; part++)
-		if (bsdlabel[part].pi_fstype == FS_MSDOS) {
+		if (pm->bsdlabel[part].pi_fstype == FS_MSDOS) {
 			bootpart_fat12 = part;
 			return 1;
 		}
@@ -233,7 +233,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -248,7 +248,7 @@ int
 md_post_disklabel(void)
 {
 	if (get_ramsize() <= 32)
-		set_swap(diskdev, bsdlabel);
+		set_swap(pm->diskdev, pm->bsdlabel);
 	return 0;
 }
 
@@ -261,7 +261,7 @@ int
 md_post_newfs(void)
 {
 	if (!nobootfs) {
-		msg_display(msg_string(MSG_copybootloader), diskdev);
+		msg_display(msg_string(MSG_copybootloader), pm->diskdev);
 		cp_to_target("/usr/mdec/boot", PART_BOOT_FAT12_PI_MOUNT);
 	}
 
@@ -292,9 +292,9 @@ md_pre_update(void)
 	int i;
 
 	if (get_ramsize() <= 32)
-		set_swap(diskdev, NULL);
+		set_swap(pm->diskdev, NULL);
 
-	read_mbr(diskdev, &mbr);
+	read_mbr(pm->diskdev, &mbr);
 	/* do a sanity check of the partition table */
 	for (ext = &mbr; ext; ext = ext->extended) {
 		part = ext->mbr.mbr_parts;
@@ -335,13 +335,13 @@ md_check_mbr(mbr_info_t *mbri)
 		part = ext->mbr.mbr_parts;
 		for (i = 0; i < MBR_PART_COUNT; part++, i++) {
 			if (part->mbrp_type == MBR_PTYPE_FAT12) {
-				bootstart = part->mbrp_start;
-				bootsize = part->mbrp_size;
+				pm->bootstart = part->mbrp_start;
+				pm->bootsize = part->mbrp_size;
 				break;
 			}
 		}
 	}
-	if (bootsize < (MIN_FAT12_BOOT / 512)) {
+	if (pm->bootsize < (MIN_FAT12_BOOT / 512)) {
 		msg_display(MSG_boottoosmall);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -349,7 +349,7 @@ md_check_mbr(mbr_info_t *mbri)
 			return 0;
 		return 1;
 	}
-	if (bootstart == 0 || bootsize == 0) {
+	if (pm->bootstart == 0 || pm->bootsize == 0) {
 		msg_display(MSG_nobootpart);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -383,14 +383,14 @@ md_mbr_use_wholedisk(mbr_info_t *mbri)
 	part[0].mbrp_flag = MBR_PFLAG_ACTIVE;
 
 	part[1].mbrp_type = MBR_PTYPE_NETBSD;
-	part[1].mbrp_size = dlsize - (bsec + FAT12_BOOT_SIZE / 512);
+	part[1].mbrp_size = pm->dlsize - (bsec + FAT12_BOOT_SIZE / 512);
 	part[1].mbrp_start = bsec + FAT12_BOOT_SIZE / 512;
 	part[1].mbrp_flag = 0;
 
-	ptstart = part[1].mbrp_start;
-	ptsize = part[1].mbrp_size;
-	bootstart = part[0].mbrp_start;
-	bootsize = part[0].mbrp_size;
+	pm->ptstart = part[1].mbrp_start;
+	pm->ptsize = part[1].mbrp_size;
+	pm->bootstart = part[0].mbrp_start;
+	pm->bootsize = part[0].mbrp_size;
 	return 1;
 }
 
diff --git a/distrib/utils/sysinst/arch/atari/md.c b/distrib/utils/sysinst/arch/atari/md.c
index 8faa9bf..59aaacc 100644
--- a/distrib/utils/sysinst/arch/atari/md.c
+++ b/distrib/utils/sysinst/arch/atari/md.c
@@ -68,10 +68,10 @@ md_get_info(void)
 int
 md_make_bsd_partitions(void)
 {
-	msg_display(MSG_infoahdilabel, diskdev);
+	msg_display(MSG_infoahdilabel, pm->diskdev);
 	process_menu(MENU_noyes, NULL);
 	if (yesno) {
-		run_program(RUN_DISPLAY, "ahdilabel /dev/r%sc", diskdev);
+		run_program(RUN_DISPLAY, "ahdilabel /dev/r%sc", pm->diskdev);
 	}
 	if (!make_bsd_partitions())
 		return 0;
@@ -79,7 +79,7 @@ md_make_bsd_partitions(void)
 	/*
 	 * Setup the disktype so /etc/disktab gets proper info
 	 */
-	if (strncmp (diskdev, "sd", 2) == 0)
+	if (strncmp (pm->diskdev, "sd", 2) == 0)
 		disktype = "SCSI";
 	else
 		disktype = "ST506";
@@ -140,7 +140,7 @@ md_post_newfs(void)
 	free(cpu_model);
 
 	/* copy tertiary boot and install boot blocks */
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	snprintf(bootpath, sizeof(bootpath), "/usr/mdec/%s/boot.atari",
 	    milan ? "milan" : "std");
 	rv = cp_to_target(bootpath, "/");
@@ -148,7 +148,7 @@ md_post_newfs(void)
 		return rv;
 
 	rv = run_program(RUN_DISPLAY, "/usr/mdec/installboot -v%s /dev/r%sc",
-	    milan ? "m" : "", diskdev);
+	    milan ? "m" : "", pm->diskdev);
 
 	return rv;
 }
diff --git a/distrib/utils/sysinst/arch/bebox/md.c b/distrib/utils/sysinst/arch/bebox/md.c
index f939303..3481d78 100644
--- a/distrib/utils/sysinst/arch/bebox/md.c
+++ b/distrib/utils/sysinst/arch/bebox/md.c
@@ -88,7 +88,7 @@ md_pre_disklabel(void)
 	printf ("%s", msg_string (MSG_dofdisk));
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
diff --git a/distrib/utils/sysinst/arch/cats/md.c b/distrib/utils/sysinst/arch/cats/md.c
index 8c0f493..e799339 100644
--- a/distrib/utils/sysinst/arch/cats/md.c
+++ b/distrib/utils/sysinst/arch/cats/md.c
@@ -63,7 +63,7 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 #if 0
@@ -72,12 +72,12 @@ md_get_info(void)
 #endif
 	int offset = 0;
 
-	if (strncmp(diskdev, "wd", 2) == 0)
+	if (strncmp(pm->diskdev, "wd", 2) == 0)
 		disktype = "ST506";
 	else
 		disktype = "SCSI";
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -85,7 +85,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf(stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -94,33 +94,33 @@ md_get_info(void)
 
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
-	ptstart = offset;
+	pm->ptstart = offset;
 /*	endwin();
-	printf("dlcyl=%d\n", dlcyl);
-	printf("dlhead=%d\n", dlhead);
-	printf("dlsec=%d\n", dlsec);
-	printf("secsz=%d\n", sectorsize);
-	printf("cylsz=%d\n", dlcylsize);
-	printf("dlsz=%d\n", dlsize);
-	printf("pstart=%d\n", ptstart);
+	printf("pm->dlcyl=%d\n", pm->dlcyl);
+	printf("pm->dlhead=%d\n", pm->dlhead);
+	printf("pm->dlsec=%d\n", pm->dlsec);
+	printf("secsz=%d\n", pm->sectorsize);
+	printf("cylsz=%d\n", pm->dlcylsize);
+	printf("dlsz=%d\n", pm->dlsize);
+	printf("pstart=%d\n", pm->ptstart);
 	printf("pstart=%d\n", partsize);
-	printf("secpun=%d\n", disklabel.d_secperunit);
+	printf("secpun=%d\n", pm->disklabel.d_secperunit);
 	backtowin();*/
 
 	return 1;
diff --git a/distrib/utils/sysinst/arch/cobalt/md.c b/distrib/utils/sysinst/arch/cobalt/md.c
index 47808d3..1826669 100644
--- a/distrib/utils/sysinst/arch/cobalt/md.c
+++ b/distrib/utils/sysinst/arch/cobalt/md.c
@@ -88,63 +88,63 @@ md_make_bsd_partitions(void)
 	 * Initialize global variables that track space used on this disk.
 	 * Standard 4.4BSD 8-partition labels always cover whole disk.
 	 */
-	if (ptsize == 0)
-		ptsize = dlsize - ptstart;
-	if (dlsize == 0)
-		dlsize = ptstart + ptsize;
+	if (pm->ptsize == 0)
+		pm->ptsize = pm->dlsize - pm->ptstart;
+	if (pm->dlsize == 0)
+		pm->dlsize = pm->ptstart + pm->ptsize;
 
-	partstart = ptstart;
-	ptend = ptstart + ptsize;
+	partstart = pm->ptstart;
+	ptend = pm->ptstart + pm->ptsize;
 
 	/* Ask for layout type -- standard or special */
 	msg_display(MSG_layout,
-		    ptsize / (MEG / sectorsize),
+		    pm->ptsize / (MEG / pm->sectorsize),
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE,
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB);
 
 	process_menu(MENU_layout, NULL);
 
 	/* Set so we use the 'real' geometry for rounding, input in MB */
-	current_cylsize = dlcylsize;
+	pm->current_cylsize = pm->dlcylsize;
 	set_sizemultname_meg();
 
 	/* Build standard partitions */
-	memset(&bsdlabel, 0, sizeof bsdlabel);
+	memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);
 
 	/* Set initial partition types to unused */
 	for (part = 0 ; part < maxpart ; ++part)
-		bsdlabel[part].pi_fstype = FS_UNUSED;
+		pm->bsdlabel[part].pi_fstype = FS_UNUSED;
 
 	/* Whole disk partition */
 	part_raw = getrawpartition();
 	if (part_raw == -1)
 		part_raw = PART_C;	/* for sanity... */
-	bsdlabel[part_raw].pi_offset = 0;
-	bsdlabel[part_raw].pi_size = dlsize;
+	pm->bsdlabel[part_raw].pi_offset = 0;
+	pm->bsdlabel[part_raw].pi_size = pm->dlsize;
 
 	if (part_raw == PART_D) {
 		/* Probably a system that expects an i386 style mbr */
 		part_bsd = PART_C;
-		bsdlabel[PART_C].pi_offset = ptstart;
-		bsdlabel[PART_C].pi_size = ptsize;
+		pm->bsdlabel[PART_C].pi_offset = pm->ptstart;
+		pm->bsdlabel[PART_C].pi_size = pm->ptsize;
 	} else {
 		part_bsd = part_raw;
 	}
 
-	if (bootsize != 0) {
-		bsdlabel[PART_BOOT_EXT2FS].pi_fstype = FS_EX2FS;
-		bsdlabel[PART_BOOT_EXT2FS].pi_size = bootsize;
-		bsdlabel[PART_BOOT_EXT2FS].pi_offset = bootstart;
-		bsdlabel[PART_BOOT_EXT2FS].pi_flags |=
+	if (pm->bootsize != 0) {
+		pm->bsdlabel[PART_BOOT_EXT2FS].pi_fstype = FS_EX2FS;
+		pm->bsdlabel[PART_BOOT_EXT2FS].pi_size = pm->bootsize;
+		pm->bsdlabel[PART_BOOT_EXT2FS].pi_offset = pm->bootstart;
+		pm->bsdlabel[PART_BOOT_EXT2FS].pi_flags |=
 		    PART_BOOT_EXT2FS_PI_FLAGS;
-		strlcpy(bsdlabel[PART_BOOT_EXT2FS].pi_mount,
+		strlcpy(pm->bsdlabel[PART_BOOT_EXT2FS].pi_mount,
 		    PART_BOOT_EXT2FS_PI_MOUNT,
-		    sizeof bsdlabel[PART_BOOT_EXT2FS].pi_mount);
+		    sizeof pm->bsdlabel[PART_BOOT_EXT2FS].pi_mount);
 	}
 
 #ifdef PART_REST
-	bsdlabel[PART_REST].pi_offset = 0;
-	bsdlabel[PART_REST].pi_size = ptstart;
+	pm->bsdlabel[PART_REST].pi_offset = 0;
+	pm->bsdlabel[PART_REST].pi_size = pm->ptstart;
 #endif
 
 	/*
@@ -154,24 +154,24 @@ md_make_bsd_partitions(void)
 	 * partitions on a multiboot i386 system.
 	 */
 	 for (i = maxpart; i--;) {
-		if (bsdlabel[i].pi_size != 0)
+		if (pm->bsdlabel[i].pi_size != 0)
 			/* Don't overwrite special partitions */
 			continue;
-		p = &oldlabel[i];
+		p = &pm->oldlabel[i];
 		if (p->pi_fstype == FS_UNUSED || p->pi_size == 0)
 			continue;
 		if (layoutkind == 4) {
 			if (PI_ISBSDFS(p))
 				p->pi_flags |= PIF_MOUNT;
 		} else {
-			if (p->pi_offset < ptstart + ptsize &&
-			    p->pi_offset + p->pi_size > ptstart)
+			if (p->pi_offset < pm->ptstart + pm->ptsize &&
+			    p->pi_offset + p->pi_size > pm->ptstart)
 				/* Not outside area we are allocating */
 				continue;
 			if (p->pi_fstype == FS_SWAP)
 				no_swap = 1;
 		}
-		bsdlabel[i] = oldlabel[i];
+		pm->bsdlabel[i] = pm->oldlabel[i];
 	 }
 
 	if (layoutkind == 4) {
@@ -185,7 +185,7 @@ md_make_bsd_partitions(void)
 	 * edit it and verify it's OK, or abort altogether.
 	 */
  edit_check:
-	if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) {
+	if (edit_and_check_label(pm->bsdlabel, maxpart, part_raw, part_bsd) == 0) {
 		msg_display(MSG_abort);
 		return 0;
 	}
@@ -193,10 +193,10 @@ md_make_bsd_partitions(void)
 		goto edit_check;
 
 	/* Disk name */
-	msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname);
+	msg_prompt(MSG_packname, pm->bsddiskname, pm->bsddiskname, sizeof pm->bsddiskname);
 
 	/* save label to disk for MI code to update. */
-	(void)savenewlabel(bsdlabel, maxpart);
+	(void)savenewlabel(pm->bsdlabel, maxpart);
 
 	/* Everything looks OK. */
 	return 1;
@@ -215,7 +215,7 @@ md_check_partitions(void)
 	 * something stupid, like move it away from the MBR partition.
 	 */
 	for (part = PART_A; part < MAXPARTITIONS; part++)
-		if (bsdlabel[part].pi_fstype == FS_EX2FS) {
+		if (pm->bsdlabel[part].pi_fstype == FS_EX2FS) {
 			bootpart_ext2fs = part;
 			return 1;
 		}
@@ -234,7 +234,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -249,7 +249,7 @@ int
 md_post_disklabel(void)
 {
 	if (get_ramsize() <= 32)
-		set_swap(diskdev, bsdlabel);
+		set_swap(pm->diskdev, pm->bsdlabel);
 
 	return 0;
 }
@@ -273,7 +273,7 @@ md_post_newfs(void)
 	unsigned int i;
 
 	if (!nobootfs) {
-		msg_display(msg_string(MSG_copybootloader), diskdev);
+		msg_display(msg_string(MSG_copybootloader), pm->diskdev);
 
 		snprintf(bootdir, sizeof(bootdir), "%s/boot",
 		    target_expand(PART_BOOT_EXT2FS_PI_MOUNT));
@@ -311,9 +311,9 @@ md_pre_update(void)
 	int i;
 
 	if (get_ramsize() <= 32)
-		set_swap(diskdev, NULL);
+		set_swap(pm->diskdev, NULL);
 
-	read_mbr(diskdev, &mbr);
+	read_mbr(pm->diskdev, &mbr);
 	/* do a sanity check of the partition table */
 	for (ext = &mbr; ext; ext = ext->extended) {
 		part = ext->mbr.mbr_parts;
@@ -354,13 +354,13 @@ md_check_mbr(mbr_info_t *mbri)
 		part = ext->mbr.mbr_parts;
 		for (i = 0; i < MBR_PART_COUNT; part++, i++) {
 			if (part->mbrp_type == MBR_PTYPE_LNXEXT2) {
-				bootstart = part->mbrp_start;
-				bootsize = part->mbrp_size;
+				pm->bootstart = part->mbrp_start;
+				pm->bootsize = part->mbrp_size;
 				break;
 			}
 		}
 	}
-	if (bootsize < (MIN_EXT2FS_BOOT / 512)) {
+	if (pm->bootsize < (MIN_EXT2FS_BOOT / 512)) {
 		msg_display(MSG_boottoosmall);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -368,7 +368,7 @@ md_check_mbr(mbr_info_t *mbri)
 			return 0;
 		return 1;
 	}
-	if (bootstart == 0 || bootsize == 0) {
+	if (pm->bootstart == 0 || pm->bootsize == 0) {
 		msg_display(MSG_nobootpart);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -402,14 +402,14 @@ md_mbr_use_wholedisk(mbr_info_t *mbri)
 	part[0].mbrp_flag = MBR_PFLAG_ACTIVE;
 
 	part[1].mbrp_type = MBR_PTYPE_NETBSD;
-	part[1].mbrp_size = dlsize - (bsec + EXT2FS_BOOT_SIZE / 512);
+	part[1].mbrp_size = pm->dlsize - (bsec + EXT2FS_BOOT_SIZE / 512);
 	part[1].mbrp_start = bsec + EXT2FS_BOOT_SIZE / 512;
 	part[1].mbrp_flag = 0;
 
-	ptstart = part[1].mbrp_start;
-	ptsize = part[1].mbrp_size;
-	bootstart = part[0].mbrp_start;
-	bootsize = part[0].mbrp_size;
+	pm->ptstart = part[1].mbrp_start;
+	pm->ptsize = part[1].mbrp_size;
+	pm->bootstart = part[0].mbrp_start;
+	pm->bootsize = part[0].mbrp_size;
 	return 1;
 }
 
diff --git a/distrib/utils/sysinst/arch/emips/md.c b/distrib/utils/sysinst/arch/emips/md.c
index 4a9004b..fc6a514 100644
--- a/distrib/utils/sysinst/arch/emips/md.c
+++ b/distrib/utils/sysinst/arch/emips/md.c
@@ -62,11 +62,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -76,7 +76,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -87,21 +87,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
diff --git a/distrib/utils/sysinst/arch/evbarm/md.c b/distrib/utils/sysinst/arch/evbarm/md.c
index 8971717..f381f46 100644
--- a/distrib/utils/sysinst/arch/evbarm/md.c
+++ b/distrib/utils/sysinst/arch/evbarm/md.c
@@ -63,25 +63,25 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	if (no_mbr)
+	if (pm->no_mbr)
 		return 1;
 
-	if (read_mbr(diskdev, &mbr) < 0)
+	if (read_mbr(pm->diskdev, &mbr) < 0)
 		memset(&mbr.mbr, 0, sizeof(mbr.mbr)-2);
 
 	if (edit_mbr(&mbr) == 0)
 		return 0;
 
-	if (strncmp(diskdev, "wd", 2) == 0)
+	if (strncmp(pm->diskdev, "wd", 2) == 0)
 		disktype = "ST506";
 	else
 		disktype = "SCSI";
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -89,7 +89,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf(stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -97,21 +97,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -140,13 +140,13 @@ md_check_partitions(void)
 int
 md_pre_disklabel(void)
 {
-	if (no_mbr)
+	if (pm->no_mbr)
 		return 0;
 
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
diff --git a/distrib/utils/sysinst/arch/evbmips/md.c b/distrib/utils/sysinst/arch/evbmips/md.c
index a29e89a..841b0a7 100644
--- a/distrib/utils/sysinst/arch/evbmips/md.c
+++ b/distrib/utils/sysinst/arch/evbmips/md.c
@@ -85,13 +85,13 @@ md_check_partitions(void)
 int
 md_pre_disklabel(void)
 {
-	if (no_mbr)
+	if (pm->no_mbr)
 		return 0;
 
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
diff --git a/distrib/utils/sysinst/arch/evbppc/md.c b/distrib/utils/sysinst/arch/evbppc/md.c
index 9006c2d..b60eb35 100644
--- a/distrib/utils/sysinst/arch/evbppc/md.c
+++ b/distrib/utils/sysinst/arch/evbppc/md.c
@@ -88,7 +88,7 @@ md_pre_disklabel(void)
 	printf ("%s", msg_string (MSG_dofdisk));
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -106,7 +106,7 @@ md_post_disklabel(void)
 	if (*doessf) {
 		printf ("%s", msg_string (MSG_dobad144));
 		return run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0",
-		    diskdev);
+		    pm->diskdev);
 	}
 	return 0;
 }
diff --git a/distrib/utils/sysinst/arch/evbsh3/md.c b/distrib/utils/sysinst/arch/evbsh3/md.c
index 6edfcda..d858a3c 100644
--- a/distrib/utils/sysinst/arch/evbsh3/md.c
+++ b/distrib/utils/sysinst/arch/evbsh3/md.c
@@ -51,11 +51,11 @@
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
+	snprintf(dev_name, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -63,7 +63,7 @@ md_get_info(void)
 		fprintf (stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -71,21 +71,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl * dlhead * dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl * pm->dlhead * pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
diff --git a/distrib/utils/sysinst/arch/evbsh3/md.h b/distrib/utils/sysinst/arch/evbsh3/md.h
index 7182e72..9c8947a 100644
--- a/distrib/utils/sysinst/arch/evbsh3/md.h
+++ b/distrib/utils/sysinst/arch/evbsh3/md.h
@@ -36,7 +36,7 @@
 /*
  * Symbolic names for disk partitions
  */
-#include <machine/disklabel.h>
+#include <machine/pm->disklabel.h>
 
 #define	PART_ROOT	PART_A
 #define	PART_SWAP	PART_B
diff --git a/distrib/utils/sysinst/arch/ews4800mips/md.c b/distrib/utils/sysinst/arch/ews4800mips/md.c
index 170a62a..a77bb43 100644
--- a/distrib/utils/sysinst/arch/ews4800mips/md.c
+++ b/distrib/utils/sysinst/arch/ews4800mips/md.c
@@ -65,11 +65,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
+	snprintf(dev_name, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -77,7 +77,7 @@ md_get_info(void)
 		fprintf (stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -85,21 +85,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl * dlhead * dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl * pm->dlhead * pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -129,7 +129,7 @@ md_check_partitions(void)
 int
 md_pre_disklabel(void)
 {
-	bsdlabel[PART_BOOT].pi_offset = ews4800mips_boot_offset();
+	pm->bsdlabel[PART_BOOT].pi_offset = ews4800mips_boot_offset();
 
 	return 0;
 }
@@ -158,7 +158,7 @@ md_post_newfs(void)
 	flags = RUN_DISPLAY | RUN_FATAL;
 	cp_to_target("/usr/mdec/boot", "/stand/boot");
 	run_program(flags, "/usr/sbin/installboot /dev/r%s%c %s",
-	    diskdev, 'a' + getrawpartition(),
+	    pm->diskdev, 'a' + getrawpartition(),
 	    "/usr/mdec/bootxx_bfs");
 
 	return 0;
@@ -195,7 +195,7 @@ md_update(void)
 static int
 ews4800mips_boot_offset(void)
 {
-	return dlcylsize;
+	return pm->dlcylsize;
 }
 
 /*
@@ -207,12 +207,12 @@ ews4800mips_boot_size(void)
 	int i;
 
 	/*
-	 * dlcylsize	: PDINFO block
-	 * dlcylsize	: 100 block
+	 * pm->dlcylsize	: PDINFO block
+	 * pm->dlcylsize	: 100 block
 	 */
-	i = dlcylsize + 100;
+	i = pm->dlcylsize + 100;
 	if (i >= 1024) /* XXX bsddisklabel.c hack. convert to byte count. */
-		i = dlcylsize * sectorsize * 2;
+		i = pm->dlcylsize * pm->sectorsize * 2;
 
 	return i;
 }
diff --git a/distrib/utils/sysinst/arch/hp300/md.c b/distrib/utils/sysinst/arch/hp300/md.c
index 9878885..ff3d6c6 100644
--- a/distrib/utils/sysinst/arch/hp300/md.c
+++ b/distrib/utils/sysinst/arch/hp300/md.c
@@ -64,9 +64,9 @@ md_get_info(void)
 	char buf[1024];
 	int fd;
 	char dev_name[100];
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 
-	snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
+	snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -76,7 +76,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -85,19 +85,19 @@ md_get_info(void)
 		close(fd);
 		exit(1);
 	}
-	if (disklabel.d_secsize != 512) {
+	if (pm->disklabel.d_secsize != 512) {
 		endwin();
 		fprintf(stderr, "Non-512byte/sector disk is not supported.\n");
 		close(fd);
 		exit(1);
 	}
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
-	dlsize = dlcyl*dlhead*dlsec;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
 
 	if (read(fd, buf, 1024) < 0) {
 		endwin();
@@ -107,7 +107,7 @@ md_get_info(void)
 	}
 
 	/* We will preserve the first cylinder as PART_BOOT for bootloader. */
-	ptstart = 0;
+	pm->ptstart = 0;
 
 	close(fd);
 
@@ -139,22 +139,22 @@ md_check_partitions(void)
 	for (part = PART_A; part < MAXPARTITIONS; part++) {
 		if (part == PART_RAW || part == PART_BOOT)
 			continue;
-		if (last >= PART_A && bsdlabel[part].pi_size > 0) {
+		if (last >= PART_A && pm->bsdlabel[part].pi_size > 0) {
 			msg_display(MSG_emptypart, part+'a');
 			process_menu(MENU_ok, NULL);
 			return 0;
 		}
-		if (bsdlabel[part].pi_size == 0) {
+		if (pm->bsdlabel[part].pi_size == 0) {
 			if (last < PART_A)
 				last = part;
 		} else {
-			if (start >= bsdlabel[part].pi_offset) {
+			if (start >= pm->bsdlabel[part].pi_offset) {
 				msg_display(MSG_ordering, part+'a');
 				process_menu(MENU_yesno, NULL);
 				if (yesno)
 					return 0;
 			}
-			start = bsdlabel[part].pi_offset;
+			start = pm->bsdlabel[part].pi_offset;
 		}
 	}
 
@@ -177,7 +177,7 @@ int
 md_post_disklabel(void)
 {
 	if (get_ramsize() < 6)
-		set_swap(diskdev, bsdlabel);
+		set_swap(pm->diskdev, pm->bsdlabel);
 
 	return 0;
 }
@@ -193,9 +193,9 @@ int
 md_post_newfs(void)
 {
 	/* boot blocks ... */
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
-	    "/usr/sbin/installboot /dev/r%sc /usr/mdec/uboot.lif", diskdev))
+	    "/usr/sbin/installboot /dev/r%sc /usr/mdec/uboot.lif", pm->diskdev))
 		process_menu(MENU_ok,
 		    deconst("Warning: disk is probably not bootable"));
 	return 0;
@@ -219,7 +219,7 @@ int
 md_pre_update(void)
 {
 	if (get_ramsize() < 6)
-		set_swap(diskdev, NULL);
+		set_swap(pm->diskdev, NULL);
 	return 1;
 }
 
@@ -239,9 +239,9 @@ hp300_boot_size(void)
 {
 	int i;
 
-	i = dlcylsize;
+	i = pm->dlcylsize;
 	if (i >= 1024) /* XXX: bsddisklabel.c has a hack. */
-		i = dlcylsize * sectorsize * 2;
+		i = pm->dlcylsize * pm->sectorsize * 2;
 
 	return i;
 }
diff --git a/distrib/utils/sysinst/arch/hp700/md.c b/distrib/utils/sysinst/arch/hp700/md.c
index ef52b11..17ebd2e 100644
--- a/distrib/utils/sysinst/arch/hp700/md.c
+++ b/distrib/utils/sysinst/arch/hp700/md.c
@@ -66,11 +66,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -80,7 +80,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -91,26 +91,26 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	/*
 	 * hp700 PDC can only address up to 2GB.
 	 */
-	root_limit = HP700_PDC_LIMIT / (unsigned)sectorsize;
+	root_limit = HP700_PDC_LIMIT / (unsigned)pm->sectorsize;
 
 	return 1;
 }
@@ -131,13 +131,13 @@ int
 md_check_partitions(void)
 {
 	/* Check the root partition is sane. */
-	uint32_t limit = HP700_PDC_LIMIT / (unsigned)sectorsize;
+	uint32_t limit = HP700_PDC_LIMIT / (unsigned)pm->sectorsize;
 	int part;
 
 	for (part = PART_A; part < MAXPARTITIONS; part++) {
-		if (strcmp(bsdlabel[part].pi_mount, "/") == 0) {
-			uint32_t offset = bsdlabel[part].pi_offset;
-			uint32_t size = bsdlabel[part].pi_size;
+		if (strcmp(pm->bsdlabel[part].pi_mount, "/") == 0) {
+			uint32_t offset = pm->bsdlabel[part].pi_offset;
+			uint32_t size = pm->bsdlabel[part].pi_size;
 
 			if (offset > limit || offset + size > limit) {
 				msg_display(MSG_md_pdclimit);
@@ -183,10 +183,10 @@ md_post_newfs(void)
 		return error;
 
 	/* boot blocks ... */
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
 	    "/usr/sbin/installboot -v /dev/r%sc /usr/mdec/xxboot",
-	    diskdev))
+	    pm->diskdev))
 		process_menu(MENU_ok,
 			 deconst("Warning: disk is probably not bootable"));
 	return 0;
diff --git a/distrib/utils/sysinst/arch/hpcarm/md.c b/distrib/utils/sysinst/arch/hpcarm/md.c
index 1e1b3c6..628a48c 100644
--- a/distrib/utils/sysinst/arch/hpcarm/md.c
+++ b/distrib/utils/sysinst/arch/hpcarm/md.c
@@ -117,7 +117,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -135,7 +135,7 @@ md_post_disklabel(void)
 	if (*doessf) {
 		msg_display(MSG_dobad144);
 		return run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0",
-		    diskdev);
+		    pm->diskdev);
 	}
 	return 0;
 }
@@ -153,7 +153,7 @@ md_post_newfs(void)
 	ssize_t sz;
 	int fd = -1;
 
-	snprintf(adevname, sizeof(adevname), "/dev/r%sa", diskdev);
+	snprintf(adevname, sizeof(adevname), "/dev/r%sa", pm->diskdev);
 	fd = open(adevname, O_RDWR);
 	if (fd < 0)
 		goto out;
diff --git a/distrib/utils/sysinst/arch/hpcmips/md.c b/distrib/utils/sysinst/arch/hpcmips/md.c
index 0d2ef06..cbdd705 100644
--- a/distrib/utils/sysinst/arch/hpcmips/md.c
+++ b/distrib/utils/sysinst/arch/hpcmips/md.c
@@ -91,7 +91,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -109,7 +109,7 @@ md_post_disklabel(void)
 	if (*doessf) {
 		msg_display(MSG_dobad144);
 		return run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0",
-		    diskdev);
+		    pm->diskdev);
 	}
 	return 0;
 }
diff --git a/distrib/utils/sysinst/arch/hpcsh/md.c b/distrib/utils/sysinst/arch/hpcsh/md.c
index 0d76194..286ce20 100644
--- a/distrib/utils/sysinst/arch/hpcsh/md.c
+++ b/distrib/utils/sysinst/arch/hpcsh/md.c
@@ -96,7 +96,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
diff --git a/distrib/utils/sysinst/arch/i386/md.c b/distrib/utils/sysinst/arch/i386/md.c
index 291594b..4b51cb90 100644
--- a/distrib/utils/sysinst/arch/i386/md.c
+++ b/distrib/utils/sysinst/arch/i386/md.c
@@ -94,12 +94,12 @@ md_get_info(void)
 #define	NETBSD_NAMED	0x0400
 #define	ACTIVE_NAMED	0x0800
 
-	if (no_mbr)
+	if (pm->no_mbr)
 		return 1;
 
-	if (read_mbr(diskdev, &mbr) < 0)
+	if (read_mbr(pm->diskdev, &mbr) < 0)
 		memset(&mbr.mbr, 0, sizeof mbr.mbr - 2);
-	get_bios_info(diskdev);
+	get_bios_info(pm->diskdev);
 
 edit:
 	if (edit_mbr(&mbr) == 0)
@@ -118,7 +118,7 @@ edit:
 	}
 
 	/*
-	 * Ensure the install partition (at sector ptstart) and the active
+	 * Ensure the install partition (at sector pm->ptstart) and the active
 	 * partition are bootable.
 	 * Determine whether the bootselect code is needed.
 	 * Note that MBR_BS_NEWMBR is always set, so we ignore it!
@@ -130,14 +130,14 @@ edit:
 		for (i = 0; i < MBR_PART_COUNT; p++, i++) {
 			if (p->mbrp_flag == MBR_PFLAG_ACTIVE) {
 				fl |= ACTIVE_FOUND;
-			    if (ext->sector + p->mbrp_start == ptstart)
+			    if (ext->sector + p->mbrp_start == pm->ptstart)
 				fl |= NETBSD_ACTIVE;
 			}
 			if (ext->mbrb.mbrbs_nametab[i][0] == 0) {
 				/* No bootmenu label... */
 				if (ext->sector == 0)
 					continue;
-				if (ext->sector + p->mbrp_start == ptstart)
+				if (ext->sector + p->mbrp_start == pm->ptstart)
 					/*
 					 * Have installed into an extended ptn
 					 * force name & bootsel...
@@ -148,7 +148,7 @@ edit:
 			/* Partition has a bootmenu label... */
 			if (ext->sector != 0)
 				fl |= MBR_BS_EXTLBA;
-			if (ext->sector + p->mbrp_start == ptstart)
+			if (ext->sector + p->mbrp_start == pm->ptstart)
 				fl |= NETBSD_NAMED;
 			else if (p->mbrp_flag == MBR_PFLAG_ACTIVE)
 				fl |= ACTIVE_NAMED;
@@ -264,13 +264,13 @@ md_check_partitions(void)
 int
 md_pre_disklabel(void)
 {
-	if (no_mbr)
+	if (pm->no_mbr)
 		return 0;
 
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -285,7 +285,7 @@ int
 md_post_disklabel(void)
 {
 	if (get_ramsize() <= 32)
-		set_swap(diskdev, bsdlabel);
+		set_swap(pm->diskdev, pm->bsdlabel);
 
 	return 0;
 }
@@ -330,7 +330,7 @@ md_post_newfs(void)
 	}
 
 	process_menu(MENU_getboottype, &boottype);
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	if (bp.bp_consdev == ~0u)
 		return 0;
 
@@ -341,7 +341,7 @@ md_post_newfs(void)
 	/* Copy bootstrap in by hand - /sbin/installboot explodes ramdisks */
 	ret = 1;
 
-	snprintf(bootxx, sizeof bootxx, "/dev/r%s%c", diskdev, 'a' + rootpart);
+	snprintf(bootxx, sizeof bootxx, "/dev/r%s%c", pm->diskdev, 'a' + rootpart);
 	td = open(bootxx, O_RDWR, 0);
 	bootxx_filename = bootxx_name();
 	if (bootxx_filename != NULL) {
@@ -410,7 +410,7 @@ int
 md_pre_update(void)
 {
 	if (get_ramsize() <= 8)
-		set_swap(diskdev, NULL);
+		set_swap(pm->diskdev, NULL);
 	return 1;
 }
 
@@ -468,7 +468,7 @@ get_bios_info(char *dev)
 	if (nip == NULL || nip->ni_nmatches == 0) {
 nogeom:
 		if (nip != NULL)
-			msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
+			msg_display(MSG_nobiosgeom, pm->dlcyl, pm->dlhead, pm->dlsec);
 		if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0
 		    && nip != NULL)
 			msg_display_add(MSG_biosguess, cyl, head, sec);
@@ -524,7 +524,7 @@ nogeom:
 static int
 mbr_root_above_chs(void)
 {
-	return ptstart + DEFROOTSIZE * (MEG / 512) >= bcyl * bhead * bsec;
+	return pm->ptstart + DEFROOTSIZE * (MEG / 512) >= bcyl * bhead * bsec;
 }
 
 static void
@@ -533,10 +533,10 @@ md_upgrade_mbrtype(void)
 	struct mbr_partition *mbrp;
 	int i, netbsdpart = -1, oldbsdpart = -1, oldbsdcount = 0;
 
-	if (no_mbr)
+	if (pm->no_mbr)
 		return;
 
-	if (read_mbr(diskdev, &mbr) < 0)
+	if (read_mbr(pm->diskdev, &mbr) < 0)
 		return;
 
 	mbrp = &mbr.mbr.mbr_parts[0];
@@ -551,7 +551,7 @@ md_upgrade_mbrtype(void)
 
 	if (netbsdpart == -1 && oldbsdcount == 1) {
 		mbrp[oldbsdpart].mbrp_type = MBR_PTYPE_NETBSD;
-		write_mbr(diskdev, &mbr, 0);
+		write_mbr(pm->diskdev, &mbr, 0);
 	}
 }
 
diff --git a/distrib/utils/sysinst/arch/i386/md.h b/distrib/utils/sysinst/arch/i386/md.h
index d99f4e3..ee1adfa 100644
--- a/distrib/utils/sysinst/arch/i386/md.h
+++ b/distrib/utils/sysinst/arch/i386/md.h
@@ -84,7 +84,7 @@
  * On i386, we allow "wd"  ST-506/IDE disks,  "sd" scsi disks, "ld" logical
  * disks, "ed" IBM ESDI disks, "raid" raidframe disks
  */
-#define DISK_NAMES "wd", "sd", "ld", "ed", "raid:no_mbr", "xbd:no_mbr"
+#define DISK_NAMES "wd", "sd", "ld", "ed", "raid:pm->no_mbr", "xbd:pm->no_mbr"
 
 /*
  * Machine-specific command to write a new label to a disk.
diff --git a/distrib/utils/sysinst/arch/landisk/md.c b/distrib/utils/sysinst/arch/landisk/md.c
index da86bd2..f1ffa64 100644
--- a/distrib/utils/sysinst/arch/landisk/md.c
+++ b/distrib/utils/sysinst/arch/landisk/md.c
@@ -85,15 +85,15 @@ md_check_partitions(void)
 int
 md_pre_disklabel(void)
 {
-	if (no_mbr)
+	if (pm->no_mbr)
 		return 0;
 
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0 ||
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0 ||
 	    run_program(RUN_SILENT | RUN_ERROR_OK,
-	    "/sbin/fdisk -f -i -c /usr/mdec/mbr %s", diskdev)) {
+	    "/sbin/fdisk -f -i -c /usr/mdec/mbr %s", pm->diskdev)) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -124,12 +124,12 @@ md_post_newfs(void)
 	char *bootxx;
 	int error;
 
-	printf (msg_string(MSG_dobootblks), diskdev);
+	printf (msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot", "/boot");
 	bootxx = bootxx_name();
 	if (bootxx != NULL) {
 		error = run_program(RUN_DISPLAY | RUN_NO_CLEAR,
-		    "/usr/sbin/installboot -v /dev/r%sa %s", diskdev, bootxx);
+		    "/usr/sbin/installboot -v /dev/r%sa %s", pm->diskdev, bootxx);
 		free(bootxx);
 	} else
 		error = -1;
diff --git a/distrib/utils/sysinst/arch/luna68k/md.c b/distrib/utils/sysinst/arch/luna68k/md.c
index 42cb144..7e52b20 100644
--- a/distrib/utils/sysinst/arch/luna68k/md.c
+++ b/distrib/utils/sysinst/arch/luna68k/md.c
@@ -64,11 +64,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
+	snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -76,7 +76,7 @@ md_get_info(void)
 		fprintf (stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -84,21 +84,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl * dlhead * dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl * pm->dlhead * pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -156,11 +156,11 @@ md_post_newfs(void)
 #if 0	/* no bootloader (yet) */
 	const char *bootfile = "/boot";
 
-	printf(msg_string(MSG_dobootblks), diskdev);
+	printf(msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot", bootfile);
 	sync();
 	run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sc %s %s",
-	    diskdev, "/usr/mdec/bootxx", bootfile);
+	    pm->diskdev, "/usr/mdec/bootxx", bootfile);
 #endif
 	return 0;
 }
diff --git a/distrib/utils/sysinst/arch/mac68k/md.c b/distrib/utils/sysinst/arch/mac68k/md.c
index f47052d..20119eb 100644
--- a/distrib/utils/sysinst/arch/mac68k/md.c
+++ b/distrib/utils/sysinst/arch/mac68k/md.c
@@ -134,13 +134,13 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd, i;
 	char dev_name[100];
 	struct apple_part_map_entry block;
 
 	snprintf(dev_name, sizeof(dev_name), "/dev/r%s%c",
-		diskdev, 'a' + getrawpartition());
+		pm->diskdev, 'a' + getrawpartition());
 
 	/*
 	 * Open the disk as a raw device
@@ -154,7 +154,7 @@ md_get_info(void)
 	/*
 	 * Try to get the default disklabel info for the device
 	 */
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s\n", dev_name);
 		close(fd);
@@ -164,30 +164,30 @@ md_get_info(void)
 	 * Get the disk parameters from the disk driver.  It should have
 	 *  obained them by querying the disk itself.
 	 */
-	blk_size = disklabel.d_secsize;
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
+	blk_size = pm->disklabel.d_secsize;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
 	/*
 	 * Just in case, initialize the structures we'll need if we
 	 *  need to completely initialize the disk.
 	 */
-	dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->disklabel.d_secperunit;
 	for (i=0;i<NEW_MAP_SIZE;i++) {
 	   if (i > 0)
 		new_map[i].pmPyPartStart = new_map[i-1].pmPyPartStart +
 			new_map[i-1].pmPartBlkCnt;
 	   new_map[i].pmDataCnt = new_map[i].pmPartBlkCnt;
 	   if (new_map[i].pmPartBlkCnt == 0) {
-		new_map[i].pmPartBlkCnt = dlsize;
-		new_map[i].pmDataCnt = dlsize;
+		new_map[i].pmPartBlkCnt = pm->dlsize;
+		new_map[i].pmDataCnt = pm->dlsize;
 		break;
 	   }
-	   dlsize -= new_map[i].pmPartBlkCnt;
+	   pm->dlsize -= new_map[i].pmPartBlkCnt;
 	}
-	dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->disklabel.d_secperunit;
 #if 0
-	msg_display(MSG_dldebug, blk_size, dlcyl, dlhead, dlsec, dlsize);
+	msg_display(MSG_dldebug, blk_size, pm->dlcyl, pm->dlhead, pm->dlsec, pm->dlsize);
 	process_menu(MENU_ok, NULL);
 #endif
 	map.size = 0;
@@ -223,7 +223,7 @@ md_get_info(void)
 	/*
 	 * Setup the disktype so /etc/disktab gets proper info
 	 */
-	if (strncmp(diskdev, "sd", 2) == 0) {
+	if (strncmp(pm->diskdev, "sd", 2) == 0) {
 		disktype = "SCSI";
 		doessf = "sf:";
 	} else
@@ -261,16 +261,16 @@ md_make_bsd_partitions(void)
 	}
 
 	/* Build standard partitions */
-	memset(&bsdlabel, 0, sizeof bsdlabel);
+	memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);
 
 	/*
 	 * The mac68k port has a predefined partition for "c" which
 	 *  is the size of the disk, everything else is unused.
 	 */
-	bsdlabel[RAW_PART].pi_size = dlsize;
+	pm->bsdlabel[RAW_PART].pi_size = pm->dlsize;
 	/*
 	 * Now, scan through the Disk Partition Map and transfer the
-	 *  information into the incore disklabel.
+	 *  information into the incore pm->disklabel.
 	 */
 	for (i=0;i<map.usable_cnt;i++) {
 	    j = map.mblk[i];
@@ -279,37 +279,37 @@ md_make_bsd_partitions(void)
 		pl = bzb->flags.part - 'a';
 		switch (whichType(&map.blk[j])) {
 		    case HFS_PART:
-			bsdlabel[pl].pi_fstype = FS_HFS;
-			strcpy (bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
+			pm->bsdlabel[pl].pi_fstype = FS_HFS;
+			strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
 			break;
 		    case ROOT_PART:
 		    case UFS_PART:
-			bsdlabel[pl].pi_fstype = FS_BSDFFS;
-			strcpy (bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
-			bsdlabel[pl].pi_flags |= PIF_NEWFS | PIF_MOUNT;
+			pm->bsdlabel[pl].pi_fstype = FS_BSDFFS;
+			strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
+			pm->bsdlabel[pl].pi_flags |= PIF_NEWFS | PIF_MOUNT;
 			break;
 		    case SWAP_PART:
-			bsdlabel[pl].pi_fstype = FS_SWAP;
+			pm->bsdlabel[pl].pi_fstype = FS_SWAP;
 			break;
 		    case SCRATCH_PART:
-			bsdlabel[pl].pi_fstype = FS_OTHER;
-			strcpy (bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
+			pm->bsdlabel[pl].pi_fstype = FS_OTHER;
+			strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
 		    default:
 			break;
 		}
-	        if (bsdlabel[pl].pi_fstype != FS_UNUSED) {
-		    bsdlabel[pl].pi_size = map.blk[j].pmPartBlkCnt;
-		    bsdlabel[pl].pi_offset = map.blk[j].pmPyPartStart;
-		    if (bsdlabel[pl].pi_fstype != FS_SWAP) {
-		        bsdlabel[pl].pi_frag = 8;
-		        bsdlabel[pl].pi_fsize = 1024;
+	        if (pm->bsdlabel[pl].pi_fstype != FS_UNUSED) {
+		    pm->bsdlabel[pl].pi_size = map.blk[j].pmPartBlkCnt;
+		    pm->bsdlabel[pl].pi_offset = map.blk[j].pmPyPartStart;
+		    if (pm->bsdlabel[pl].pi_fstype != FS_SWAP) {
+		        pm->bsdlabel[pl].pi_frag = 8;
+		        pm->bsdlabel[pl].pi_fsize = 1024;
 		    }
 		}
 	    }
 	}
 
 	/* Disk name  - don't bother asking, just use the physical name*/
-	strcpy (bsddiskname, diskdev);
+	strcpy (pm->bsddiskname, pm->diskdev);
 
 #ifdef DEBUG
 	f = fopen ("/tmp/disktab", "w");
@@ -321,26 +321,26 @@ md_make_bsd_partitions(void)
 		(void) fprintf (stderr, "Could not open /etc/disktab");
 		exit (1);
 	}
-	(void)fprintf (f, "%s|NetBSD installation generated:\\\n", bsddiskname);
+	(void)fprintf (f, "%s|NetBSD installation generated:\\\n", pm->bsddiskname);
 	(void)fprintf (f, "\t:dt=%s:ty=winchester:\\\n", disktype);
-	(void)fprintf (f, "\t:nc#%d:nt#%d:ns#%d:\\\n", dlcyl, dlhead, dlsec);
-	(void)fprintf (f, "\t:sc#%d:su#%" PRIu32 ":\\\n", dlhead*dlsec, (uint32_t)dlsize);
+	(void)fprintf (f, "\t:nc#%d:nt#%d:ns#%d:\\\n", pm->dlcyl, pm->dlhead, pm->dlsec);
+	(void)fprintf (f, "\t:sc#%d:su#%" PRIu32 ":\\\n", pm->dlhead*pm->dlsec, (uint32_t)pm->dlsize);
 	(void)fprintf (f, "\t:se#%d:%s\\\n", blk_size, doessf);
 	for (i=0; i<8; i++) {
-		if (bsdlabel[i].pi_fstype == FS_HFS)
+		if (pm->bsdlabel[i].pi_fstype == FS_HFS)
 		    (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=macos:",
-			       'a'+i, bsdlabel[i].pi_size,
-			       'a'+i, bsdlabel[i].pi_offset,
+			       'a'+i, pm->bsdlabel[i].pi_size,
+			       'a'+i, pm->bsdlabel[i].pi_offset,
 			       'a'+i);
 		else
 		    (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=%s:",
-			       'a'+i, bsdlabel[i].pi_size,
-			       'a'+i, bsdlabel[i].pi_offset,
-			       'a'+i, getfslabelname(bsdlabel[i].pi_fstype));
-		if (bsdlabel[i].pi_fstype == FS_BSDFFS)
+			       'a'+i, pm->bsdlabel[i].pi_size,
+			       'a'+i, pm->bsdlabel[i].pi_offset,
+			       'a'+i, getfslabelname(pm->bsdlabel[i].pi_fstype));
+		if (pm->bsdlabel[i].pi_fstype == FS_BSDFFS)
 			(void)fprintf (f, "b%c#%d:f%c#%d",
-			   'a'+i, bsdlabel[i].pi_fsize * bsdlabel[i].pi_frag,
-			   'a'+i, bsdlabel[i].pi_fsize);
+			   'a'+i, pm->bsdlabel[i].pi_fsize * pm->bsdlabel[i].pi_frag,
+			   'a'+i, pm->bsdlabel[i].pi_fsize);
 		if (i < 7)
 			(void)fprintf (f, "\\\n");
 		else
@@ -369,7 +369,7 @@ md_pre_disklabel(void)
 {
     int fd;
     char dev_name[100];
-    struct disklabel lp;
+    struct pm->disklabel lp;
     Block0 new_block0 = {APPLE_DRVR_MAP_MAGIC, 512,
 	 		 0, 0, 0, 0, 0, 0, 0, 0, {0}};
 
@@ -379,7 +379,7 @@ md_pre_disklabel(void)
      */
     printf ("%s", msg_string (MSG_dodiskmap));
 
-    snprintf (dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
+    snprintf (dev_name, sizeof(dev_name), "/dev/r%sc", pm->diskdev);
     /*
      * Open the disk as a raw device
      */
@@ -400,7 +400,7 @@ md_pre_disklabel(void)
 	    close (fd);
 	    exit (1);
 	}
-	new_block0.sbBlkCount = dlsize;		/* Set disk size */
+	new_block0.sbBlkCount = pm->dlsize;		/* Set disk size */
 	if (write (fd, &new_block0, blk_size) != blk_size) {
 	    endwin();
 	    fprintf (stderr, "I/O error writing Block0\n");
@@ -429,7 +429,7 @@ md_pre_disklabel(void)
      * should be done by disklabel -- which is normally called right after
      * we return -- but may be commented out for the mac68k port. We'll
      * instead update the incore table by forcing a dummy write here. This
-     * relies on a change in the mac68k-specific writedisklabel() routine.
+     * relies on a change in the mac68k-specific write_disklabel() routine.
      * If that change doesn't exist nothing bad happens here. If disklabel
      * properly updates the ondisk and incore labels everything still
      * works. Only if we fail here and if disklabel fails are we in
@@ -457,7 +457,7 @@ md_pre_disklabel(void)
 int
 md_post_disklabel(void)
 {
-    struct disklabel updated_label;
+    struct pm->disklabel updated_label;
     int fd, i, no_match;
     char dev_name[100], buf[80];
     const char *fst[] = {"free", "swap", " v6 ", " v7 ", "sysv", "v71k",
@@ -465,7 +465,7 @@ md_post_disklabel(void)
 			"9660", "boot", "ados", "hfs ", "fcor", "ex2f",
 			"ntfs", "raid", "ccd "};
 
-    snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
+    snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", pm->diskdev);
     /*
      * Open the disk as a raw device
      */
@@ -484,12 +484,12 @@ md_post_disklabel(void)
     for (i=0;i<MAXPARTITIONS;i++) {
         if (i > updated_label.d_npartitions)
            break;
-        if (bsdlabel[i].pi_size != updated_label.d_partitions[i].p_size)
+        if (pm->bsdlabel[i].pi_size != updated_label.d_partitions[i].p_size)
            no_match = 1;
-        if (bsdlabel[i].pi_size) {
-           if (bsdlabel[i].pi_offset != updated_label.d_partitions[i].p_offset)
+        if (pm->bsdlabel[i].pi_size) {
+           if (pm->bsdlabel[i].pi_offset != updated_label.d_partitions[i].p_offset)
                no_match = 1;
-           if (bsdlabel[i].pi_fstype != updated_label.d_partitions[i].p_fstype)
+           if (pm->bsdlabel[i].pi_fstype != updated_label.d_partitions[i].p_fstype)
                no_match = 1;
         }
         if (no_match)
@@ -505,8 +505,8 @@ md_post_disklabel(void)
            " in-core: offset      size type on-disk: offset      size type");
        for (i=0;i<MAXPARTITIONS;i++) {
            sprintf(buf, " %c:%13.8x%10.8x%5s%16.8x%10.8x%5s", i+'a',
-              bsdlabel[i].pi_offset, bsdlabel[i].pi_size,
-              fst[bsdlabel[i].pi_fstype],
+              pm->bsdlabel[i].pi_offset, pm->bsdlabel[i].pi_size,
+              fst[pm->bsdlabel[i].pi_fstype],
               updated_label.d_partitions[i].p_offset,
               updated_label.d_partitions[i].p_size,
               fst[updated_label.d_partitions[i].p_fstype]);
@@ -759,7 +759,7 @@ getName(part, len_name, name)
 		/*
 		 * OK, this is stupid but it's damn nice to know!
 		 */
-		snprintf (dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
+		snprintf (dev_name, sizeof(dev_name), "/dev/r%sc", pm->diskdev);
 		/*
 		 * Open the disk as a raw device
 		 */
@@ -1048,7 +1048,7 @@ disp_selected_part(sel)
 	    getUse(&map.blk[j], sizeof(use), use);
 	    getName(&map.blk[j], sizeof(name), name);
 	    bzb = (EBZB *)&map.blk[j].pmBootArgs[0];
-	    msg_table_add(MSG_part_row, diskdev,
+	    msg_table_add(MSG_part_row, pm->diskdev,
 		bzb->flags.part, map.blk[j].pmPyPartStart,
                  map.blk[j].pmPartBlkCnt, fstyp, use, name);
 	    if (i == sel) msg_standend();
@@ -1070,9 +1070,9 @@ check_for_errors()
 
     for (i=0;i<map.usable_cnt;i++) {
 	j = map.mblk[i];
-	if (map.blk[j].pmPyPartStart > dlsize)
+	if (map.blk[j].pmPyPartStart > pm->dlsize)
 		errs++;
-	if ((map.blk[j].pmPyPartStart + map.blk[j].pmPartBlkCnt) > dlsize + 1)
+	if ((map.blk[j].pmPyPartStart + map.blk[j].pmPartBlkCnt) > pm->dlsize + 1)
 		errs++;
     }
     return(errs);
@@ -1106,16 +1106,16 @@ report_errors()
     }
     for (i=0;i<map.usable_cnt;i++) {
 	j = map.mblk[i];
-	if (map.blk[j].pmPyPartStart > dlsize) {
+	if (map.blk[j].pmPyPartStart > pm->dlsize) {
 	    bzb = (EBZB *)&map.blk[j].pmBootArgs[0];
 	    msg_display_add(MSG_disksetup_part_beginning,
-		diskdev, bzb->flags.part);
+		pm->diskdev, bzb->flags.part);
 	    errs++;
 	}
-	if ((map.blk[j].pmPyPartStart + map.blk[j].pmPartBlkCnt) > dlsize) {
+	if ((map.blk[j].pmPyPartStart + map.blk[j].pmPartBlkCnt) > pm->dlsize) {
 	    bzb = (EBZB *)&map.blk[j].pmBootArgs[0];
 	    msg_display_add(MSG_disksetup_part_size,
-		diskdev, bzb->flags.part);
+		pm->diskdev, bzb->flags.part);
 	    errs++;
 	}
     }
@@ -1130,7 +1130,7 @@ edit_diskmap(void)
     int i;
 
 	/* Ask full/part */
-	msg_display (MSG_fullpart, diskdev);
+	msg_display (MSG_fullpart, pm->diskdev);
 	process_menu (MENU_fullpart, NULL);
 
 	map.selected = 0;
diff --git a/distrib/utils/sysinst/arch/mac68k/menus.md.de b/distrib/utils/sysinst/arch/mac68k/menus.md.de
index 5164dad..79830b0 100644
--- a/distrib/utils/sysinst/arch/mac68k/menus.md.de
+++ b/distrib/utils/sysinst/arch/mac68k/menus.md.de
@@ -39,7 +39,7 @@ menu fullpart, title  "Bitte w
 	option "Die ganze Festplatte für NetBSD verwenden", exit, action  {usefull = 1;};
 
 menu nodiskmap, title "Bitte wählen Sie", y=16;
-	display action { msg_display (MSG_nodiskmap, diskdev); };
+	display action { msg_display (MSG_nodiskmap, pm->diskdev); };
 	option "Installation abbrechen", exit, action {
 		endwin();  exit(1);
 	};
@@ -99,9 +99,9 @@ menu editparttable, title  "W
 			bzb->mount_point[0] = '\0';
 			strcpy (map.blk[k].pmPartType, "Apple_Free");
 			map.blk[k].pmPyPartStart += size;
-			if ((map.blk[k].pmPyPartStart + free_size) > dlsize)
+			if ((map.blk[k].pmPyPartStart + free_size) > pm->dlsize)
 			    map.blk[k].pmPartBlkCnt =
-				dlsize - map.blk[k].pmPyPartStart;
+				pm->dlsize - map.blk[k].pmPyPartStart;
 			else
 			    map.blk[k].pmPartBlkCnt = free_size;
 			map.blk[k].pmDataCnt = map.blk[k].pmPartBlkCnt;
@@ -129,20 +129,20 @@ menu editparttable, title  "W
 	option "Partition korrigieren", action {
 		int i = map.mblk[map.selected];
 		EBZB *bzb = (EBZB *)&map.blk[i].pmBootArgs[0];
-		msg_display(MSG_partdebug, diskdev, bzb->flags.part,
+		msg_display(MSG_partdebug, pm->diskdev, bzb->flags.part,
 			map.blk[i].pmPyPartStart,
 			map.blk[i].pmPartBlkCnt);
 		if ((map.blk[i].pmPyPartStart +
-		    map.blk[i].pmPartBlkCnt) > dlsize) {
+		    map.blk[i].pmPartBlkCnt) > pm->dlsize) {
 			msg_display_add(MSG_parttable_fix_fixing,
-				diskdev, bzb->flags.part);
+				pm->diskdev, bzb->flags.part);
 			map.blk[i].pmPartBlkCnt =
-			    dlsize - map.blk[i].pmPyPartStart;
+			    pm->dlsize - map.blk[i].pmPyPartStart;
 			map.blk[i].pmDataCnt =
 			    map.blk[i].pmPartBlkCnt;
 		} else {
 		    msg_display_add(MSG_parttable_fix_fine,
-			diskdev, bzb->flags.part);
+			pm->diskdev, bzb->flags.part);
 		}
 		process_menu(MENU_ok, NULL);
 		};
diff --git a/distrib/utils/sysinst/arch/mac68k/menus.md.en b/distrib/utils/sysinst/arch/mac68k/menus.md.en
index a4c18e3..4ae1bce 100644
--- a/distrib/utils/sysinst/arch/mac68k/menus.md.en
+++ b/distrib/utils/sysinst/arch/mac68k/menus.md.en
@@ -39,7 +39,7 @@ menu fullpart, title  "Select your choice";
 	option "Use the entire disk", 	    exit, action  {usefull = 1;};
 
 menu nodiskmap, title "Choose an option", y=16;
-	display action { msg_display (MSG_nodiskmap, diskdev); };
+	display action { msg_display (MSG_nodiskmap, pm->diskdev); };
 	option "Abort install", exit, action {
 		endwin();  exit(1);
 	};
@@ -99,9 +99,9 @@ menu editparttable, title  "Choose your partition", exit, y=14;
 			bzb->mount_point[0] = '\0';
 			strcpy ((char *)map.blk[k].pmPartType, "Apple_Free");
 			map.blk[k].pmPyPartStart += size;
-			if ((map.blk[k].pmPyPartStart + free_size) > dlsize)
+			if ((map.blk[k].pmPyPartStart + free_size) > pm->dlsize)
 			    map.blk[k].pmPartBlkCnt =
-				dlsize - map.blk[k].pmPyPartStart;
+				pm->dlsize - map.blk[k].pmPyPartStart;
 			else
 			    map.blk[k].pmPartBlkCnt = free_size;
 			map.blk[k].pmDataCnt = map.blk[k].pmPartBlkCnt;
@@ -129,20 +129,20 @@ menu editparttable, title  "Choose your partition", exit, y=14;
 	option "Fix selected partition", action {
 		int i = map.mblk[map.selected];
 		EBZB *bzb = (EBZB *)&map.blk[i].pmBootArgs[0];
-		msg_display(MSG_partdebug, diskdev, bzb->flags.part,
+		msg_display(MSG_partdebug, pm->diskdev, bzb->flags.part,
 			map.blk[i].pmPyPartStart,
 			map.blk[i].pmPartBlkCnt);
 		if ((map.blk[i].pmPyPartStart +
-		    map.blk[i].pmPartBlkCnt) > dlsize) {
+		    map.blk[i].pmPartBlkCnt) > pm->dlsize) {
 			msg_display_add(MSG_parttable_fix_fixing,
-				diskdev, bzb->flags.part);
+				pm->diskdev, bzb->flags.part);
 			map.blk[i].pmPartBlkCnt =
-			    dlsize - map.blk[i].pmPyPartStart;
+			    pm->dlsize - map.blk[i].pmPyPartStart;
 			map.blk[i].pmDataCnt =
 			    map.blk[i].pmPartBlkCnt;
 		} else {
 		    msg_display_add(MSG_parttable_fix_fine,
-			diskdev, bzb->flags.part);
+			pm->diskdev, bzb->flags.part);
 		}
 		process_menu(MENU_ok, NULL);
 		};
diff --git a/distrib/utils/sysinst/arch/mac68k/menus.md.es b/distrib/utils/sysinst/arch/mac68k/menus.md.es
index 3c81043..d79e4cd 100644
--- a/distrib/utils/sysinst/arch/mac68k/menus.md.es
+++ b/distrib/utils/sysinst/arch/mac68k/menus.md.es
@@ -39,7 +39,7 @@ menu fullpart, title  "Seleccione su opcion";
 	option "Usar el disco entero", 	    exit, action  {usefull = 1;};
 
 menu nodiskmap, title "Escoja una opcion", y=16;
-	display action { msg_display (MSG_nodiskmap, diskdev); };
+	display action { msg_display (MSG_nodiskmap, pm->diskdev); };
 	option "Abortar instalacion", exit, action {
 		endwin();  exit(1);
 	};
@@ -99,9 +99,9 @@ menu editparttable, title  "Escoja su particion", exit, y=14;
 			bzb->mount_point[0] = '\0';
 			strcpy (map.blk[k].pmPartType, "Apple_Free");
 			map.blk[k].pmPyPartStart += size;
-			if ((map.blk[k].pmPyPartStart + free_size) > dlsize)
+			if ((map.blk[k].pmPyPartStart + free_size) > pm->dlsize)
 			    map.blk[k].pmPartBlkCnt =
-				dlsize - map.blk[k].pmPyPartStart;
+				pm->dlsize - map.blk[k].pmPyPartStart;
 			else
 			    map.blk[k].pmPartBlkCnt = free_size;
 			map.blk[k].pmDataCnt = map.blk[k].pmPartBlkCnt;
@@ -129,20 +129,20 @@ menu editparttable, title  "Escoja su particion", exit, y=14;
 	option "Arreglar particion seleccionada", action {
 		int i = map.mblk[map.selected];
 		EBZB *bzb = (EBZB *)&map.blk[i].pmBootArgs[0];
-		msg_display(MSG_partdebug, diskdev, bzb->flags.part,
+		msg_display(MSG_partdebug, pm->diskdev, bzb->flags.part,
 			map.blk[i].pmPyPartStart,
 			map.blk[i].pmPartBlkCnt);
 		if ((map.blk[i].pmPyPartStart +
-		    map.blk[i].pmPartBlkCnt) > dlsize) {
+		    map.blk[i].pmPartBlkCnt) > pm->dlsize) {
 			msg_display_add(MSG_parttable_fix_fixing,
-				diskdev, bzb->flags.part);
+				pm->diskdev, bzb->flags.part);
 			map.blk[i].pmPartBlkCnt =
-			    dlsize - map.blk[i].pmPyPartStart;
+			    pm->dlsize - map.blk[i].pmPyPartStart;
 			map.blk[i].pmDataCnt =
 			    map.blk[i].pmPartBlkCnt;
 		} else {
 		    msg_display_add(MSG_parttable_fix_fine,
-			diskdev, bzb->flags.part);
+			pm->diskdev, bzb->flags.part);
 		}
 		process_menu(MENU_ok, NULL);
 		};
diff --git a/distrib/utils/sysinst/arch/mac68k/menus.md.pl b/distrib/utils/sysinst/arch/mac68k/menus.md.pl
index 8d5a70d..41de635 100644
--- a/distrib/utils/sysinst/arch/mac68k/menus.md.pl
+++ b/distrib/utils/sysinst/arch/mac68k/menus.md.pl
@@ -41,7 +41,7 @@ menu fullpart, title  "Wybierz";
 	option "Uzyj calego dysku", 	    exit, action  {usefull = 1;};
 
 menu nodiskmap, title "Wybierz opcje", y=16;
-       display action { msg_display (MSG_nodiskmap, diskdev); };
+       display action { msg_display (MSG_nodiskmap, pm->diskdev); };
        option "Przerwij instalacje", exit, action {
 		endwin();  exit(1);
 	};
@@ -101,9 +101,9 @@ menu editparttable, title  "Wybierz swoje partycje", exit, y=14;
 			bzb->mount_point[0] = '\0';
 			strcpy (map.blk[k].pmPartType, "Apple_Free");
 			map.blk[k].pmPyPartStart += size;
-			if ((map.blk[k].pmPyPartStart + free_size) > dlsize)
+			if ((map.blk[k].pmPyPartStart + free_size) > pm->dlsize)
 			    map.blk[k].pmPartBlkCnt =
-				dlsize - map.blk[k].pmPyPartStart;
+				pm->dlsize - map.blk[k].pmPyPartStart;
 			else
 			    map.blk[k].pmPartBlkCnt = free_size;
 			map.blk[k].pmDataCnt = map.blk[k].pmPartBlkCnt;
@@ -131,20 +131,20 @@ menu editparttable, title  "Wybierz swoje partycje", exit, y=14;
 	option "Napraw wybrana partycje", action {
 		int i = map.mblk[map.selected];
 		EBZB *bzb = (EBZB *)&map.blk[i].pmBootArgs[0];
-		msg_display(MSG_partdebug, diskdev, bzb->flags.part,
+		msg_display(MSG_partdebug, pm->diskdev, bzb->flags.part,
 			map.blk[i].pmPyPartStart,
 			map.blk[i].pmPartBlkCnt);
 		if ((map.blk[i].pmPyPartStart +
-		    map.blk[i].pmPartBlkCnt) > dlsize) {
+		    map.blk[i].pmPartBlkCnt) > pm->dlsize) {
 			msg_display_add(MSG_parttable_fix_fixing,
-				diskdev, bzb->flags.part);
+				pm->diskdev, bzb->flags.part);
 			map.blk[i].pmPartBlkCnt =
-			    dlsize - map.blk[i].pmPyPartStart;
+			    pm->dlsize - map.blk[i].pmPyPartStart;
 			map.blk[i].pmDataCnt =
 			    map.blk[i].pmPartBlkCnt;
 		} else {
 		    msg_display_add(MSG_parttable_fix_fine,
-			diskdev, bzb->flags.part);
+			pm->diskdev, bzb->flags.part);
 		}
 		process_menu(MENU_ok, NULL);
 		};
diff --git a/distrib/utils/sysinst/arch/macppc/md.c b/distrib/utils/sysinst/arch/macppc/md.c
index 2b9d90c..ff9c6e7 100644
--- a/distrib/utils/sysinst/arch/macppc/md.c
+++ b/distrib/utils/sysinst/arch/macppc/md.c
@@ -63,11 +63,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf (dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf (dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open (dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -75,7 +75,7 @@ md_get_info(void)
 		fprintf (stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -83,21 +83,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -172,14 +172,14 @@ md_post_newfs(void)
 	 * yet, so assume partition a has some offset on OF3 machines
 	 * and don't try installboot(8) in that case.
 	 */
-	if (bsdlabel[PART_A].pi_offset != 0)
+	if (pm->bsdlabel[PART_A].pi_offset != 0)
 		return 0;
 
-	printf (msg_string(MSG_dobootblks), diskdev);
+	printf (msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/ofwboot", bootfile);
 	sync();
 	run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sa %s %s",
-	    diskdev, "/usr/mdec/bootxx", bootfile);
+	    pm->diskdev, "/usr/mdec/bootxx", bootfile);
 	return 0;
 }
 
diff --git a/distrib/utils/sysinst/arch/mipsco/md.c b/distrib/utils/sysinst/arch/mipsco/md.c
index 1a035d5..7f2db6a 100644
--- a/distrib/utils/sysinst/arch/mipsco/md.c
+++ b/distrib/utils/sysinst/arch/mipsco/md.c
@@ -63,11 +63,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -77,7 +77,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -88,21 +88,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -160,10 +160,10 @@ md_post_newfs(void)
 		return 0;
 	}
 
-	printf(msg_string(MSG_dobootblks), diskdev);
+	printf(msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot", "/boot");
 	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
-	    "/usr/mdec/installboot /dev/r%sc /usr/mdec/bootxx_ffs", diskdev))
+	    "/usr/mdec/installboot /dev/r%sc /usr/mdec/bootxx_ffs", pm->diskdev))
 		process_menu(MENU_ok,
 			deconst("Warning: disk is probably not bootable"));
 	return 0;
diff --git a/distrib/utils/sysinst/arch/mvme68k/md.c b/distrib/utils/sysinst/arch/mvme68k/md.c
index 77064f6..7821f98 100644
--- a/distrib/utils/sysinst/arch/mvme68k/md.c
+++ b/distrib/utils/sysinst/arch/mvme68k/md.c
@@ -64,9 +64,9 @@ md_get_info(void)
 	char buf[1024];
 	int fd;
 	char dev_name[100];
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -76,7 +76,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -85,19 +85,19 @@ md_get_info(void)
 		close(fd);
 		exit(1);
 	}
-	if (disklabel.d_secsize != 512) {
+	if (pm->disklabel.d_secsize != 512) {
 		endwin();
 		fprintf(stderr, "Non-512byte/sector disk is not supported.\n");
 		close(fd);
 		exit(1);
 	}
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
-	dlsize = dlcyl*dlhead*dlsec;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
 
 	if (read(fd, buf, 1024) < 0) {
 		endwin();
@@ -107,7 +107,7 @@ md_get_info(void)
 	}
 
 	/* preserve first cylinder for system. */
-	ptstart = disklabel.d_secpercyl;
+	pm->ptstart = pm->disklabel.d_secpercyl;
 
 	close(fd);
 
@@ -137,22 +137,22 @@ md_check_partitions(void)
 	for (part = PART_A; part < 8; part++) {
 		if (part == PART_C)
 			continue;
-		if (last >= PART_A && bsdlabel[part].pi_size > 0) {
+		if (last >= PART_A && pm->bsdlabel[part].pi_size > 0) {
 			msg_display(MSG_emptypart, part+'a');
 			process_menu(MENU_ok, NULL);
 			return 0;
 		}
-		if (bsdlabel[part].pi_size == 0) {
+		if (pm->bsdlabel[part].pi_size == 0) {
 			if (last < PART_A)
 				last = part;
 		} else {
-			if (start > bsdlabel[part].pi_offset) {
+			if (start > pm->bsdlabel[part].pi_offset) {
 				msg_display(MSG_ordering, part+'a');
 				process_menu(MENU_yesno, NULL);
 				if (yesno)
 					return 0;
 			}
-			start = bsdlabel[part].pi_offset;
+			start = pm->bsdlabel[part].pi_offset;
 		}
 	}
 
@@ -175,7 +175,7 @@ int
 md_post_disklabel(void)
 {
 	if (get_ramsize() < 6)
-		set_swap(diskdev, bsdlabel);
+		set_swap(pm->diskdev, pm->bsdlabel);
 
 	return 0;
 }
@@ -192,11 +192,11 @@ md_post_newfs(void)
 {
 
 	/* boot blocks ... */
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	cp_to_target("/usr/mdec/bootsd", "/.bootsd");
 	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
 	    "/usr/mdec/installboot %s /usr/mdec/bootxx /dev/r%sa",
-	    target_expand("/.bootsd"), diskdev))
+	    target_expand("/.bootsd"), pm->diskdev))
 		process_menu(MENU_ok,
 			deconst("Warning: disk is probably not bootable"));
 	return 0;
@@ -220,7 +220,7 @@ int
 md_pre_update(void)
 {
 	if (get_ramsize() < 6)
-		set_swap(diskdev, NULL);
+		set_swap(pm->diskdev, NULL);
 	return 1;
 }
 
diff --git a/distrib/utils/sysinst/arch/news68k/md.c b/distrib/utils/sysinst/arch/news68k/md.c
index 021c24d..f355c04 100644
--- a/distrib/utils/sysinst/arch/news68k/md.c
+++ b/distrib/utils/sysinst/arch/news68k/md.c
@@ -64,11 +64,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
+	snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -76,7 +76,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf(stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -84,21 +84,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl * dlhead * dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl * pm->dlhead * pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -155,11 +155,11 @@ md_post_newfs(void)
 {
 	const char *bootfile = "/boot";
 
-	printf(msg_string(MSG_dobootblks), diskdev);
+	printf(msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot", bootfile);
 	sync();
 	run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sc %s %s",
-	    diskdev, "/usr/mdec/bootxx", bootfile);
+	    pm->diskdev, "/usr/mdec/bootxx", bootfile);
 	return 0;
 }
 
diff --git a/distrib/utils/sysinst/arch/newsmips/md.c b/distrib/utils/sysinst/arch/newsmips/md.c
index 11e4163..030cbef 100644
--- a/distrib/utils/sysinst/arch/newsmips/md.c
+++ b/distrib/utils/sysinst/arch/newsmips/md.c
@@ -63,11 +63,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf (dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf (dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open (dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -75,7 +75,7 @@ md_get_info(void)
 		fprintf (stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf (stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -83,21 +83,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -150,11 +150,11 @@ md_post_newfs()
 {
 	const char *bootfile = "/boot";
 
-	printf (msg_string(MSG_dobootblks), diskdev);
+	printf (msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot", bootfile);
 	sync();
 	run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sc %s %s",
-	    diskdev, "/usr/mdec/bootxx", bootfile);
+	    pm->diskdev, "/usr/mdec/bootxx", bootfile);
 	return 0;
 }
 
diff --git a/distrib/utils/sysinst/arch/ofppc/md.c b/distrib/utils/sysinst/arch/ofppc/md.c
index 0ff9339..d522ee6 100644
--- a/distrib/utils/sysinst/arch/ofppc/md.c
+++ b/distrib/utils/sysinst/arch/ofppc/md.c
@@ -101,28 +101,28 @@ md_make_bsd_partitions(void)
 	if (rdb_found) {
 		/*
 		 * We found RDB partitions on the disk, which cannot be
-		 * modified by rewriting the disklabel.
+		 * modified by rewriting the pm->disklabel.
 		 * So just use what we have got.
 		 */
 		for (part = 0; part < maxpart; part++) {
-			if (PI_ISBSDFS(&bsdlabel[part])) {
-				bsdlabel[part].pi_flags |=
+			if (PI_ISBSDFS(&pm->bsdlabel[part])) {
+				pm->bsdlabel[part].pi_flags |=
 				    PIF_NEWFS | PIF_MOUNT;
 
 				if (part == PART_A)
-					strcpy(bsdlabel[part].pi_mount, "/");
+					strcpy(pm->bsdlabel[part].pi_mount, "/");
 			}
 		}
 
 		part_bsd = part_raw = getrawpartition();
 		if (part_raw == -1)
 			part_raw = PART_C;	/* for sanity... */
-		bsdlabel[part_raw].pi_offset = 0;
-		bsdlabel[part_raw].pi_size = dlsize;
+		pm->bsdlabel[part_raw].pi_offset = 0;
+		pm->bsdlabel[part_raw].pi_size = pm->dlsize;
 
 		set_sizemultname_meg();
 rdb_edit_check:
-		if (edit_and_check_label(bsdlabel, maxpart, part_raw,
+		if (edit_and_check_label(pm->bsdlabel, maxpart, part_raw,
 		    part_bsd) == 0) {
 			msg_display(MSG_abort);
 			return 0;
@@ -137,72 +137,72 @@ rdb_edit_check:
 	 * Initialize global variables that track space used on this disk.
 	 * Standard 4.4BSD 8-partition labels always cover whole disk.
 	 */
-	if (ptsize == 0)
-		ptsize = dlsize - ptstart;
-	if (dlsize == 0)
-		dlsize = ptstart + ptsize;
+	if (pm->ptsize == 0)
+		pm->ptsize = pm->dlsize - pm->ptstart;
+	if (pm->dlsize == 0)
+		pm->dlsize = pm->ptstart + pm->ptsize;
 
-	partstart = ptstart;
-	ptend = ptstart + ptsize;
+	partstart = pm->ptstart;
+	ptend = pm->ptstart + pm->ptsize;
 
 	/* Ask for layout type -- standard or special */
 	msg_display(MSG_layout,
-		    ptsize / (MEG / sectorsize),
+		    pm->ptsize / (MEG / pm->sectorsize),
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE,
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB);
 
 	process_menu(MENU_layout, NULL);
 
 	/* Set so we use the 'real' geometry for rounding, input in MB */
-	current_cylsize = dlcylsize;
+	pm->current_cylsize = pm->dlcylsize;
 	set_sizemultname_meg();
 
 	/* Build standard partitions */
-	memset(&bsdlabel, 0, sizeof bsdlabel);
+	memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);
 
 	/* Set initial partition types to unused */
 	for (part = 0 ; part < maxpart ; ++part)
-		bsdlabel[part].pi_fstype = FS_UNUSED;
+		pm->bsdlabel[part].pi_fstype = FS_UNUSED;
 
 	/* Whole disk partition */
 	part_raw = getrawpartition();
 	if (part_raw == -1)
 		part_raw = PART_C;	/* for sanity... */
-	bsdlabel[part_raw].pi_offset = 0;
-	bsdlabel[part_raw].pi_size = dlsize;
+	pm->bsdlabel[part_raw].pi_offset = 0;
+	pm->bsdlabel[part_raw].pi_size = pm->dlsize;
 
 	if (part_raw == PART_D) {
 		/* Probably a system that expects an i386 style mbr */
 		part_bsd = PART_C;
-		bsdlabel[PART_C].pi_offset = ptstart;
-		bsdlabel[PART_C].pi_size = ptsize;
+		pm->bsdlabel[PART_C].pi_offset = pm->ptstart;
+		pm->bsdlabel[PART_C].pi_size = pm->ptsize;
 	} else {
 		part_bsd = part_raw;
 	}
 
-	if (bootsize != 0) {
-		bsdlabel[PART_BOOT_FAT12].pi_fstype = FS_MSDOS;
-		bsdlabel[PART_BOOT_FAT12].pi_size = bootsize;
-		bsdlabel[PART_BOOT_FAT12].pi_offset = bootstart;
-		bsdlabel[PART_BOOT_FAT12].pi_flags |= PART_BOOT_FAT12_PI_FLAGS;
-		strlcpy(bsdlabel[PART_BOOT_FAT12].pi_mount,
+	if (pm->bootsize != 0) {
+		pm->bsdlabel[PART_BOOT_FAT12].pi_fstype = FS_MSDOS;
+		pm->bsdlabel[PART_BOOT_FAT12].pi_size = pm->bootsize;
+		pm->bsdlabel[PART_BOOT_FAT12].pi_offset = pm->bootstart;
+		pm->bsdlabel[PART_BOOT_FAT12].pi_flags |= PART_BOOT_FAT12_PI_FLAGS;
+		strlcpy(pm->bsdlabel[PART_BOOT_FAT12].pi_mount,
 		    PART_BOOT_FAT12_PI_MOUNT,
-		    sizeof bsdlabel[PART_BOOT_FAT12].pi_mount);
+		    sizeof pm->bsdlabel[PART_BOOT_FAT12].pi_mount);
 	}
 	if (binfosize != 0) {
-		bsdlabel[PART_BOOT_BINFO].pi_fstype = FS_OTHER;
-		bsdlabel[PART_BOOT_BINFO].pi_size = binfosize;
-		bsdlabel[PART_BOOT_BINFO].pi_offset = binfostart;
+		pm->bsdlabel[PART_BOOT_BINFO].pi_fstype = FS_OTHER;
+		pm->bsdlabel[PART_BOOT_BINFO].pi_size = binfosize;
+		pm->bsdlabel[PART_BOOT_BINFO].pi_offset = binfostart;
 	}
 	if (bprepsize != 0) {
-		bsdlabel[PART_BOOT_PREP].pi_fstype = FS_BOOT;
-		bsdlabel[PART_BOOT_PREP].pi_size = bprepsize;
-		bsdlabel[PART_BOOT_PREP].pi_offset = bprepstart;
+		pm->bsdlabel[PART_BOOT_PREP].pi_fstype = FS_BOOT;
+		pm->bsdlabel[PART_BOOT_PREP].pi_size = bprepsize;
+		pm->bsdlabel[PART_BOOT_PREP].pi_offset = bprepstart;
 	}
 
 #ifdef PART_REST
-	bsdlabel[PART_REST].pi_offset = 0;
-	bsdlabel[PART_REST].pi_size = ptstart;
+	pm->bsdlabel[PART_REST].pi_offset = 0;
+	pm->bsdlabel[PART_REST].pi_size = pm->ptstart;
 #endif
 
 	/*
@@ -212,24 +212,24 @@ rdb_edit_check:
 	 * partitions on a multiboot i386 system.
 	 */
 	 for (i = maxpart; i--;) {
-		if (bsdlabel[i].pi_size != 0)
+		if (pm->bsdlabel[i].pi_size != 0)
 			/* Don't overwrite special partitions */
 			continue;
-		p = &oldlabel[i];
+		p = &pm->oldlabel[i];
 		if (p->pi_fstype == FS_UNUSED || p->pi_size == 0)
 			continue;
 		if (layoutkind == 4) {
 			if (PI_ISBSDFS(p))
 				p->pi_flags |= PIF_MOUNT;
 		} else {
-			if (p->pi_offset < ptstart + ptsize &&
-			    p->pi_offset + p->pi_size > ptstart)
+			if (p->pi_offset < pm->ptstart + pm->ptsize &&
+			    p->pi_offset + p->pi_size > pm->ptstart)
 				/* Not outside area we are allocating */
 				continue;
 			if (p->pi_fstype == FS_SWAP)
 				no_swap = 1;
 		}
-		bsdlabel[i] = oldlabel[i];
+		pm->bsdlabel[i] = pm->oldlabel[i];
 	 }
 
 	if (layoutkind == 4) {
@@ -243,7 +243,7 @@ rdb_edit_check:
 	 * edit it and verify it's OK, or abort altogether.
 	 */
  edit_check:
-	if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) {
+	if (edit_and_check_label(pm->bsdlabel, maxpart, part_raw, part_bsd) == 0) {
 		msg_display(MSG_abort);
 		return 0;
 	}
@@ -251,10 +251,10 @@ rdb_edit_check:
 		goto edit_check;
 
 	/* Disk name */
-	msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname);
+	msg_prompt(MSG_packname, pm->bsddiskname, pm->bsddiskname, sizeof pm->bsddiskname);
 
 	/* save label to disk for MI code to update. */
-	(void) savenewlabel(bsdlabel, maxpart);
+	(void) savenewlabel(pm->bsdlabel, maxpart);
 
 	/* Everything looks OK. */
 	return 1;
@@ -277,13 +277,13 @@ md_check_partitions(void)
 	 * from the MBR partition.
 	 */
 	for (part = PART_A; part < MAXPARTITIONS; part++) {
-		if (bsdlabel[part].pi_fstype == FS_MSDOS) {
+		if (pm->bsdlabel[part].pi_fstype == FS_MSDOS) {
 			bootpart_fat12 = part;
 			ffat++;
-		} else if (bsdlabel[part].pi_fstype == FS_BOOT) {
+		} else if (pm->bsdlabel[part].pi_fstype == FS_BOOT) {
 			bootpart_prep = part;
 			fprep++;
-		} else if (bsdlabel[part].pi_fstype == FS_OTHER) {
+		} else if (pm->bsdlabel[part].pi_fstype == FS_OTHER) {
 			bootpart_binfo = part;
 			fprep++;
 		}
@@ -314,7 +314,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -330,10 +330,10 @@ md_post_disklabel(void)
 {
 	char bootdev[100];
 
-	if (bootstart == 0 || bootsize == 0 || rdb_found)
+	if (pm->bootstart == 0 || pm->bootsize == 0 || rdb_found)
 		return 0;
 
-	snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev,
+	snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", pm->diskdev,
 	    'a'+bootpart_fat12);
 	run_program(RUN_DISPLAY, "/sbin/newfs_msdos %s", bootdev);
 
@@ -380,18 +380,18 @@ md_post_extract(void)
 	}
 
 	if (!noprepfix) {
-		snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev,
+		snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", pm->diskdev,
 		    'a'+bootpart_prep);
-		snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", diskdev,
+		snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", pm->diskdev,
 		    'a'+bootpart_prep);
 		run_program(RUN_DISPLAY, "/bin/dd if=/dev/zero of=%s bs=512",
 		    bootdev);
 		run_program(RUN_DISPLAY, "/bin/dd if=/usr/mdec/ofwboot "
 		    "of=%s bs=512", bootbdev);
 
-		snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", diskdev,
+		snprintf(bootdev, sizeof bootdev, "/dev/r%s%c", pm->diskdev,
 		    'a'+bootpart_binfo);
-		snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", diskdev,
+		snprintf(bootbdev, sizeof bootbdev, "/dev/%s%c", pm->diskdev,
 		    'a'+bootpart_binfo);
 		run_program(RUN_DISPLAY, "/bin/dd if=/dev/zero of=%s bs=512",
 		    bootdev);
@@ -421,7 +421,7 @@ md_pre_update(void)
 	if (check_rdb())
 		return 1;
 
-	read_mbr(diskdev, &mbr);
+	read_mbr(pm->diskdev, &mbr);
 	/* do a sanity check of the partition table */
 	for (ext = &mbr; ext; ext = ext->extended) {
 		part = ext->mbr.mbr_parts;
@@ -474,8 +474,8 @@ md_check_mbr(mbr_info_t *mbri)
 		part = ext->mbr.mbr_parts;
 		for (i = 0; i < MBR_PART_COUNT; part++, i++) {
 			if (part->mbrp_type == MBR_PTYPE_FAT12) {
-				bootstart = part->mbrp_start;
-				bootsize = part->mbrp_size;
+				pm->bootstart = part->mbrp_start;
+				pm->bootsize = part->mbrp_size;
 			} else if (part->mbrp_type == MBR_PTYPE_PREP &&
 			    part->mbrp_size < 50) {
 				/* this is the bootinfo partition */
@@ -493,7 +493,7 @@ md_check_mbr(mbr_info_t *mbri)
 
 	/* we need to either have a pair of prep partitions, or a single
 	 * fat.  if neither, things are broken. */
-	if (!(bootsize >= (MIN_FAT12_BOOT/512) ||
+	if (!(pm->bootsize >= (MIN_FAT12_BOOT/512) ||
 		(binfosize >= (MIN_BINFO_BOOT/512) &&
 		    bprepsize >= (MIN_PREP_BOOT/512)))) {
 		msg_display(MSG_bootnotright);
@@ -517,7 +517,7 @@ md_check_mbr(mbr_info_t *mbri)
 	}
 
 	/* check the fat12 parititons */
-	if (bootsize > 0 && bootsize < (MIN_FAT12_BOOT/512)) {
+	if (pm->bootsize > 0 && pm->bootsize < (MIN_FAT12_BOOT/512)) {
 		msg_display(MSG_boottoosmall);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -527,7 +527,7 @@ md_check_mbr(mbr_info_t *mbri)
 	}
 
 	/* if both sets contain zero, thats bad */
-	if ((bootstart == 0 || bootsize == 0) &&
+	if ((pm->bootstart == 0 || pm->bootsize == 0) &&
 	    (binfosize == 0 || binfostart == 0 ||
 		bprepsize == 0 || bprepstart == 0)) {
 		msg_display(MSG_nobootpart);
@@ -571,7 +571,7 @@ md_mbr_use_wholedisk(mbr_info_t *mbri)
 	part[0].mbrp_flag = 0;
 
 	part[1].mbrp_type = MBR_PTYPE_NETBSD;
-	part[1].mbrp_size = dlsize - (bsec + FAT12_BOOT_SIZE/512 +
+	part[1].mbrp_size = pm->dlsize - (bsec + FAT12_BOOT_SIZE/512 +
 	    BINFO_BOOT_SIZE/512 + PREP_BOOT_SIZE/512);
 	part[1].mbrp_start = bsec + FAT12_BOOT_SIZE/512 + BINFO_BOOT_SIZE/512 +
 	    PREP_BOOT_SIZE/512;
@@ -587,10 +587,10 @@ md_mbr_use_wholedisk(mbr_info_t *mbri)
 	part[3].mbrp_start = bsec + FAT12_BOOT_SIZE/512 + BINFO_BOOT_SIZE/512;
 	part[3].mbrp_flag = 0;
 
-	ptstart = part[1].mbrp_start;
-	ptsize = part[1].mbrp_size;
-	bootstart = part[0].mbrp_start;
-	bootsize = part[0].mbrp_size;
+	pm->ptstart = part[1].mbrp_start;
+	pm->ptsize = part[1].mbrp_size;
+	pm->bootstart = part[0].mbrp_start;
+	pm->bootsize = part[0].mbrp_size;
 	binfostart = part[2].mbrp_start;
 	binfosize= part[2].mbrp_size;
 	bprepstart = part[3].mbrp_start;
@@ -620,7 +620,7 @@ check_rdb(void)
 
 	/* Find out if this disk has a valid RDB, before continuing. */
 	rdb = (struct rdblock *)buf;
-	fd = opendisk(diskdev, O_RDONLY, diskpath, sizeof(diskpath), 0);
+	fd = opendisk(pm->diskdev, O_RDONLY, diskpath, sizeof(diskpath), 0);
 	if (fd < 0)
 		return 0;
 	for (blk = 0; blk < RDB_MAXBLOCKS; blk++) {
diff --git a/distrib/utils/sysinst/arch/pmax/md.c b/distrib/utils/sysinst/arch/pmax/md.c
index e8bd354..19aabd8 100644
--- a/distrib/utils/sysinst/arch/pmax/md.c
+++ b/distrib/utils/sysinst/arch/pmax/md.c
@@ -62,11 +62,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -76,7 +76,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -87,21 +87,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -161,12 +161,12 @@ md_post_newfs(void)
 		return 0;
 	}
 
-	printf(msg_string(MSG_dobootblks), diskdev);
+	printf(msg_string(MSG_dobootblks), pm->diskdev);
 	cp_to_target("/usr/mdec/boot.pmax", "/boot.pmax");
 	bootxx = bootxx_name();
 	if (bootxx != NULL) {
 		error = run_program(RUN_DISPLAY | RUN_NO_CLEAR,
-		    "/usr/sbin/installboot /dev/r%sc %s", diskdev, bootxx);
+		    "/usr/sbin/installboot /dev/r%sc %s", pm->diskdev, bootxx);
 		free(bootxx);
 	} else
 		error = -1;
diff --git a/distrib/utils/sysinst/arch/prep/md.c b/distrib/utils/sysinst/arch/prep/md.c
index 36fd490..0d36771 100644
--- a/distrib/utils/sysinst/arch/prep/md.c
+++ b/distrib/utils/sysinst/arch/prep/md.c
@@ -87,7 +87,7 @@ md_check_partitions(void)
 	 * something stupid, like move it away from the MBR partition.
 	 */
 	for (part = PART_A; part < MAXPARTITIONS; part++)
-		if (bsdlabel[part].pi_fstype == FS_BOOT) {
+		if (pm->bsdlabel[part].pi_fstype == FS_BOOT) {
 			prep_bootpart = part;
 			return 1;
 		}
@@ -106,7 +106,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -149,8 +149,8 @@ md_post_extract(void)
 	else
 		snprintf(bootloader, 100, "/usr/mdec/boot");
 
-	snprintf(rawdev, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
-	snprintf(bootpart, 100, "/dev/r%s%c", diskdev, 'a' + prep_bootpart);
+	snprintf(rawdev, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
+	snprintf(bootpart, 100, "/dev/r%s%c", pm->diskdev, 'a' + prep_bootpart);
 	if (prep_rawdevfix)
 		run_program(RUN_DISPLAY|RUN_CHROOT,
 		    "/usr/mdec/mkbootimage -b %s -k /netbsd "
@@ -181,7 +181,7 @@ md_pre_update(void)
 	mbr_info_t *ext;
 	int i;
 
-	read_mbr(diskdev, &mbr);
+	read_mbr(pm->diskdev, &mbr);
 	/* do a sanity check of the partition table */
 	for (ext = &mbr; ext; ext = ext->extended) {
 		part = ext->mbr.mbr_parts;
@@ -225,12 +225,12 @@ md_check_mbr(mbr_info_t *mbri)
 		for (i = 0; i < MBR_PART_COUNT; part++, i++) {
 			if (part->mbrp_type != MBR_PTYPE_PREP)
 				continue;
-			bootstart = part->mbrp_start;
-			bootsize = part->mbrp_size;
+			pm->bootstart = part->mbrp_start;
+			pm->bootsize = part->mbrp_size;
 			break;
 		}
 	}
-	if (bootsize < (MIN_PREP_BOOT/512)) {
+	if (pm->bootsize < (MIN_PREP_BOOT/512)) {
 		msg_display(MSG_preptoosmall);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -238,7 +238,7 @@ md_check_mbr(mbr_info_t *mbri)
 			return 0;
 		return 1;
 	}
-	if (bootstart == 0 || bootsize == 0) {
+	if (pm->bootstart == 0 || pm->bootsize == 0) {
 		msg_display(MSG_nopreppart);
 		msg_display_add(MSG_reeditpart, 0);
 		process_menu(MENU_yesno, NULL);
@@ -272,14 +272,14 @@ md_mbr_use_wholedisk(mbr_info_t *mbri)
 	part[0].mbrp_flag = MBR_PFLAG_ACTIVE;
 
 	part[1].mbrp_type = MBR_PTYPE_NETBSD;
-	part[1].mbrp_size = dlsize - (bsec + PREP_BOOT_SIZE/512);
+	part[1].mbrp_size = pm->dlsize - (bsec + PREP_BOOT_SIZE/512);
 	part[1].mbrp_start = bsec + PREP_BOOT_SIZE/512;
 	part[1].mbrp_flag = 0;
 
-	ptstart = part[1].mbrp_start;
-	ptsize = part[1].mbrp_size;
-	bootstart = part[0].mbrp_start;
-	bootsize = part[0].mbrp_size;
+	pm->ptstart = part[1].mbrp_start;
+	pm->ptsize = part[1].mbrp_size;
+	pm->bootstart = part[0].mbrp_start;
+	pm->bootsize = part[0].mbrp_size;
 	return 1;
 }
 
diff --git a/distrib/utils/sysinst/arch/sandpoint/md.c b/distrib/utils/sysinst/arch/sandpoint/md.c
index 5872e39..fc42a72 100644
--- a/distrib/utils/sysinst/arch/sandpoint/md.c
+++ b/distrib/utils/sysinst/arch/sandpoint/md.c
@@ -122,7 +122,7 @@ md_pre_disklabel(void)
 	printf ("%s", msg_string (MSG_dofdisk));
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -140,7 +140,7 @@ md_post_disklabel(void)
 	if (*doessf) {
 		printf ("%s", msg_string (MSG_dobad144));
 		return run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0",
-		    diskdev);
+		    pm->diskdev);
 	}
 	return 0;
 }
diff --git a/distrib/utils/sysinst/arch/sgimips/md.c b/distrib/utils/sysinst/arch/sgimips/md.c
index bece141..98d7897 100644
--- a/distrib/utils/sysinst/arch/sgimips/md.c
+++ b/distrib/utils/sysinst/arch/sgimips/md.c
@@ -79,11 +79,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
+	snprintf(dev_name, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -93,7 +93,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -104,21 +104,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -156,19 +156,19 @@ md_pre_disklabel(void)
 int
 md_post_disklabel(void)
 {
-	set_swap(diskdev, bsdlabel);
-        if (strstr(instsys.version, "(INSTALL32_IP3x)"))
+	set_swap(pm->diskdev, pm->bsdlabel);
+    if (strstr(instsys.version, "(INSTALL32_IP3x)"))
 		return run_program(RUN_DISPLAY,
 		    "%s %s", "/usr/mdec/sgivol -f -w boot /usr/mdec/ip3xboot",
-		    diskdev);
+		    pm->diskdev);
 
 	if (strstr(instsys.version, "(INSTALL32_IP2x)")) {
 		run_program(RUN_DISPLAY,
 		  "%s %s", "/usr/mdec/sgivol -f -w aoutboot /usr/mdec/aoutboot",
-		  diskdev);
+		  pm->diskdev);
 		return run_program(RUN_DISPLAY,
 		  "%s %s", "/usr/mdec/sgivol -f -w boot /usr/mdec/ip2xboot",
-		  diskdev);
+		  pm->diskdev);
 	}
 
 	/* Presumably an IP12, we add the boot code later... */
@@ -201,7 +201,7 @@ md_cleanup_install(void)
 
 	if (strstr(instsys.version, "(GENERIC32_IP12)"))
 		run_program(0, "/usr/mdec/sgivol -f -w netbsd %s %s",
-			    target_expand("/netbsd.ecoff"), diskdev);
+			    target_expand("/netbsd.ecoff"), pm->diskdev);
 }
 
 int
diff --git a/distrib/utils/sysinst/arch/sgimips/md.h b/distrib/utils/sysinst/arch/sgimips/md.h
index 92be0d4..d51ce67 100644
--- a/distrib/utils/sysinst/arch/sgimips/md.h
+++ b/distrib/utils/sysinst/arch/sgimips/md.h
@@ -63,7 +63,7 @@
  * hand-edited disklabel will NOT be written by MI code.
  */
 /*
- * sgimips should not use -r, as this prevents the SGI disklabel
+ * sgimips should not use -r, as this prevents the SGI pm->disklabel
  * from being written.
  */
 #define DISKLABEL_CMD "disklabel -w"
diff --git a/distrib/utils/sysinst/arch/shark/md.c b/distrib/utils/sysinst/arch/shark/md.c
index 070336a..593f6ca 100644
--- a/distrib/utils/sysinst/arch/shark/md.c
+++ b/distrib/utils/sysinst/arch/shark/md.c
@@ -65,16 +65,16 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	if (strncmp(diskdev, "wd", 2) == 0)
+	if (strncmp(pm->diskdev, "wd", 2) == 0)
 		disktype = "ST506";
 	else
 		disktype = "SCSI";
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -82,7 +82,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		endwin();
 		fprintf(stderr, "Can't read disklabel on %s.\n", dev_name);
 		close(fd);
@@ -90,21 +90,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -135,7 +135,7 @@ md_pre_disklabel(void)
 {
 	char diskpath[MAXPATHLEN];
 
-	if (clear_mbr(diskdev, diskpath, sizeof(diskpath)) == -1) {
+	if (clear_mbr(pm->diskdev, diskpath, sizeof(diskpath)) == -1) {
 		msg_display(MSG_badclearmbr, diskpath);
 		process_menu(MENU_ok, NULL);
 	}
diff --git a/distrib/utils/sysinst/arch/sparc/md.c b/distrib/utils/sysinst/arch/sparc/md.c
index 6934ed6..1fa8360 100644
--- a/distrib/utils/sysinst/arch/sparc/md.c
+++ b/distrib/utils/sysinst/arch/sparc/md.c
@@ -68,11 +68,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%s%c", diskdev, 'a' + getrawpartition());
+	snprintf(dev_name, 100, "/dev/r%s%c", pm->diskdev, 'a' + getrawpartition());
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -82,7 +82,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -93,21 +93,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -160,8 +160,8 @@ md_post_newfs(void)
 {
 
 	/* boot blocks ... */
-	msg_display(MSG_dobootblks, diskdev);
-	return (run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", diskdev) ||
+	msg_display(MSG_dobootblks, pm->diskdev);
+	return (run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", pm->diskdev) ||
 	    run_program(RUN_DISPLAY, "/usr/mdec/binstall ffs %s",
 		targetroot_mnt));
 }
diff --git a/distrib/utils/sysinst/arch/sparc64/md.c b/distrib/utils/sysinst/arch/sparc64/md.c
index f4ab543..7a1152f 100644
--- a/distrib/utils/sysinst/arch/sparc64/md.c
+++ b/distrib/utils/sysinst/arch/sparc64/md.c
@@ -69,11 +69,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -83,7 +83,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -94,21 +94,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -195,10 +195,10 @@ static void
 install_bootblocks(void)
 {
 	/* Install boot blocks before mounting the target disk */
-	msg_display(MSG_dobootblks, diskdev);
-	run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
+	run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", pm->diskdev);
 	run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sc"
-	    " /usr/mdec/bootblk", diskdev);
+	    " /usr/mdec/bootblk", pm->diskdev);
 }
 
 /* install/update secondary bootstrap */
diff --git a/distrib/utils/sysinst/arch/vax/md.c b/distrib/utils/sysinst/arch/vax/md.c
index cb71b83..2fc804c 100644
--- a/distrib/utils/sysinst/arch/vax/md.c
+++ b/distrib/utils/sysinst/arch/vax/md.c
@@ -66,11 +66,11 @@ md_init_set_status(int flags)
 int
 md_get_info(void)
 {
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 	int fd;
 	char dev_name[100];
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -80,7 +80,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -91,21 +91,21 @@ md_get_info(void)
 	}
 	close(fd);
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
 
 	/*
-	 * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
+	 * Compute whole disk size. Take max of (pm->dlcyl*pm->dlhead*pm->dlsec)
 	 * and secperunit,  just in case the disk is already labelled.
 	 * (If our new label's RAW_PART size ends up smaller than the
 	 * in-core RAW_PART size  value, updating the label will fail.)
 	 */
-	dlsize = dlcyl*dlhead*dlsec;
-	if (disklabel.d_secperunit > dlsize)
-		dlsize = disklabel.d_secperunit;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
+	if (pm->disklabel.d_secperunit > pm->dlsize)
+		pm->dlsize = pm->disklabel.d_secperunit;
 
 	return 1;
 }
@@ -156,9 +156,9 @@ md_post_disklabel(void)
 int
 md_post_newfs(void)
 {
-	printf(msg_string(MSG_dobootblks), diskdev);
+	printf(msg_string(MSG_dobootblks), pm->diskdev);
 	run_program(0, "/usr/sbin/installboot /dev/r%s%c /usr/mdec/%.2sboot",
-	    diskdev, 'a' + getrawpartition(), diskdev);
+	    pm->diskdev, 'a' + getrawpartition(), pm->diskdev);
 	return 0;
 }
 
diff --git a/distrib/utils/sysinst/arch/x68k/md.c b/distrib/utils/sysinst/arch/x68k/md.c
index 1da75ef..dd862ea 100644
--- a/distrib/utils/sysinst/arch/x68k/md.c
+++ b/distrib/utils/sysinst/arch/x68k/md.c
@@ -81,9 +81,9 @@ md_get_info(void)
 	char buf[1024];
 	int fd;
 	char dev_name[100];
-	struct disklabel disklabel;
+	struct pm->disklabel pm->disklabel;
 
-	snprintf(dev_name, 100, "/dev/r%sc", diskdev);
+	snprintf(dev_name, 100, "/dev/r%sc", pm->diskdev);
 
 	fd = open(dev_name, O_RDONLY, 0);
 	if (fd < 0) {
@@ -93,7 +93,7 @@ md_get_info(void)
 		fprintf(stderr, "Can't open %s\n", dev_name);
 		exit(1);
 	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (ioctl(fd, DIOCGDINFO, &pm->disklabel) == -1) {
 		if (logfp)
 			(void)fprintf(logfp, "Can't read disklabel on %s.\n",
 				dev_name);
@@ -102,19 +102,19 @@ md_get_info(void)
 		close(fd);
 		exit(1);
 	}
-	if (disklabel.d_secsize != 512) {
+	if (pm->disklabel.d_secsize != 512) {
 		endwin();
 		fprintf(stderr, "Non-512byte/sector disk is not supported.\n");
 		close(fd);
 		exit(1);
 	}
 
-	dlcyl = disklabel.d_ncylinders;
-	dlhead = disklabel.d_ntracks;
-	dlsec = disklabel.d_nsectors;
-	sectorsize = disklabel.d_secsize;
-	dlcylsize = disklabel.d_secpercyl;
-	dlsize = dlcyl*dlhead*dlsec;
+	pm->dlcyl = pm->disklabel.d_ncylinders;
+	pm->dlhead = pm->disklabel.d_ntracks;
+	pm->dlsec = pm->disklabel.d_nsectors;
+	pm->sectorsize = pm->disklabel.d_secsize;
+	pm->dlcylsize = pm->disklabel.d_secpercyl;
+	pm->dlsize = pm->dlcyl*pm->dlhead*pm->dlsec;
 
 	if (read(fd, buf, 1024) < 0) {
 		endwin();
@@ -134,7 +134,7 @@ md_get_info(void)
 		}
 #endif
 	/* preserve first 64 sectors for system. */
-	ptstart = 64;
+	pm->ptstart = 64;
 
 	/* preserve existing partitions? */
 
@@ -165,22 +165,22 @@ md_check_partitions(void)
 	for (part = PART_A; part < 8; part++) {
 		if (part == PART_C)
 			continue;
-		if (last >= PART_A && bsdlabel[part].pi_size > 0) {
+		if (last >= PART_A && pm->bsdlabel[part].pi_size > 0) {
 			msg_display(MSG_emptypart, part+'a');
 			process_menu(MENU_ok, NULL);
 			return 0;
 		}
-		if (bsdlabel[part].pi_size == 0) {
+		if (pm->bsdlabel[part].pi_size == 0) {
 			if (last < PART_A)
 				last = part;
 		} else {
-			if (start >= bsdlabel[part].pi_offset) {
+			if (start >= pm->bsdlabel[part].pi_offset) {
 				msg_display(MSG_ordering, part+'a');
 				process_menu(MENU_yesno, NULL);
 				if (yesno)
 					return 0;
 			}
-			start = bsdlabel[part].pi_offset;
+			start = pm->bsdlabel[part].pi_offset;
 		}
 	}
 
@@ -205,10 +205,10 @@ md_check_partitions(void)
 			break;
 		}
 	}
-	emptylabel(bsdlabel);
-	bsdlabel[C].pi_fstype = FS_UNUSED;
-	bsdlabel[C].pi_offset = 0;
-	bsdlabel[C].pi_size = dlsize;
+	emptylabel(pm->bsdlabel);
+	pm->bsdlabel[C].pi_fstype = FS_UNUSED;
+	pm->bsdlabel[C].pi_offset = 0;
+	pm->bsdlabel[C].pi_size = pm->dlsize;
 	for (i = 0, j = A; i < NDOSPART;) {
 		if (j == C) {
 			j++;
@@ -221,22 +221,22 @@ md_check_partitions(void)
 			i++;
 			continue;
 		}
-		bsdlabel[j].pi_fstype = (i == 1) ? FS_SWAP : FS_BSDFFS;
-		bsdlabel[j].pi_offset = md_disklabel.dosparts[i].dp_start*2;
-		bsdlabel[j].pi_size = md_disklabel.dosparts[i].dp_size*2;
+		pm->bsdlabel[j].pi_fstype = (i == 1) ? FS_SWAP : FS_BSDFFS;
+		pm->bsdlabel[j].pi_offset = md_disklabel.dosparts[i].dp_start*2;
+		pm->bsdlabel[j].pi_size = md_disklabel.dosparts[i].dp_size*2;
 		i++;
 		j++;
 	}
 	if (j > 6) {
-		msg_display(MSG_nofreepart, diskdev);
+		msg_display(MSG_nofreepart, pm->diskdev);
 		return 0;
 	}
 	md_nfreepart = 8 - j;
 
 	/* check for free space */
-	fsptsize = bsdlabel[A].pi_offset - 64;
-	if (fptsize <= 0) {	/* XXX: should not be 0; minfsdb?  */
-		msg_display(MSG_notfirst, diskdev);
+	fspm->ptsize = pm->bsdlabel[A].pi_offset - 64;
+	if (fpm->ptsize <= 0) {	/* XXX: should not be 0; minfsdb?  */
+		msg_display(MSG_notfirst, pm->diskdev);
 		process_menu(MENU_ok);
 		exit(1);
 	}
@@ -263,7 +263,7 @@ int
 md_post_disklabel(void)
 {
 	if (get_ramsize() < 6)
-		set_swap(diskdev, bsdlabel);
+		set_swap(pm->diskdev, pm->bsdlabel);
 	return 0;
 }
 
@@ -278,11 +278,11 @@ int
 md_post_newfs(void)
 {
 	/* boot blocks ... */
-	msg_display(MSG_dobootblks, diskdev);
+	msg_display(MSG_dobootblks, pm->diskdev);
 	cp_to_target("/usr/mdec/boot", "/boot");
 	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
 	    "/usr/mdec/installboot.new /usr/mdec/sdboot_ufs /dev/r%sa",
-	    diskdev))
+	    pm->diskdev))
 		process_menu(MENU_ok,
 			deconst("Warning: disk is probably not bootable"));
 	return 0;
@@ -306,7 +306,7 @@ int
 md_pre_update(void)
 {
 	if (get_ramsize() < 6)
-		set_swap(diskdev, NULL);
+		set_swap(pm->diskdev, NULL);
 	return 1;
 }
 
@@ -321,10 +321,10 @@ md_update(void)
 static int
 md_newdisk(void)
 {
-	msg_display(MSG_newdisk, diskdev, diskdev);
+	msg_display(MSG_newdisk, pm->diskdev, pm->diskdev);
 
 	return run_program(RUN_FATAL|RUN_DISPLAY,
-	    "/usr/mdec/newdisk -v %s", diskdev);
+	    "/usr/mdec/newdisk -v %s", pm->diskdev);
 }
 
 
diff --git a/distrib/utils/sysinst/arch/zaurus/md.c b/distrib/utils/sysinst/arch/zaurus/md.c
index fe2c043..5d49a61 100644
--- a/distrib/utils/sysinst/arch/zaurus/md.c
+++ b/distrib/utils/sysinst/arch/zaurus/md.c
@@ -100,7 +100,7 @@ md_pre_disklabel(void)
 	msg_display(MSG_dofdisk);
 
 	/* write edited MBR onto disk. */
-	if (write_mbr(diskdev, &mbr, 1) != 0) {
+	if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
 		msg_display(MSG_wmbrfail);
 		process_menu(MENU_ok, NULL);
 		return 1;
@@ -130,7 +130,7 @@ md_post_newfs(void)
 	ssize_t sz;
 	int fd = -1;
 
-	snprintf(adevname, sizeof(adevname), "/dev/r%sa", diskdev);
+	snprintf(adevname, sizeof(adevname), "/dev/r%sa", pm->diskdev);
 	fd = open(adevname, O_RDWR);
 	if (fd < 0)
 		goto out;
diff --git a/distrib/utils/sysinst/bsddisklabel.c b/distrib/utils/sysinst/bsddisklabel.c
index 6916792..82c116d 100644
--- a/distrib/utils/sysinst/bsddisklabel.c
+++ b/distrib/utils/sysinst/bsddisklabel.c
@@ -95,7 +95,7 @@ save_ptn(int ptn, daddr_t start, daddr_t size, int fstype, const char *mountpt)
 	if (maxptn == 0)
 		maxptn = getmaxpartitions();
 
-	if (ptn < 0 || bsdlabel[ptn].pi_fstype != FS_UNUSED) {
+	if (ptn < 0 || pm->bsdlabel[ptn].pi_fstype != FS_UNUSED) {
 		ptn = getrawpartition() + 1;
 #ifdef PART_FIRST_FREE
 		if (ptn < PART_FIRST_FREE)
@@ -106,7 +106,7 @@ save_ptn(int ptn, daddr_t start, daddr_t size, int fstype, const char *mountpt)
 				return -1;
 			if (ptn == PART_USR)
 				continue;
-			if (bsdlabel[ptn].pi_fstype == FS_UNUSED)
+			if (pm->bsdlabel[ptn].pi_fstype == FS_UNUSED)
 				break;
 		}
 	}
@@ -114,15 +114,15 @@ save_ptn(int ptn, daddr_t start, daddr_t size, int fstype, const char *mountpt)
 	if (fstype == FS_UNUSED)
 		return ptn;
 
-	p = bsdlabel + ptn;
+	p = pm->bsdlabel + ptn;
 	p->pi_offset = start;
 	p->pi_size = size;
 	set_ptype(p, fstype, mountpt ? PIF_NEWFS : 0);
 
 	if (mountpt != NULL) {
 		for (pp = 0; pp < maxptn; pp++) {
-			if (strcmp(bsdlabel[pp].pi_mount, mountpt) == 0)
-				bsdlabel[pp].pi_flags &= ~PIF_MOUNT;
+			if (strcmp(pm->bsdlabel[pp].pi_mount, mountpt) == 0)
+				pm->bsdlabel[pp].pi_flags &= ~PIF_MOUNT;
 		}
 		strlcpy(p->pi_mount, mountpt, sizeof p->pi_mount);
 		p->pi_flags |= PIF_MOUNT;
@@ -146,7 +146,7 @@ set_ptn_titles(menudesc *m, int opt, void *arg)
 {
 	struct ptn_info *pi = arg;
 	struct ptn_size *p;
-	int sm = MEG / sectorsize;
+	int sm = MEG / pm->sectorsize;
 	daddr_t size;
 	char inc_free[12];
 
@@ -162,7 +162,7 @@ set_ptn_titles(menudesc *m, int opt, void *arg)
 	else
 		inc_free[0] = 0;
 	wprintw(m->mw, "%6" PRIi64 "%8s%10" PRIi64 "%10" PRIi64 " %c %s",
-		size / sm, inc_free, size / dlcylsize, size,
+		size / sm, inc_free, size / pm->dlcylsize, size,
 		p == pi->pool_part ? '+' : ' ', p->mount);
 }
 
@@ -260,15 +260,15 @@ set_ptn_size(menudesc *m, void *arg)
 			mult = 1;
 			break;
 		case 'c':
-			mult = dlcylsize;
+			mult = pm->dlcylsize;
 			break;
 		case 'm':
 		case 'M':
-			mult = MEG / sectorsize;
+			mult = MEG / pm->sectorsize;
 			break;
 		case 'g':
 		case 'G':
-			mult = 1024 * MEG / sectorsize;
+			mult = 1024 * MEG / pm->sectorsize;
 			break;
 		case '+':
 			cp--;
@@ -285,7 +285,7 @@ set_ptn_size(menudesc *m, void *arg)
 			break;
 	}
 
-	size = NUMSEC(size, mult, dlcylsize);
+	size = NUMSEC(size, mult, pm->dlcylsize);
 	if (p->ptn_id == PART_TMP_RAMDISK) {
 		p->size = size;
 		return 0;
@@ -295,7 +295,7 @@ set_ptn_size(menudesc *m, void *arg)
 	if (*cp == '+' && p->limit == 0) {
 		pi->pool_part = p;
 		if (size == 0)
-			size = dlcylsize;
+			size = pm->dlcylsize;
 	}
 	if (p->limit != 0 && size > p->limit)
 		size = p->limit;
@@ -321,9 +321,9 @@ set_ptn_size(menudesc *m, void *arg)
 			 * but keep cylinder alignment
 			 */
 			if (f < 0)
-				f = -roundup(-f, dlcylsize);
+				f = -roundup(-f, pm->dlcylsize);
 			else
-				f = rounddown(f, dlcylsize);
+				f = rounddown(f, pm->dlcylsize);
 			size += f;
 			if (size != 0) {
 				pi->free_space -= f;
@@ -337,6 +337,7 @@ set_ptn_size(menudesc *m, void *arg)
 	return 0;
 }
 
+/* Menu to change sizes of /, /usr, /home and etc. partitions */
 void
 get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 {
@@ -346,7 +347,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 	struct ptn_size *p;
 	daddr_t size;
 
-	static struct ptn_info pi = { -1, {
+	struct ptn_info pi = { -1, {
 #define PI_ROOT 0
 		{ PART_ROOT,	{ '/', '\0' },
 		  DEFROOTSIZE,	DEFROOTSIZE , 0, 0},
@@ -400,7 +401,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 		/* Make size of root include default size of /usr */
 		pi.ptn_sizes[PI_ROOT].size += pi.ptn_sizes[PI_USR].dflt_size;
 
-		sm = MEG / sectorsize;
+		sm = MEG / pm->sectorsize;
 
 		if (root_limit != 0) {
 			/* Bah - bios can not read all the disk, limit root */
@@ -425,14 +426,14 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 		/* Change preset sizes from MB to sectors */
 		pi.free_space = sectors;
 		for (p = pi.ptn_sizes; p->mount[0]; p++) {
-			p->size = NUMSEC(p->size, sm, dlcylsize);
-			p->dflt_size = NUMSEC(p->dflt_size, sm, dlcylsize);
+			p->size = NUMSEC(p->size, sm, pm->dlcylsize);
+			p->dflt_size = NUMSEC(p->dflt_size, sm, pm->dlcylsize);
 			pi.free_space -= p->size;
 		}
 
 		/* Steal space from swap to make things fit.. */
 		if (pi.free_space < 0) {
-			i = roundup(-pi.free_space, dlcylsize);
+			i = roundup(-pi.free_space, pm->dlcylsize);
 			if (i > pi.ptn_sizes[PI_SWAP].size)
 				i = pi.ptn_sizes[PI_SWAP].size;
 			pi.ptn_sizes[PI_SWAP].size -= i;
@@ -441,7 +442,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 
 		/* Add space for 2 system dumps to / (traditional) */
 		i = get_ramsize() * sm;
-		i = roundup(i, dlcylsize);
+		i = roundup(i, pm->dlcylsize);
 		if (pi.free_space > i * 2)
 			i *= 2;
 		if (pi.free_space > i) {
@@ -459,7 +460,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 		/* Count free partition slots */
 		pi.free_parts = 0;
 		for (i = 0; i < maxpart; i++) {
-			if (bsdlabel[i].pi_size == 0)
+			if (pm->bsdlabel[i].pi_size == 0)
 				pi.free_parts++;
 		}
 		for (i = 0; i < MAXPARTITIONS; i++) {
@@ -472,7 +473,6 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 
 		pi.menu_no = new_menu(0, pi.ptn_menus, nelem(pi.ptn_menus),
 			3, -1, 12, 70,
-			MC_NOSHORTCUT |
 			MC_ALWAYS_SCROLL | MC_NOBOX | MC_NOCLEAR,
 			NULL, set_ptn_titles, NULL,
 			"help", pi.exit_msg);
@@ -483,12 +483,12 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 
 	do {
 		set_ptn_menu(&pi);
-		current_cylsize = dlcylsize;
+		pm->current_cylsize = pm->dlcylsize;
 		process_menu(pi.menu_no, &pi);
 	} while (pi.free_space < 0 || pi.free_parts < 0);
 
 	/* Give any cylinder fragment to last partition */
-	if (pi.pool_part != NULL || pi.free_space < dlcylsize) {
+	if (pi.pool_part != NULL || pi.free_space < pm->dlcylsize) {
 		for (p = pi.ptn_sizes + nelem(pi.ptn_sizes) - 1; ;p--) {
 			if (p->size == 0) {
 				if (p == pi.ptn_sizes)
@@ -497,7 +497,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 			}
 			if (p->ptn_id == PART_TMP_RAMDISK)
 				continue;
-			p->size += pi.free_space % dlcylsize;
+			p->size += pi.free_space % pm->dlcylsize;
 			break;
 		}
 	}
@@ -505,7 +505,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap)
 	for (p = pi.ptn_sizes; p->mount[0]; p++, part_start += size) {
 		size = p->size;
 		if (p == pi.pool_part) {
-			size += rounddown(pi.free_space, dlcylsize);
+			size += rounddown(pi.free_space, pm->dlcylsize);
 			if (p->limit != 0 && size > p->limit)
 				size = p->limit;
 		}
@@ -544,45 +544,45 @@ make_bsd_partitions(void)
 	 * Initialize global variables that track space used on this disk.
 	 * Standard 4.4BSD 8-partition labels always cover whole disk.
 	 */
-	if (ptsize == 0)
-		ptsize = dlsize - ptstart;
-	if (dlsize == 0)
-		dlsize = ptstart + ptsize;
+	if (pm->ptsize == 0)
+		pm->ptsize = pm->dlsize - pm->ptstart;
+	if (pm->dlsize == 0)
+		pm->dlsize = pm->ptstart + pm->ptsize;
 
-	partstart = ptstart;
-	ptend = ptstart + ptsize;
+	partstart = pm->ptstart;
+	ptend = pm->ptstart + pm->ptsize;
 
 	/* Ask for layout type -- standard or special */
 	msg_display(MSG_layout,
-		    (int) (ptsize / (MEG / sectorsize)),
+		    (int) (pm->ptsize / (MEG / pm->sectorsize)),
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE,
 		    DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB);
 
 	process_menu(MENU_layout, NULL);
 
 	/* Set so we use the 'real' geometry for rounding, input in MB */
-	current_cylsize = dlcylsize;
+	pm->current_cylsize = pm->dlcylsize;
 	set_sizemultname_meg();
 
 	/* Build standard partitions */
-	memset(&bsdlabel, 0, sizeof bsdlabel);
+	memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);
 
 	/* Set initial partition types to unused */
 	for (part = 0 ; part < maxpart ; ++part)
-		bsdlabel[part].pi_fstype = FS_UNUSED;
+		pm->bsdlabel[part].pi_fstype = FS_UNUSED;
 
 	/* Whole disk partition */
 	part_raw = getrawpartition();
 	if (part_raw == -1)
 		part_raw = PART_C;	/* for sanity... */
-	bsdlabel[part_raw].pi_offset = 0;
-	bsdlabel[part_raw].pi_size = dlsize;
+	pm->bsdlabel[part_raw].pi_offset = 0;
+	pm->bsdlabel[part_raw].pi_size = pm->dlsize;
 
 	if (part_raw == PART_D) {
 		/* Probably a system that expects an i386 style mbr */
 		part_bsd = PART_C;
-		bsdlabel[PART_C].pi_offset = ptstart;
-		bsdlabel[PART_C].pi_size = ptsize;
+		pm->bsdlabel[PART_C].pi_offset = pm->ptstart;
+		pm->bsdlabel[PART_C].pi_size = pm->ptsize;
 	} else {
 		part_bsd = part_raw;
 	}
@@ -591,51 +591,51 @@ make_bsd_partitions(void)
 	i = BOOT_SIZE;
 	if (i >= 1024) {
 		/* Treat big numbers as a byte count */
-		i = (i + dlcylsize * sectorsize - 1) / (dlcylsize * sectorsize);
-		i *= dlcylsize;
+		i = (i + pm->dlcylsize * pm->sectorsize - 1) / (pm->dlcylsize * pm->sectorsize);
+		i *= pm->dlcylsize;
 	}
-	bsdlabel[PART_BOOT].pi_fstype = FS_BOOT;
-	bsdlabel[PART_BOOT].pi_size = i;
+	pm->bsdlabel[PART_BOOT].pi_fstype = FS_BOOT;
+	pm->bsdlabel[PART_BOOT].pi_size = i;
 #ifdef BOOT_HIGH
-	bsdlabel[PART_BOOT].pi_offset = ptend - i;
+	pm->bsdlabel[PART_BOOT].pi_offset = ptend - i;
 	ptend -= i;
 #else
-	bsdlabel[PART_BOOT].pi_offset = ptstart;
+	pm->bsdlabel[PART_BOOT].pi_offset = pm->ptstart;
 	partstart += i;
 #endif
 #elif defined(PART_BOOT)
-	if (bootsize != 0) {
-		bsdlabel[PART_BOOT].pi_fstype = FS_BOOT;
-		bsdlabel[PART_BOOT].pi_size = bootsize;
-		bsdlabel[PART_BOOT].pi_offset = bootstart;
+	if (pm->bootsize != 0) {
+		pm->bsdlabel[PART_BOOT].pi_fstype = FS_BOOT;
+		pm->bsdlabel[PART_BOOT].pi_size = pm->bootsize;
+		pm->bsdlabel[PART_BOOT].pi_offset = pm->bootstart;
 #if defined(PART_BOOT_PI_FLAGS)
-		bsdlabel[PART_BOOT].pi_flags |= PART_BOOT_PI_FLAGS;
+		pm->bsdlabel[PART_BOOT].pi_flags |= PART_BOOT_PI_FLAGS;
 #endif
 #if defined(PART_BOOT_PI_MOUNT)
-		strlcpy(bsdlabel[PART_BOOT].pi_mount, PART_BOOT_PI_MOUNT,
-		    sizeof bsdlabel[PART_BOOT].pi_mount);
+		strlcpy(pm->bsdlabel[PART_BOOT].pi_mount, PART_BOOT_PI_MOUNT,
+		    sizeof pm->bsdlabel[PART_BOOT].pi_mount);
 #endif
 	}
 #endif /* PART_BOOT w/o BOOT_SIZE */
 
 #if defined(PART_SYSVBFS) && defined(SYSVBFS_SIZE)
-	bsdlabel[PART_SYSVBFS].pi_offset = partstart;
-	bsdlabel[PART_SYSVBFS].pi_fstype = FS_SYSVBFS;
-	bsdlabel[PART_SYSVBFS].pi_size = SYSVBFS_SIZE;
-	bsdlabel[PART_SYSVBFS].pi_flags |= PIF_NEWFS | PIF_MOUNT;
-	strlcpy(bsdlabel[PART_SYSVBFS].pi_mount, "/stand",
-	    sizeof bsdlabel[PART_SYSVBFS].pi_mount);
+	pm->bsdlabel[PART_SYSVBFS].pi_offset = partstart;
+	pm->bsdlabel[PART_SYSVBFS].pi_fstype = FS_SYSVBFS;
+	pm->bsdlabel[PART_SYSVBFS].pi_size = SYSVBFS_SIZE;
+	pm->bsdlabel[PART_SYSVBFS].pi_flags |= PIF_NEWFS | PIF_MOUNT;
+	strlcpy(pm->bsdlabel[PART_SYSVBFS].pi_mount, "/stand",
+	    sizeof pm->bsdlabel[PART_SYSVBFS].pi_mount);
 	partstart += SYSVBFS_SIZE;
 #endif
 
 #ifdef PART_REST
-	bsdlabel[PART_REST].pi_offset = 0;
-	bsdlabel[PART_REST].pi_size = ptstart;
+	pm->bsdlabel[PART_REST].pi_offset = 0;
+	pm->bsdlabel[PART_REST].pi_size = pm->ptstart;
 #endif
 
 	if (layoutkind == 4) {
 		/*
-		 * If 'oldlabel' is a default label created by the kernel it
+		 * If 'pm->oldlabel' is a default label created by the kernel it
 		 * will have exactly one valid partition besides raw_part
 		 * which covers the whole disk - but might lie outside the
 		 * mbr partition we (by now) have offset by a few sectors.
@@ -645,7 +645,7 @@ make_bsd_partitions(void)
 		for (i = 0; i < maxpart; i++) {
 			if (i == part_raw)
 				continue;
-			if (oldlabel[i].pi_size > 0 && PI_ISBSDFS(&oldlabel[i])) {
+			if (pm->oldlabel[i].pi_size > 0 && PI_ISBSDFS(&pm->oldlabel[i])) {
 				if (valid_part >= 0) {
 					/* nope, not the default case */
 					valid_part = -1;
@@ -654,9 +654,9 @@ make_bsd_partitions(void)
 				valid_part = i;
 			}
 		}
-		if (valid_part >= 0 && oldlabel[valid_part].pi_offset < ptstart) {
-			oldlabel[valid_part].pi_offset = ptstart;
-			oldlabel[valid_part].pi_size -= ptstart;
+		if (valid_part >= 0 && pm->oldlabel[valid_part].pi_offset < pm->ptstart) {
+			pm->oldlabel[valid_part].pi_offset = pm->ptstart;
+			pm->oldlabel[valid_part].pi_size -= pm->ptstart;
 		}
 	}
 
@@ -667,10 +667,10 @@ make_bsd_partitions(void)
 	 * partitions on a multiboot i386 system.
 	 */
 	 for (i = maxpart; i--;) {
-		if (bsdlabel[i].pi_size != 0)
+		if (pm->bsdlabel[i].pi_size != 0)
 			/* Don't overwrite special partitions */
 			continue;
-		p = &oldlabel[i];
+		p = &pm->oldlabel[i];
 		if (p->pi_fstype == FS_UNUSED || p->pi_size == 0)
 			continue;
 		if (layoutkind == 4) {
@@ -684,14 +684,14 @@ make_bsd_partitions(void)
 				}
 			}
 		} else {
-			if (p->pi_offset < ptstart + ptsize &&
-			    p->pi_offset + p->pi_size > ptstart)
+			if (p->pi_offset < pm->ptstart + pm->ptsize &&
+			    p->pi_offset + p->pi_size > pm->ptstart)
 				/* Not outside area we are allocating */
 				continue;
 			if (p->pi_fstype == FS_SWAP)
 				no_swap = 1;
 		}
-		bsdlabel[i] = oldlabel[i];
+		pm->bsdlabel[i] = pm->oldlabel[i];
 	 }
 
 	if (layoutkind != 4)
@@ -702,18 +702,18 @@ make_bsd_partitions(void)
 	 * edit it and verify it's OK, or abort altogether.
 	 */
  edit_check:
-	if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) {
+	if (edit_and_check_label(pm->bsdlabel, maxpart, part_raw, part_bsd) == 0) {
 		msg_display(MSG_abort);
 		return 0;
 	}
-	if (check_partitions() == 0)
+	if (partman_go == 0 && check_partitions() == 0)
 		goto edit_check;
 
 	/* Disk name */
-	msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname);
+	msg_prompt(MSG_packname, pm->bsddiskname, pm->bsddiskname, sizeof pm->bsddiskname);
 
 	/* save label to disk for MI code to update. */
-	(void) savenewlabel(bsdlabel, maxpart);
+	(void) savenewlabel(pm->bsdlabel, maxpart);
 
 	/* Everything looks OK. */
 	return (1);
@@ -746,9 +746,9 @@ check_partitions(void)
 	}
 #endif
 #ifndef HAVE_UFS2_BOOT
-	fstype = bsdlabel[rootpart].pi_fstype;
+	fstype = pm->bsdlabel[rootpart].pi_fstype;
 	if (fstype == FS_BSDFFS &&
-	    (bsdlabel[rootpart].pi_flags & PIF_FFSv2) != 0) {
+	    (pm->bsdlabel[rootpart].pi_flags & PIF_FFSv2) != 0) {
 		process_menu(MENU_ok, deconst(MSG_cannot_ufs2_root));
 		return 0;
 	}
diff --git a/distrib/utils/sysinst/configmenu.c b/distrib/utils/sysinst/configmenu.c
index d8eedde..5593d02 100644
--- a/distrib/utils/sysinst/configmenu.c
+++ b/distrib/utils/sysinst/configmenu.c
@@ -94,7 +94,7 @@ configinfo config_list[] = {
 	{MSG_enable_mdnsd, CONFIGOPT_MDNSD, "mdnsd", toggle_rcvar, NULL},
 	{"Enable XDM", CONFIGOPT_XDM, "xdm", toggle_rcvar, NULL},
 	{NULL,		CONFIGOPT_LAST,	NULL, NULL, NULL}
-}; //TODO XDM
+}; // TODO: XDM
 
 static void
 config_list_init(void)
@@ -413,6 +413,7 @@ do_configmenu()
 
 	/* if the target isn't mounted already, figure it out. */
 	if (target_mounted() == 0) {
+		partman_go = 1;
 		if (find_disks(msg_string(MSG_configure_prior)) < 0)
 			return;
 
diff --git a/distrib/utils/sysinst/defs.h b/distrib/utils/sysinst/defs.h
index 14630fb..f47b3d4 100644
--- a/distrib/utils/sysinst/defs.h
+++ b/distrib/utils/sysinst/defs.h
@@ -51,6 +51,7 @@ deconst(const void *p)
 
 #include "msg_defs.h"
 #include "menu_defs.h"
+#include "mbr.h"
 
 #define min(a,b)	((a) < (b) ? (a) : (b))
 #define max(a,b)	((a) > (b) ? (a) : (b))
@@ -208,6 +209,8 @@ typedef struct _partinfo {
 #define PIF_LOG		0x0800		/* mount -o log */
 #define PIF_MOUNT_OPTS	0x0ff0		/* all above mount flags */
 #define PIF_RESET	0x1000		/* internal - restore previous values */
+    const char *mnt_opts;
+    const char *fsname;
 } partinfo;	/* Single partition from a disklabel */
 
 struct ptn_info {
@@ -241,42 +244,62 @@ pid_t ttysig_forward;
 int layoutkind;
 int sizemult;
 const char *multname;
+int partman_go;   /* run partition manager */
+int fstab_prepared; /* Should we create new /etc/fstab or append old? */
 
-/* loging variables */
+/* logging variables */
 
 FILE *logfp;
 FILE *script;
 
-/* Actual name of the disk. */
-char diskdev[SSTRSIZE];
-int no_mbr;				/* set for raid (etc) */
+
 int rootpart;				/* partition we install into */
 const char *disktype;		/* ST506, SCSI, ... */
-
-/* Area of disk we can allocate, start and size in disk sectors. */
-daddr_t ptstart, ptsize;
-/* If we have an MBR boot partition, start and size in sectors */
-int bootstart, bootsize;
-
-/* Actual values for current disk - set by find_disks() or md_get_info() */
-int sectorsize;
-int dlcyl, dlhead, dlsec, dlcylsize;
-daddr_t dlsize;
-int current_cylsize;
-unsigned int root_limit;		/* BIOS (etc) read limit */
+unsigned int root_limit;    /* BIOS (etc) read limit */
 
 /* Information for the NetBSD disklabel */
 enum DLTR { PART_A, PART_B, PART_C, PART_D, PART_E, PART_F, PART_G, PART_H,
 	    PART_I, PART_J, PART_K, PART_L, PART_M, PART_N, PART_O, PART_P};
 #define partition_name(x)	('a' + (x))
-partinfo oldlabel[MAXPARTITIONS];	/* What we found on the disk */
-partinfo bsdlabel[MAXPARTITIONS];	/* What we want it to look like */
 daddr_t tmp_ramdisk_size;
 
 #define DISKNAME_SIZE 16
-char bsddiskname[DISKNAME_SIZE];
+char bsddiskname[DISKNAME_SIZE]; // TODO: xxx
 const char *doessf;
 
+/* Information for extended partition manager */
+typedef struct pm_devs_t {
+    /* Actual name of the disk. */
+    char diskdev[SSTRSIZE];
+    char diskdev_descr[STRSIZE];
+    char id_dk[SSTRSIZE];
+    int bootable;
+    char bsddiskname[DISKNAME_SIZE];
+    partinfo oldlabel[MAXPARTITIONS]; /* What we found on the disk */
+    partinfo bsdlabel[MAXPARTITIONS]; /* What we want it to look like */
+    mbr_info_t mbr;
+    int no_mbr; /* set for raid (etc) */
+    int use_gpt;
+    /* Actual values for current disk - set by find_disks() or md_get_info() */
+    int sectorsize, dlcyl, dlhead, dlsec, dlcylsize, current_cylsize;
+    daddr_t dlsize;
+    /* Area of disk we can allocate, start and size in disk sectors. */
+    daddr_t ptstart, ptsize;
+    /* If we have an MBR boot partition, start and size in sectors */
+    int bootstart, bootsize;
+    struct pm_devs_t *next;
+} pm_devs_t;
+pm_devs_t *pm_devs; /* Pointer to head of list with all devices */
+pm_devs_t *pm_found; /* Pointer to selected in find_disks device
+                        (when extended partition manager isn't used) */
+pm_devs_t *pm; /* Pointer to currend device with which we work */
+
+#define MNTS_MAX 100
+struct {
+    const char *diskdev, *mnt_opts, *fsname;
+    char *pi_mount;
+} mnts[MNTS_MAX];
+
 /* Relative file name for storing a distribution. */
 char xfer_dir[STRSIZE];
 int  clean_xfer_dir;
@@ -390,7 +413,14 @@ int	mount_disks(void);
 int	set_swap(const char *, partinfo *);
 int	check_swap(const char *, int);
 char	*bootxx_name(void);
-int	partitioning(void);
+int	partman(void);
+int partman_adddisk(menudesc *, void *);
+int partman_addvnd(menudesc *, void *);
+int partman_deldev(menudesc *, void *);
+int partman_commit(menudesc *, void *);
+int partman_mountall(void);
+void partman_menufmt(menudesc *, int, void *);
+void partman_select(pm_devs_t *);
 
 /* from disks_lfs.c */
 int	fs_is_lfs(void *);
diff --git a/distrib/utils/sysinst/disks.c b/distrib/utils/sysinst/disks.c
index f7c41e9..be1c612 100644
--- a/distrib/utils/sysinst/disks.c
+++ b/distrib/utils/sysinst/disks.c
@@ -360,7 +360,7 @@ int
 find_disks(const char *doingwhat)
 {
 	struct disk_desc disks[MAX_DISKS];
-	menu_ent dsk_menu[nelem(disks)];
+	menu_ent dsk_menu[nelem(disks) + !partman_go];
 	struct disk_desc *disk;
 	int i;
 	int numdisks;
@@ -390,8 +390,15 @@ find_disks(const char *doingwhat)
 			dsk_menu[i].opt_flags = OPT_EXIT;
 			dsk_menu[i].opt_action = set_dsk_select;
 		}
+		if (partman_go == 0) {
+			dsk_menu[i].opt_name = "Extended partitioning"; // TODO: localize
+			dsk_menu[i].opt_menu = OPT_NOMENU;
+			dsk_menu[i].opt_flags = OPT_EXIT;
+			dsk_menu[i].opt_action = set_dsk_select;
+		}
+
 		menu_no = new_menu(MSG_Available_disks,
-			dsk_menu, numdisks, -1, 4, 0, 0,
+			dsk_menu, numdisks + !partman_go, -1, 4, 0, 0,
 			MC_SCROLL,
 			NULL, NULL, NULL, NULL, NULL);
 		if (menu_no == -1)
@@ -403,34 +410,41 @@ find_disks(const char *doingwhat)
 
 	if (selected_disk == -1)
 	    return -1;
+	if (selected_disk == numdisks) {
+		partman_go = 1;
+	    return -2;
+	}
 
 	disk = disks + selected_disk;
-	strlcpy(diskdev, disk->dd_name, sizeof diskdev);
+	pm = pm_found;
+	pm->bootable = 0;
+	strlcpy(pm->diskdev, disk->dd_name, sizeof pm->diskdev);
+	strlcpy(pm->diskdev_descr, disk->dd_descr, sizeof pm->diskdev_descr);
 
 	/* Use as a default disk if the user has the sets on a local disk */
-	strlcpy(localfs_dev, disk->dd_name, sizeof localfs_dev);
-
-	sectorsize = disk->dd_secsize;
-	dlcyl = disk->dd_cyl;
-	dlhead = disk->dd_head;
-	dlsec = disk->dd_sec;
-	dlsize = disk->dd_totsec;
-	no_mbr = disk->dd_no_mbr;
-	if (dlsize == 0)
-		dlsize = disk->dd_cyl * disk->dd_head * disk->dd_sec;
-	if (dlsize > UINT32_MAX) {
+	strlcpy(localfs_dev, disk->dd_name, sizeof localfs_dev); // TODO: sss
+
+	pm->sectorsize = disk->dd_secsize;
+	pm->dlcyl = disk->dd_cyl;
+	pm->dlhead = disk->dd_head;
+	pm->dlsec = disk->dd_sec;
+	pm->dlsize = disk->dd_totsec;
+	pm->no_mbr = disk->dd_no_mbr;
+	if (pm->dlsize == 0)
+		pm->dlsize = disk->dd_cyl * disk->dd_head * disk->dd_sec;
+	if (pm->dlsize > UINT32_MAX) {
 		msg_display(MSG_toobigdisklabel);
 		process_menu(MENU_ok, NULL);
 		return -1;
 	}
-	dlcylsize = dlhead * dlsec;
+	pm->dlcylsize = pm->dlhead * pm->dlsec;
 
 	/* Get existing/default label */
-	memset(&oldlabel, 0, sizeof oldlabel);
-	incorelabel(diskdev, oldlabel);
+	memset(&pm->oldlabel, 0, sizeof pm->oldlabel);
+	incorelabel(pm->diskdev, pm->oldlabel);
 
 	/* Set 'target' label to current label in case we don't change it */
-	memcpy(&bsdlabel, &oldlabel, sizeof bsdlabel);
+	memcpy(&pm->bsdlabel, &pm->oldlabel, sizeof pm->bsdlabel);
 
 	return numdisks;
 }
@@ -441,7 +455,7 @@ fmt_fspart(menudesc *m, int ptn, void *arg)
 	unsigned int poffset, psize, pend;
 	const char *desc;
 	static const char *Yes, *No;
-	partinfo *p = bsdlabel + ptn;
+	partinfo *p = pm->bsdlabel + ptn;
 
 	if (Yes == NULL) {
 		Yes = msg_string(MSG_Yes);
@@ -499,7 +513,7 @@ write_disklabel (void)
 #ifdef DISKLABEL_CMD
 	/* disklabel the disk */
 	return run_program(RUN_DISPLAY, "%s -f /tmp/disktab %s '%s'",
-	    DISKLABEL_CMD, diskdev, bsddiskname);
+	    DISKLABEL_CMD, pm->diskdev, pm->bsddiskname);
 #else
 	return 0;
 #endif
@@ -509,8 +523,8 @@ write_disklabel (void)
 static int
 ptn_sort(const void *a, const void *b)
 {
-	return strcmp(bsdlabel[*(const int *)a].pi_mount,
-		      bsdlabel[*(const int *)b].pi_mount);
+	return strcmp(pm->bsdlabel[*(const int *)a].pi_mount,
+		      pm->bsdlabel[*(const int *)b].pi_mount);
 }
 
 int
@@ -518,16 +532,14 @@ make_filesystems(void)
 {
 	unsigned int i;
 	int ptn;
-	int ptn_order[nelem(bsdlabel)];
+	int ptn_order[nelem(pm->bsdlabel)];
 	int error = 0;
 	unsigned int maxpart = getmaxpartitions();
 	char *newfs;
-	const char *mnt_opts;
-	const char *fsname;
 	partinfo *lbl;
 
-	if (maxpart > nelem(bsdlabel))
-		maxpart = nelem(bsdlabel);
+	if (maxpart > nelem(pm->bsdlabel))
+		maxpart = nelem(pm->bsdlabel);
 
 	/* Making new file systems and mounting them */
 
@@ -543,9 +555,9 @@ make_filesystems(void)
 		 * point defined, or is marked preserve, don't touch it!
 		 */
 		ptn = ptn_order[i];
-		lbl = bsdlabel + ptn;
+		lbl = pm->bsdlabel + ptn;
 
-		if (is_active_rootpart(diskdev, ptn))
+		if (is_active_rootpart(pm->diskdev, ptn))
 			continue;
 
 		if (*lbl->pi_mount == 0)
@@ -553,14 +565,14 @@ make_filesystems(void)
 			continue;
 
 		newfs = NULL;
-		mnt_opts = NULL;
-		fsname = NULL;
+		lbl->mnt_opts = NULL;
+		lbl->fsname = NULL;
 		switch (lbl->pi_fstype) {
 		case FS_APPLEUFS:
 			asprintf(&newfs, "/sbin/newfs %s%.0d",
 				lbl->pi_isize != 0 ? "-i" : "", lbl->pi_isize);
-			mnt_opts = "-tffs -o async";
-			fsname = "ffs";
+			lbl->mnt_opts = "-tffs -o async";
+			lbl->fsname = "ffs";
 			break;
 		case FS_BSDFFS:
 			asprintf(&newfs,
@@ -569,36 +581,36 @@ make_filesystems(void)
 			    lbl->pi_fsize * lbl->pi_frag, lbl->pi_fsize,
 			    lbl->pi_isize != 0 ? " -i " : "", lbl->pi_isize);
 			if (lbl->pi_flags & PIF_LOG)
-				mnt_opts = "-tffs -o log";
+				lbl->mnt_opts = "-tffs -o log";
 			else
-				mnt_opts = "-tffs -o async";
-			fsname = "ffs";
+				lbl->mnt_opts = "-tffs -o async";
+			lbl->fsname = "ffs";
 			break;
 		case FS_BSDLFS:
 			asprintf(&newfs, "/sbin/newfs_lfs -b %d",
 				lbl->pi_fsize * lbl->pi_frag);
-			mnt_opts = "-tlfs";
-			fsname = "lfs";
+			lbl->mnt_opts = "-tlfs";
+			lbl->fsname = "lfs";
 			break;
 		case FS_MSDOS:
 #ifdef USE_NEWFS_MSDOS
 			asprintf(&newfs, "/sbin/newfs_msdos");
 #endif
-			mnt_opts = "-tmsdos";
-			fsname = "msdos";
+			lbl->mnt_opts = "-tmsdos";
+			lbl->fsname = "msdos";
 			break;
 #ifdef USE_SYSVBFS
 		case FS_SYSVBFS:
 			asprintf(&newfs, "/sbin/newfs_sysvbfs");
-			mnt_opts = "-tsysvbfs";
-			fsname = "sysvbfs";
+			lbl->mnt_opts = "-tsysvbfs";
+			lbl->fsname = "sysvbfs";
 			break;
 #endif
 #ifdef USE_EXT2FS
 		case FS_EX2FS:
 			asprintf(&newfs, "/sbin/newfs_ext2fs");
-			mnt_opts = "-text2fs";
-			fsname = "ext2fs";
+			lbl->mnt_opts = "-text2fs";
+			lbl->fsname = "ext2fs";
 			break;
 #endif
 		}
@@ -608,11 +620,11 @@ make_filesystems(void)
 			        /* newfs only if mount fails */
 			        if (run_program(RUN_SILENT | RUN_ERROR_OK,
 				    "mount -rt msdos /dev/%s%c /mnt2",
-				    diskdev, 'a' + ptn) != 0)
+				    pm->diskdev, 'a' + ptn) != 0)
 					error = run_program(
 					    RUN_DISPLAY | RUN_PROGRESS,
 					    "%s /dev/r%s%c",
-					    newfs, diskdev, 'a' + ptn);
+					    newfs, pm->diskdev, 'a' + ptn);
 				else {
 			        	run_program(RUN_SILENT | RUN_ERROR_OK,
 					    "umount /mnt2");
@@ -621,10 +633,10 @@ make_filesystems(void)
 			} else
 #endif
 			error = run_program(RUN_DISPLAY | RUN_PROGRESS,
-			    "%s /dev/r%s%c", newfs, diskdev, 'a' + ptn);
+			    "%s /dev/r%s%c", newfs, pm->diskdev, 'a' + ptn);
 		} else {
 			/* We'd better check it isn't dirty */
-			error = fsck_preen(diskdev, ptn, fsname);
+			error = fsck_preen(pm->diskdev, ptn, lbl->fsname);
 		}
 		free(newfs);
 		if (error != 0)
@@ -632,13 +644,14 @@ make_filesystems(void)
 
 		md_pre_mount();
 
-		if (lbl->pi_flags & PIF_MOUNT && mnt_opts != NULL) {
+		if (partman_go == 0 && lbl->pi_flags & PIF_MOUNT &&
+				lbl->mnt_opts != NULL) {
 			make_target_dir(lbl->pi_mount);
-			error = target_mount(mnt_opts, diskdev, ptn,
+			error = target_mount(lbl->mnt_opts, pm->diskdev, ptn,
 					    lbl->pi_mount);
 			if (error) {
 				msg_display(MSG_mountfail,
-					    diskdev, 'a' + ptn, lbl->pi_mount);
+					    pm->diskdev, 'a' + ptn, lbl->pi_mount);
 				process_menu(MENU_ok, NULL);
 				return error;
 			}
@@ -655,30 +668,35 @@ make_fstab(void)
 	const char *dump_dev;
 
 	/* Create the fstab. */
-	make_target_dir("/etc");
-	f = target_fopen("/etc/fstab", "w");
+	if (fstab_prepared == 0) {
+		make_target_dir("/etc");
+		f = target_fopen("/etc/fstab", "w");
+		scripting_fprintf(NULL, "cat <<EOF >%s/etc/fstab\n", target_prefix());
+	} else {
+		f = target_fopen("/etc/fstab", "a");
+		scripting_fprintf(NULL, "cat <<EOF >>%s/etc/fstab\n", target_prefix());
+	}
 	if (logfp)
 		(void)fprintf(logfp,
-		    "Creating %s/etc/fstab.\n", target_prefix());
-	scripting_fprintf(NULL, "cat <<EOF >%s/etc/fstab\n", target_prefix());
-
+		    "Making %s/etc/fstab (%s).\n", target_prefix(), pm->diskdev);
+	
 	if (f == NULL) {
-#ifndef DEBUG
 		msg_display(MSG_createfstab);
 		if (logfp)
 			(void)fprintf(logfp, "Failed to make /etc/fstab!\n");
 		process_menu(MENU_ok, NULL);
+#ifndef DEBUG
 		return 1;
 #else
 		f = stdout;
 #endif
 	}
-
-	scripting_fprintf(f, "# NetBSD %s/etc/fstab\n# See /usr/share/examples/"
-		"fstab/ for more examples.\n", target_prefix());
+	if (!fstab_prepared)
+		scripting_fprintf(f, "# NetBSD %s/etc/fstab\n# See /usr/share/examples/"
+			"fstab/ for more examples.\n", target_prefix());
 	for (i = 0; i < getmaxpartitions(); i++) {
 		const char *s = "";
-		const char *mp = bsdlabel[i].pi_mount;
+		const char *mp = pm->bsdlabel[i].pi_mount;
 		const char *fstype = "ffs";
 		int fsck_pass = 0, dump_freq = 0;
 
@@ -691,7 +709,7 @@ make_fstab(void)
 			mp = "/mnt";
 		}
 
-		switch (bsdlabel[i].pi_fstype) {
+		switch (pm->bsdlabel[i].pi_fstype) {
 		case FS_UNUSED:
 			continue;
 		case FS_BSDLFS:
@@ -718,7 +736,7 @@ make_fstab(void)
 				dump_dev ="";
 			}
 			scripting_fprintf(f, "/dev/%s%c\t\tnone\tswap\tsw%s\t\t 0 0\n",
-				diskdev, 'a' + i, dump_dev);
+				pm->diskdev, 'a' + i, dump_dev);
 			continue;
 #ifdef USE_SYSVBFS
 		case FS_SYSVBFS:
@@ -732,52 +750,53 @@ make_fstab(void)
 			break;
 		}
 		/* The code that remounts root rw doesn't check the partition */
-		if (strcmp(mp, "/") == 0 && !(bsdlabel[i].pi_flags & PIF_MOUNT))
+		if (strcmp(mp, "/") == 0 && !(pm->bsdlabel[i].pi_flags & PIF_MOUNT))
 			s = "# ";
 
  		scripting_fprintf(f,
 		  "%s/dev/%s%c\t\t%s\t%s\trw%s%s%s%s%s%s%s%s\t\t %d %d\n",
-		   s, diskdev, 'a' + i, mp, fstype,
-		   bsdlabel[i].pi_flags & PIF_LOG ? ",log" : "",
-		   bsdlabel[i].pi_flags & PIF_MOUNT ? "" : ",noauto",
-		   bsdlabel[i].pi_flags & PIF_ASYNC ? ",async" : "",
-		   bsdlabel[i].pi_flags & PIF_NOATIME ? ",noatime" : "",
-		   bsdlabel[i].pi_flags & PIF_NODEV ? ",nodev" : "",
-		   bsdlabel[i].pi_flags & PIF_NODEVMTIME ? ",nodevmtime" : "",
-		   bsdlabel[i].pi_flags & PIF_NOEXEC ? ",noexec" : "",
-		   bsdlabel[i].pi_flags & PIF_NOSUID ? ",nosuid" : "",
+		   s, pm->diskdev, 'a' + i, mp, fstype,
+		   pm->bsdlabel[i].pi_flags & PIF_LOG ? ",log" : "",
+		   pm->bsdlabel[i].pi_flags & PIF_MOUNT ? "" : ",noauto",
+		   pm->bsdlabel[i].pi_flags & PIF_ASYNC ? ",async" : "",
+		   pm->bsdlabel[i].pi_flags & PIF_NOATIME ? ",noatime" : "",
+		   pm->bsdlabel[i].pi_flags & PIF_NODEV ? ",nodev" : "",
+		   pm->bsdlabel[i].pi_flags & PIF_NODEVMTIME ? ",nodevmtime" : "",
+		   pm->bsdlabel[i].pi_flags & PIF_NOEXEC ? ",noexec" : "",
+		   pm->bsdlabel[i].pi_flags & PIF_NOSUID ? ",nosuid" : "",
 		   dump_freq, fsck_pass);
 	}
-
-	if (tmp_ramdisk_size != 0) {
+	if (!fstab_prepared) {
+		if (tmp_ramdisk_size != 0) {
 #ifdef HAVE_TMPFS
-		scripting_fprintf(f, "tmpfs\t\t/tmp\ttmpfs\trw,-m=1777,-s=%"
-		    PRIi64 "\n",
-		    tmp_ramdisk_size * 512);
-#else
-		if (swap_dev != -1)
-			scripting_fprintf(f, "/dev/%s%c\t\t/tmp\tmfs\trw,-s=%"
+			scripting_fprintf(f, "tmpfs\t\t/tmp\ttmpfs\trw,-m=1777,-s=%"
 			    PRIi64 "\n",
-			    diskdev, 'a' + swap_dev, tmp_ramdisk_size);
-		else
-			scripting_fprintf(f, "swap\t\t/tmp\tmfs\trw,-s=%"
-			    PRIi64 "\n",
-			    tmp_ramdisk_size);
+			    tmp_ramdisk_size * 512);
+#else
+			if (swap_dev != -1)
+				scripting_fprintf(f, "/dev/%s%c\t\t/tmp\tmfs\trw,-s=%"
+				    PRIi64 "\n",
+				    pm->diskdev, 'a' + swap_dev, tmp_ramdisk_size);
+			else
+				scripting_fprintf(f, "swap\t\t/tmp\tmfs\trw,-s=%"
+				    PRIi64 "\n",
+				    tmp_ramdisk_size);
 #endif
-	}
-
-	/* Add /kern, /proc and /dev/pts to fstab and make mountpoint. */
-	scripting_fprintf(f, "kernfs\t\t/kern\tkernfs\trw\n");
-	scripting_fprintf(f, "ptyfs\t\t/dev/pts\tptyfs\trw\n");
-	scripting_fprintf(f, "procfs\t\t/proc\tprocfs\trw\n");
-	scripting_fprintf(f, "/dev/" CD_NAME "\t\t/cdrom\tcd9660\tro,noauto\n");
-	make_target_dir("/kern");
-	make_target_dir("/proc");
-	make_target_dir("/dev/pts");
-	make_target_dir("/cdrom");
+		}
 
+		/* Add /kern, /proc and /dev/pts to fstab and make mountpoint. */
+		scripting_fprintf(f, "kernfs\t\t/kern\tkernfs\trw\n");
+		scripting_fprintf(f, "ptyfs\t\t/dev/pts\tptyfs\trw\n");
+		scripting_fprintf(f, "procfs\t\t/proc\tprocfs\trw\n");
+		scripting_fprintf(f, "/dev/" CD_NAME "\t\t/cdrom\tcd9660\tro,noauto\n");
+		make_target_dir("/kern");
+		make_target_dir("/proc");
+		make_target_dir("/dev/pts");
+		make_target_dir("/cdrom");
+	}
 	scripting_fprintf(NULL, "EOF\n");
 
+	fstab_prepared = 1;
 #ifndef DEBUG
 	fclose(f);
 	fflush(NULL);
@@ -919,7 +938,7 @@ mount_root(void)
 {
 	int	error;
 
-	error = fsck_preen(diskdev, rootpart, "ffs");
+	error = fsck_preen(pm->diskdev, rootpart, "ffs");
 	if (error != 0)
 		return error;
 
@@ -931,7 +950,7 @@ mount_root(void)
 	 * XXX consider -o remount in case target root is
 	 * current root, still readonly from single-user?
 	 */
-	return target_mount("", diskdev, rootpart, "");
+	return target_mount("", pm->diskdev, rootpart, "");
 }
 
 /* Get information on the file systems mounted from the root filesystem.
@@ -969,7 +988,7 @@ mount_disks(void)
 	/* Check the target /etc/fstab exists before trying to parse it. */
 	if (target_dir_exists_p("/etc") == 0 ||
 	    target_file_exists_p("/etc/fstab") == 0) {
-		msg_display(MSG_noetcfstab, diskdev);
+		msg_display(MSG_noetcfstab, pm->diskdev);
 		process_menu(MENU_ok, NULL);
 		return 0;
 	}
@@ -979,7 +998,7 @@ mount_disks(void)
 	fstabsize = target_collect_file(T_FILE, &fstab, "/etc/fstab");
 	if (fstabsize < 0) {
 		/* error ! */
-		msg_display(MSG_badetcfstab, diskdev);
+		msg_display(MSG_badetcfstab, pm->diskdev);
 		process_menu(MENU_ok, NULL);
 		return 0;
 	}
@@ -997,7 +1016,7 @@ set_swap(const char *disk, partinfo *pp)
 	int rval;
 
 	if (pp == NULL)
-		pp = oldlabel;
+		pp = pm->oldlabel;
 
 	for (i = 0; i < MAXPARTITIONS; i++) {
 		if (pp[i].pi_fstype != FS_SWAP)
@@ -1073,11 +1092,11 @@ bootxx_name(void)
 	char *bootxx;
 
 	/* check we have boot code for the root partition type */
-	fstype = bsdlabel[rootpart].pi_fstype;
+	fstype = pm->bsdlabel[rootpart].pi_fstype;
 	switch (fstype) {
 #if defined(BOOTXX_FFSV1) || defined(BOOTXX_FFSV2)
 	case FS_BSDFFS:
-		if (bsdlabel[rootpart].pi_flags & PIF_FFSv2) {
+		if (pm->bsdlabel[rootpart].pi_flags & PIF_FFSv2) {
 #ifdef BOOTXX_FFSV2
 			bootxxname = BOOTXX_FFSV2;
 #else
@@ -1110,55 +1129,288 @@ bootxx_name(void)
 }
 #endif
 
-// TODO: write new partition tool there
+
+
+
+void
+partman_select(pm_devs_t *pm_devs_in)
+{
+	pm = pm_devs_in;
+	if (logfp)
+		(void)fprintf(logfp,"Partman device: %s\n", pm->diskdev);
+	return;
+
+}
+
+// TODO: mount order
+static int
+partman_mountall_sort(const void *a, const void *b)
+{
+	return strcmp(mnts[*(const int *)a].pi_mount,
+		      mnts[*(const int *)b].pi_mount);
+}
+
 int
-partitioning(void)
+partman_mountall(void)
 {
+	pm_devs_t *pm_devs_i;
+	int num_devs = 0;
+	int i, error;
+
+	int mnts_order[MNTS_MAX]; // TODO: rewrite
+	for (pm_devs_i = pm_devs->next, num_devs = 0; pm_devs_i != NULL;
+			pm_devs_i = pm_devs_i->next) {
+		fprintf(logfp,"::%s\n",pm_devs_i->diskdev); fflush(logfp);
+		for (i = 0; i < MAXPARTITIONS; i++) {
+			if (pm_devs_i->bsdlabel[i].pi_flags & PIF_MOUNT &&
+					pm_devs_i->bsdlabel[i].mnt_opts != NULL) {
+				mnts[num_devs].diskdev = pm_devs_i->diskdev;
+				mnts[num_devs].mnt_opts = pm_devs_i->bsdlabel[i].mnt_opts;
+				mnts[num_devs].fsname = pm_devs_i->bsdlabel[i].fsname;
+				mnts[num_devs].pi_mount = pm_devs_i->bsdlabel[i].pi_mount;
+				num_devs++;
+				fprintf(logfp,":::%s\n",mnts[num_devs].pi_mount); fflush(logfp);
+			}
+		}
+	}
+	for (i = 0; i < num_devs; i++)
+		mnts_order[i] = i;
+	qsort(mnts_order, num_devs, sizeof mnts_order[0], partman_mountall_sort);
+
+	for (i = 0; i < num_devs; i++) {
+		make_target_dir(mnts[i].pi_mount);
+		error = target_mount(mnts[i].mnt_opts, pm->diskdev, i, mnts[i].pi_mount);
+		if (error) {
+			msg_display(MSG_mountfail, pm->diskdev, 'a' + i, mnts[i].pi_mount);
+			process_menu(MENU_ok, NULL);
+			return error;
+		}
+	}
+	return 0;
+}
+
+int
+partman_adddisk(menudesc *m, void *arg)
+{
+	*(int *)arg = m->cursel + 1;
+	pm_devs_t *pm_devs_tmp;
+
 	if (find_disks(msg_string(MSG_install)) < 0)
 		return -1;
+
 	clear();
 	refresh();
 
-	if (check_swap(diskdev, 0) > 0) {
+	if (check_swap(pm->diskdev, 0) > 0) {
 		msg_display(MSG_swapactive);
 		process_menu(MENU_ok, NULL);
-		if (check_swap(diskdev, 1) < 0) {
+		if (check_swap(pm->diskdev, 1) < 0) {
 			msg_display(MSG_swapdelfailed);
 			process_menu(MENU_ok, NULL);
-			if (!debug)
-				return -1;
+			return -1;
 		}
 	}
 
-	if (md_get_info() == 0)
-		return -1;
-	if (md_make_bsd_partitions() == 0)
-		return -1;
+	for (pm_devs_tmp = pm_devs; pm_devs_tmp->next != NULL;
+			pm_devs_tmp = pm_devs_tmp->next)
+		if (strcmp(pm_devs_tmp->next->diskdev, pm->diskdev) == 0)
+			return 0;
+	pm_devs_tmp->next = pm_found;
 
-	/* Last chance ... do you really want to do this? */
-	clear();
-	refresh();
-	msg_display(MSG_lastchance, diskdev);
-	process_menu(MENU_noyes, NULL);
-	if (!yesno)
-		return -1;
+	pm_found = malloc(sizeof (pm_devs_t));
+	pm_found->next = NULL;
 
-	if (md_pre_disklabel() != 0)
-		return -1;
+	return 0;
+}
 
-	if (write_disklabel() != 0)
-		return -1;
+int
+partman_addvnd(menudesc *m, void *arg)
+{
+	*(int *)arg = m->cursel + 1;
+	return 0;
+}
 
-	if (md_post_disklabel() != 0)
-		return -1;
+int
+partman_deldev(menudesc *m, void *arg)
+{
+	pm_devs_t *pm_devs_tmp, *pm_devs_swap;
+	*(int *)arg = m->cursel + 1;
+
+	for (pm_devs_tmp = pm_devs; pm_devs_tmp->next != NULL;
+			pm_devs_tmp = pm_devs_tmp->next)
+		if (pm_devs_tmp->next == pm) {
+			if (pm_devs_tmp->next->next == NULL) {
+				free(pm_devs_tmp->next);
+				pm_devs_tmp->next = NULL;
+			} else {
+				pm_devs_swap = pm_devs_tmp->next->next;
+				free(pm_devs_tmp->next);
+				pm_devs_tmp->next = pm_devs_swap;
+			}
+			return 0;
+		}
+	return -1;
+}
 
-	if (make_filesystems())
-		return -1;
+int
+partman_commit(menudesc *m, void *arg)
+{
+	pm_devs_t *pm_devs_i;
+	*(int *)arg = m->cursel + 1;
+
+	for (pm_devs_i = pm_devs->next; pm_devs_i != NULL;
+			pm_devs_i = pm_devs_i->next) {
+		partman_select(pm_devs_i);
+		if (
+				md_pre_disklabel() != 0  || /* Write partition table */
+				write_disklabel() != 0   || /* Write slices table (disklabel) */
+				md_post_disklabel() != 0 || /* Enable swap and check badblock */
+				make_filesystems()          /* Create filesystems by newfs */
+			) { /* If something fails... */
+			return -1;
+		}
+		/* Write bootsector if needed */
+		if (pm_devs_i->bootable && md_post_newfs() != 0) {
+			return -1;
+		}
+	}
+    return 0;
+}
 
-	if (make_fstab() != 0)
+static int
+partman_submenu(menudesc *m, void *arg)
+{
+	pm_devs_t *pm_devs_i;
+	int retvalue;
+	int ok = 0;
+	int i;
+	*(int *)arg = m->cursel + 1;
+
+	/* write selected disk to diskdev variable */
+	for (pm_devs_i = pm_devs->next, i = 0; !ok && pm_devs_i != NULL;
+			pm_devs_i = pm_devs_i->next, i++)
+		if (i == m->cursel) {
+			partman_select(pm_devs_i);
+			ok = 1;
+			break;
+		}
+	if (!ok)
 		return -1;
 
-	if (md_post_newfs() != 0)
-		return -1;
-    return 0;
+	process_menu(MENU_pmentry, &retvalue);
+	return 0;
+}
+
+void
+partman_menufmt(menudesc *m, int ptn, void *arg)
+{
+	pm_devs_t *pm_devs_i;
+	int i;
+	unsigned int maxpart;
+	char *dev_mounts = malloc(STRSIZE * sizeof(char));
+	dev_mounts[0] = '\0';
+
+	for (pm_devs_i = pm_devs->next, i = 0;
+			i != ptn && pm_devs_i != NULL;
+			pm_devs_i = pm_devs_i->next, i++);
+	if (i != ptn || pm_devs_i == NULL) 
+		return;
+
+	maxpart = ((unsigned int)getmaxpartitions() > nelem(pm_devs_i->bsdlabel))?
+				nelem(pm_devs_i->bsdlabel) : (unsigned int)getmaxpartitions();
+	for (i = 0; (unsigned int)i < maxpart; i++) {
+		if (pm_devs_i->bsdlabel[i].pi_mount != 0 &&
+				pm_devs_i->bsdlabel[i].pi_fstype != FS_UNUSED) {
+			strcat(dev_mounts, pm_devs_i->bsdlabel[i].pi_mount);
+			strcat(dev_mounts, " ");
+		}
+	}
+
+	wprintw(m->mw,"%-25s %-20s %4s", pm_devs_i->diskdev_descr, dev_mounts,
+			(pm_devs_i->bootable)?"BOOT":"" );
+	return;
+}
+
+// TODO: switch to langfiles
+// TODO: resolve case with 2 same bsddisknames
+int
+partman(void)
+{
+	menu_ent part_menu[MAX_DISKS];
+	int menu_pm;
+	int i, ii;
+	int retvalue = 0;
+	pm_devs_t *pm_devs_i;
+
+	do {
+		clear();
+		refresh();
+		for (pm_devs_i = pm_devs->next, i = 0; pm_devs_i != NULL;
+				pm_devs_i = pm_devs_i->next, i++) {
+			part_menu[i].opt_name = NULL;
+			part_menu[i].opt_action = partman_submenu;
+		}
+
+		part_menu[i] = (struct menu_ent) {
+			.opt_name = "Add disk",
+			.opt_action = partman_adddisk,
+		};
+		part_menu[++i] = (struct menu_ent) {
+			.opt_name = "Create CGD",
+			.opt_action = partman_addvnd,
+		};
+		part_menu[++i] = (struct menu_ent) {
+			.opt_name = "Create VND disk",
+			.opt_action = partman_addvnd,
+		};
+		part_menu[++i] = (struct menu_ent) {
+			.opt_name = "Create LVM VG",
+			.opt_action = partman_addvnd,
+		};
+		part_menu[++i] = (struct menu_ent) {
+			.opt_name = "Create RAIFframe",
+			.opt_action = partman_addvnd,
+		};
+		part_menu[++i] = (struct menu_ent) {
+			.opt_name = "Commit changes",
+			.opt_action = partman_commit,
+		};
+
+		for (ii = 0; ii <= i; ii++) {
+			part_menu[ii].opt_menu = OPT_NOMENU;
+			part_menu[ii].opt_flags = OPT_EXIT;
+		}
+
+		menu_pm = new_menu("Disk editor. All disks, partitions, LVM, RAID displayed there.\nAt first add drive, then prepare partitions and go.",
+			part_menu, i+1,	1, 1, 0, 0, MC_ALWAYS_SCROLL | MC_NOBOX | MC_NOCLEAR,
+			NULL, partman_menufmt, NULL, NULL, NULL);
+		retvalue = 0;
+		if (menu_pm == -1)
+			retvalue = -1;
+		else {
+			process_menu(menu_pm, &retvalue);
+			free_menu(menu_pm);
+		}
+
+		if (logfp)
+			(void)fprintf(logfp, "partman retvalue is %d\n", retvalue);
+	} while (retvalue > 0);
+	
+	// TODO: check_partitions()
+	/* Check that fstab on target device is readable - if so then we can go */
+	if (retvalue == 0) {
+		if (partman_mountall() != 0 ||
+			make_fstab() != 0)
+			retvalue = -1;
+		else {
+			FILE *file_tmp = fopen(concat_paths(targetroot_mnt, "/etc/fstab"), "r");
+			if (file_tmp == NULL)
+				retvalue = -1;
+			else
+				fclose(file_tmp);
+		}
+	}
+
+	/* retvalue <0 - error, retvalue ==0 - user quits, retvalue >0 - all ok */
+	return (retvalue >= 0)?0:-1;
 }
diff --git a/distrib/utils/sysinst/install.c b/distrib/utils/sysinst/install.c
index 077c75a..10935e3 100644
--- a/distrib/utils/sysinst/install.c
+++ b/distrib/utils/sysinst/install.c
@@ -45,23 +45,70 @@
 void
 do_install(void)
 {
+	int find_disks_ret;
+	int retcode = 0;
+	partman_go = 0;
+	fstab_prepared = 0;
 
+#ifndef DEBUG
 	msg_display(MSG_installusure);
 	process_menu(MENU_noyes, NULL);
 	if (!yesno)
 		return;
+#endif
 
 	get_ramsize();
 
 	/* Create and mount partitions */
-	if (!partitioning() < 0) {
-		msg_display(MSG_abort);
-		process_menu(MENU_ok, NULL);
+	find_disks_ret = find_disks(msg_string(MSG_install));
+	if (partman_go == 1) {
+		if (partman() < 0) {
+			msg_display(MSG_abort);
+			process_menu(MENU_ok, NULL);
+			return;
+		}		
+	} else if (find_disks_ret < 0)
 		return;
+	else {
+	/* Classical partitioning wizard */
+		clear();
+		refresh();
+
+		if (check_swap(pm->diskdev, 0) > 0) {
+			msg_display(MSG_swapactive);
+			process_menu(MENU_ok, NULL);
+			if (check_swap(pm->diskdev, 1) < 0) {
+				msg_display(MSG_swapdelfailed);
+				process_menu(MENU_ok, NULL);
+				if (!debug)
+					return;
+			}
+		}
+
+		if (!md_get_info() || md_make_bsd_partitions() == 0) {
+			msg_display(MSG_abort);
+			process_menu(MENU_ok, NULL);
+			return;
+		}
+
+		/* Last chance ... do you really want to do this? */
+		clear();
+		refresh();
+		msg_display(MSG_lastchance, pm->diskdev);
+		process_menu(MENU_noyes, NULL);
+		if (!yesno)
+			return;
+
+		if (md_pre_disklabel() != 0 || write_disklabel() != 0 ||
+			md_post_disklabel() != 0 ||make_filesystems() ||
+			make_fstab() != 0 || md_post_newfs() != 0)
+			return;
 	}
 
 	/* Unpack the distribution. */
-	process_menu(MENU_distset, NULL);
+	process_menu(MENU_distset, &retcode);
+	if (retcode == 0)
+		return;
 	if (get_and_unpack_sets(0, MSG_disksetupdone,
 	    MSG_extractcomplete, MSG_abortinst) != 0)
 		return;
diff --git a/distrib/utils/sysinst/label.c b/distrib/utils/sysinst/label.c
index f6d96ae..ebdb567 100644
--- a/distrib/utils/sysinst/label.c
+++ b/distrib/utils/sysinst/label.c
@@ -193,7 +193,7 @@ edit_fs_size(menudesc *m, void *arg)
 
 	size = getpartsize(p->pi_offset, p->pi_size);
 	if (size == ~0u)
-		size = dlsize - p->pi_offset;
+		size = pm->dlsize - p->pi_offset;
 	p->pi_size = size;
 	if (size == 0) {
 		p->pi_offset = 0;
@@ -398,7 +398,7 @@ edit_ptn(menudesc *menu, void *arg)
 			get_fstype, NULL, NULL, NULL, MSG_unchanged);
 	}
 
-	p = bsdlabel + menu->cursel;
+	p = pm->bsdlabel + menu->cursel;
 	p->pi_flags &= ~PIF_RESET;
 	p_save = *p;
 	for (;;) {
@@ -419,7 +419,7 @@ set_ptn_header(menudesc *m, void *arg)
 	int t;
 
 	msg_clear();
-	msg_table_add(MSG_edfspart, 'a' + (p - bsdlabel));
+	msg_table_add(MSG_edfspart, 'a' + (p - pm->bsdlabel));
 
 	/* Determine which of the properties can be changed */
 	for (i = PTN_MENU_START; i <= PTN_MENU_MOUNTPT; i++) {
@@ -461,10 +461,10 @@ set_ptn_header(menudesc *m, void *arg)
 static void
 disp_sector_count(menudesc *m, msg fmt, uint s)
 {
-	uint ms = MEG / sectorsize;
+	uint ms = MEG / pm->sectorsize;
 
 	wprintw(m->mw, msg_string(fmt),
-		s / ms, s / dlcylsize, s % dlcylsize ? '*' : ' ', s );
+		s / ms, s / pm->dlcylsize, s % pm->dlcylsize ? '*' : ' ', s );
 }
 
 static void
@@ -575,7 +575,7 @@ set_label_texts(menudesc *menu, void *arg)
 			m->opt_flags = OPT_IGNORE;
 		} else {
 			m->opt_flags = 0;
-			if (bsdlabel[ptn].pi_fstype == FS_UNUSED)
+			if (pm->bsdlabel[ptn].pi_fstype == FS_UNUSED)
 				continue;
 		}
 		show_unused_ptn = ptn + 2;
@@ -629,7 +629,7 @@ edit_and_check_label(partinfo *lp, int nparts, int rawpart, int bsdpart)
 		return 1;
 
 	pi.flags = 0;
-	current_cylsize = dlcylsize;
+	pm->current_cylsize = pm->dlcylsize;
 
 	for (;;) {
 		int i, j;
@@ -639,7 +639,7 @@ edit_and_check_label(partinfo *lp, int nparts, int rawpart, int bsdpart)
 
 		/* User thinks the label is OK. */
 		/* check we have a single root fs */
-		if (check_one_root(lp, nparts) == 0)
+		if (check_one_root(lp, nparts) == 0 && partman_go == 0)
 			msg_display(MSG_must_be_one_root);
 		else 
 			/* Check for overlaps */
@@ -686,7 +686,7 @@ incorelabel(const char *dkname, partinfo *lp)
 	 * than d_diskname.  Who knows why, but pull the value back here.
 	 */
 	if (lab.d_typename[0] != 0 && strcmp(lab.d_typename, "unknown") != 0)
-		strlcpy(bsddiskname, lab.d_typename, sizeof bsddiskname);
+		strlcpy(pm->bsddiskname, lab.d_typename, sizeof pm->bsddiskname);
 
 	fd = opendisk(dkname, O_RDONLY, buf, sizeof buf, 0);
 	pp = &lab.d_partitions[0];
@@ -806,10 +806,10 @@ getpartoff(uint32_t defpartstart)
 		if (isize[1] == '\0' && isize[0] >= 'a' &&
 		    isize[0] <= maxpartc) {
 			partn = isize[0] - 'a';
-			i = bsdlabel[partn].pi_size + bsdlabel[partn].pi_offset;
+			i = pm->bsdlabel[partn].pi_size + pm->bsdlabel[partn].pi_offset;
 			localsizemult = 1;
 		} else if (atoi(isize) == -1) {
-			i = ptstart;
+			i = pm->ptstart;
 			localsizemult = 1;
 		} else {
 			if (atofsb(isize, &i, &localsizemult)) {
@@ -818,13 +818,13 @@ getpartoff(uint32_t defpartstart)
 			}
 		}
 		/* round to cylinder size if localsizemult != 1 */
-		i = NUMSEC(i/localsizemult, localsizemult, dlcylsize);
+		i = NUMSEC(i/localsizemult, localsizemult, pm->dlcylsize);
 		/* Adjust to start of slice if needed */
-		if ((i < ptstart && (ptstart - i) < localsizemult) ||
-		    (i > ptstart && (i - ptstart) < localsizemult)) {
-			i = ptstart;
+		if ((i < pm->ptstart && (pm->ptstart - i) < localsizemult) ||
+		    (i > pm->ptstart && (i - pm->ptstart) < localsizemult)) {
+			i = pm->ptstart;
 		}
-		if (i <= dlsize)
+		if (i <= pm->dlsize)
 			break;
 		errmsg = msg_string(MSG_startoutsidedisk);
 	}
@@ -839,7 +839,7 @@ getpartsize(uint32_t partstart, uint32_t defpartsize)
 	char dsize[20], isize[20], maxpartc;
 	const char *errmsg = "\n";
 	uint32_t i, partend, localsizemult;
-	uint32_t fsptend = ptstart + ptsize;
+	uint32_t fsptend = pm->ptstart + pm->ptsize;
 	int partn;
 
 	maxpartc = 'a' + getmaxpartitions() - 1;
@@ -853,7 +853,7 @@ getpartsize(uint32_t partstart, uint32_t defpartsize)
 		if (isize[1] == '\0' && isize[0] >= 'a' &&
 		    isize[0] <= maxpartc) {
 			partn = isize[0] - 'a';
-			i = bsdlabel[partn].pi_offset - partstart;
+			i = pm->bsdlabel[partn].pi_offset - partstart;
 			localsizemult = 1;
 		} else if (atoi(isize) == -1) {
 			i = fsptend - partstart;
@@ -869,17 +869,17 @@ getpartsize(uint32_t partstart, uint32_t defpartsize)
 		 * is not 1 sector
 		 */
 		partend = NUMSEC((partstart + i) / localsizemult,
-		    localsizemult, dlcylsize);
+		    localsizemult, pm->dlcylsize);
 		/* Align to end-of-disk or end-of-slice if close enough */
-		if (partend > (dlsize - localsizemult)
-		    && partend < (dlsize + localsizemult))
-			partend = dlsize;
+		if (partend > (pm->dlsize - localsizemult)
+		    && partend < (pm->dlsize + localsizemult))
+			partend = pm->dlsize;
 		if (partend > (fsptend - localsizemult)
 		    && partend < (fsptend + localsizemult))
 			partend = fsptend;
 		/* sanity checks */
-		if (partend > dlsize) {
-			partend = dlsize;
+		if (partend > pm->dlsize) {
+			partend = pm->dlsize;
 			msg_prompt_win(MSG_endoutsidedisk, -1, 13, 70, 6,
 			    NULL, isize, 1,
 			    (partend - partstart) / sizemult, multname);
@@ -922,15 +922,15 @@ atofsb(const char *str, uint32_t *p_val, uint32_t *localsizemult)
 		}
 		if (str[i] == 'G' || str[i] == 'g') {
 			val *= 1024;
-			*localsizemult = MEG / sectorsize;
+			*localsizemult = MEG / pm->sectorsize;
 			break;
 		}
 		if (str[i] == 'M' || str[i] == 'm') {
-			*localsizemult = MEG / sectorsize;
+			*localsizemult = MEG / pm->sectorsize;
 			break;
 		}
 		if (str[i] == 'c') {
-			*localsizemult = dlcylsize;
+			*localsizemult = pm->dlcylsize;
 			break;
 		}
 		if (str[i] == 's') {
diff --git a/distrib/utils/sysinst/main.c b/distrib/utils/sysinst/main.c
index b4ca0df..69723e8 100644
--- a/distrib/utils/sysinst/main.c
+++ b/distrib/utils/sysinst/main.c
@@ -62,7 +62,6 @@ static void process_f_flag(char *);
 static int exit_cleanly = 0;	/* Did we finish nicely? */
 FILE *logfp;			/* log file */
 FILE *script;			/* script file */
-int part_mode;			/* run partition editor */
 
 #ifdef DEBUG
 extern int log_flip(void);
@@ -106,7 +105,7 @@ static const struct f_arg fflagopts[] = {
 	{"local dir", "release", localfs_dir, sizeof localfs_dir},
 	{"targetroot mount", "/targetroot", targetroot_mnt, sizeof targetroot_mnt},
 	{"dist postfix", ".tgz", dist_postfix, sizeof dist_postfix},
-	{"diskname", "mydisk", bsddiskname, sizeof bsddiskname},
+	{"diskname", "mydisk", bsddiskname, sizeof bsddiskname}, /* TODO: xxx */
 	{"pkg host", SYSINST_PKG_HOST, pkg.host, sizeof pkg.host},
 	{"pkg dir", SYSINST_PKG_DIR, pkg.dir, sizeof pkg.dir},
 	{"pkg prefix", "/" MACH "/" REL "/All", pkg_dir, sizeof pkg_dir},
@@ -136,6 +135,11 @@ init(void)
 	mnt2_mounted = 0;
 	fd_type = "msdos";
 
+	pm_devs = malloc (sizeof (pm_devs_t));
+	pm_devs->next = NULL;
+	pm_found = malloc (sizeof (pm_devs_t));
+	pm_found->next = NULL;
+
 	for (arg = fflagopts; arg->name != NULL; arg++)
 		strlcpy(arg->var, arg->dflt, arg->size);
 	pkg.xfer_type = pkgsrc.xfer_type = "http";
@@ -183,7 +187,7 @@ main(int argc, char **argv)
 			break;
 		case 'p':
 			/* Partition tool */
-			part_mode = 1;
+			partman_go = 1;
 			break;
 		case '?':
 		default:
@@ -231,8 +235,8 @@ main(int argc, char **argv)
 	get_kb_encoding();
 
 	/* Menu processing */
-	if (part_mode)
-		partitioning();
+	if (partman_go)
+		partman();
 	else
 		process_menu(MENU_netbsd, NULL);
 
@@ -356,6 +360,7 @@ toplevel(void)
 	 * XXX must be idempotent, since we get run each time the main
 	 *     menu is displayed.
 	 */
+	chdir(getenv("HOME")? getenv("HOME") : "/");
 	unwind_mounts();
 
 	/* Display banner message in (english, francais, deutsch..) */
diff --git a/distrib/utils/sysinst/mbr.c b/distrib/utils/sysinst/mbr.c
index 40202d9..c916074 100644
--- a/distrib/utils/sysinst/mbr.c
+++ b/distrib/utils/sysinst/mbr.c
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.90 2012/04/07 03:08:33 tsutsui Exp $ */
+/*	$NetBSD: mbr.c,v 1.91 2012/05/26 05:09:59 tsutsui Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -196,8 +196,8 @@ set_bios_geom_with_mbr_guess(void)
 	int cyl, head;
 	daddr_t sec;
 
-	read_mbr(diskdev, &mbr);
-	msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
+	read_mbr(pm->diskdev, &mbr);
+	msg_display(MSG_nobiosgeom, pm->dlcyl, pm->dlhead, pm->dlsec);
 	if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
 		msg_display_add(MSG_biosguess, cyl, head, sec);
 	set_bios_geom(cyl, head, sec);
@@ -227,8 +227,8 @@ set_bios_geom(int cyl, int head, int sec)
 		bhead = atoi(res);
 	} while (bhead <= 0 || bhead > 256);
 
-	bcyl = dlsize / bsec / bhead;
-	if (dlsize != bcyl * bsec * bhead)
+	bcyl = pm->dlsize / bsec / bhead;
+	if (pm->dlsize != bcyl * bsec * bhead)
 		bcyl++;
 }
 
@@ -237,7 +237,7 @@ void
 disp_cur_geom(void)
 {
 
-	msg_display_add(MSG_realgeom, dlcyl, dlhead, dlsec);
+	msg_display_add(MSG_realgeom, pm->dlcyl, pm->dlhead, pm->dlsec);
 	msg_display_add(MSG_biosgeom, bcyl, bhead, bsec);
 }
 #endif
@@ -267,7 +267,7 @@ remove_old_partitions(uint start, int64_t size)
 	if (end == 0)
 		return;
 
-	for (p = oldlabel; p < oldlabel + nelem(oldlabel); p++) {
+	for (p = pm->oldlabel; p < pm->oldlabel + nelem(pm->oldlabel); p++) {
 		if (p->pi_offset >= end || p->pi_offset + p->pi_size <= start)
 			continue;
 		memset(p, 0, sizeof *p);
@@ -282,7 +282,7 @@ find_mbr_space(struct mbr_sector *mbrs, uint *start, uint *size, uint from, int
 	uint s, e;
 
     check_again:
-	sz = dlsize - from;
+	sz = pm->dlsize - from;
 	for (i = 0; i < MBR_PART_COUNT; i++) {
 		if (i == ignore)
 			continue;
@@ -1174,7 +1174,7 @@ set_mbr_header(menudesc *m, void *arg)
 
 	msg_display(MSG_editparttable);
 
-	msg_table_add(MSG_part_header, (unsigned long)(dlsize/sizemult),
+	msg_table_add(MSG_part_header, (unsigned long)(pm->dlsize/sizemult),
 	    multname, multname, multname, multname);
 
 	if (num_opts == 0) {
@@ -1242,12 +1242,12 @@ mbr_use_wholedisk(mbr_info_t *mbri)
 	memset(&mbri->mbrb, 0, sizeof mbri->mbrb);
 #endif
 	part[0].mbrp_type = MBR_PTYPE_NETBSD;
-	part[0].mbrp_size = dlsize - ptn_0_offset;
+	part[0].mbrp_size = pm->dlsize - ptn_0_offset;
 	part[0].mbrp_start = ptn_0_offset;
 	part[0].mbrp_flag = MBR_PFLAG_ACTIVE;
 
-	ptstart = ptn_0_offset;
-	ptsize = dlsize - ptn_0_offset;
+	pm->ptstart = ptn_0_offset;
+	pm->ptsize = pm->dlsize - ptn_0_offset;
 	return 1;
 }
 
@@ -1271,7 +1271,8 @@ edit_mbr(mbr_info_t *mbri)
 	/* Ask full/part */
 
 	part = &mbrs->mbr_parts[0];
-	msg_display(MSG_fullpart, diskdev);
+	get_ptn_alignment(part);  /* update ptn_alignment */
+	msg_display(MSG_fullpart, pm->diskdev);
 	process_menu(MENU_fullpart, &usefull);
 
 	/* DOS fdisk label checking and value setting. */
@@ -1309,11 +1310,11 @@ edit_mbr(mbr_info_t *mbri)
 
 	/* Default to MB, and use bios geometry for cylinder size */
 	set_sizemultname_meg();
-	current_cylsize = bhead * bsec;
+	pm->current_cylsize = bhead * bsec;
 
 	for (;;) {
-		ptstart = 0;
-		ptsize = 0;
+		pm->ptstart = 0;
+		pm->ptsize = 0;
 		process_menu(mbr_menu, mbri);
 
 		activepart = 0;
@@ -1328,8 +1329,8 @@ edit_mbr(mbr_info_t *mbri)
 					continue;
 				start = ext->sector + part->mbrp_start;
 				if (start == mbri->install) {
-					ptstart = mbri->install;
-					ptsize = part->mbrp_size;
+					pm->ptstart = mbri->install;
+					pm->ptsize = part->mbrp_size;
 				}
 				if (bsdstart != 0)
 					bsdstart = ~0;
@@ -1341,12 +1342,12 @@ edit_mbr(mbr_info_t *mbri)
 		}
 
 		/* Install in only netbsd partition if none tagged */
-		if (ptstart == 0 && bsdstart != ~0u) {
-			ptstart = bsdstart;
-			ptsize = bsdsize;
+		if (pm->ptstart == 0 && bsdstart != ~0u) {
+			pm->ptstart = bsdstart;
+			pm->ptsize = bsdsize;
 		}
 
-		if (ptstart == 0) {
+		if (pm->ptstart == 0) {
 			if (bsdstart == 0)
 				msg_display(MSG_nobsdpart);
 			else
@@ -1454,10 +1455,10 @@ read_mbr(const char *disk, mbr_info_t *mbri)
 	 * partition headers we might have to produce.
 	 */
 	if (bsec == 0)
-		bsec = dlsec;
+		bsec = pm->dlsec;
 	ptn_0_offset = bsec;
 	/* use 1MB default offset on large disks as fdisk(8) */
-	if (dlsize > 2048 * 1024 * 128)
+	if (pm->dlsize > 2048 * 1024 * 128)
 		ptn_0_offset = 2048;
 
 	memset(mbri, 0, sizeof *mbri);
@@ -1477,7 +1478,7 @@ read_mbr(const char *disk, mbr_info_t *mbri)
 
 		mbrp = &mbrs->mbr_parts[0];
 		if (ext_base == 0) {
-			get_ptn_alignment(mbrp);
+			get_ptn_alignment(mbrp);  /* get ptn_0_offset */
 		} else {
 			/* sanity check extended chain */
 			if (MBR_IS_EXTENDED(mbrp[0].mbrp_type))
@@ -1761,13 +1762,13 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, daddr_t *sec)
 	 * the invalid physical one.
 	 */
 
-	xcylinders = dlcyl;
-	xheads = dlhead;
-	xsectors = dlsec;
+	xcylinders = pm->dlcyl;
+	xheads = pm->dlhead;
+	xsectors = pm->dlsec;
 	if (xcylinders > MAXCYL || xheads > MAXHEAD || xsectors > MAXSECTOR) {
 		xsectors = MAXSECTOR;
 		xheads = MAXHEAD;
-		xcylinders = dlsize / (MAXSECTOR * MAXHEAD);
+		xcylinders = pm->dlsize / (MAXSECTOR * MAXHEAD);
 		if (xcylinders > MAXCYL)
 			xcylinders = MAXCYL;
 	}
@@ -1805,8 +1806,8 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, daddr_t *sec)
 	 * Estimate the number of cylinders.
 	 * XXX relies on get_disks having been called.
 	 */
-	xcylinders = dlsize / xheads / xsectors;
-	if (dlsize != xcylinders * xheads * xsectors)
+	xcylinders = pm->dlsize / xheads / xsectors;
+	if (pm->dlsize != xcylinders * xheads * xsectors)
 		xcylinders++;
 
 	/*
@@ -1889,7 +1890,7 @@ get_ptn_alignment(struct mbr_partition *mbrp0)
 		}
 	} else {
 		/* Use 1MB offset for large (>128GB) disks */
-		if (dlsize > 2048 * 1024 * 128)
+		if (pm->dlsize > 2048 * 1024 * 128)
 			ptn_alignment = 2048;
 			ptn_0_offset = 2048;
 	}
diff --git a/distrib/utils/sysinst/mbr.h b/distrib/utils/sysinst/mbr.h
index e5fe2b9..8d1ccf87 100644
--- a/distrib/utils/sysinst/mbr.h
+++ b/distrib/utils/sysinst/mbr.h
@@ -76,7 +76,7 @@ struct mbr_info_t {
 /* incore fdisk (mbr, bios) geometry */
 int bcyl, bhead, bsec;
 
-mbr_info_t mbr;
+mbr_info_t mbr; // TODO: xxx
 
 #ifdef BOOTSEL
 struct mbr_bootsel *mbs;
diff --git a/distrib/utils/sysinst/menus.mi b/distrib/utils/sysinst/menus.mi
index 36e88e5..08c8d1f 100644
--- a/distrib/utils/sysinst/menus.mi
+++ b/distrib/utils/sysinst/menus.mi
@@ -177,7 +177,7 @@ menu utility, title MSG_NetBSD_VERSION_Utilities, exit,
 			network_up = 0;
 			config_network();
 		};
-	option MSG_Partition_a_disk, action { partitioning(); };
+	option MSG_Partition_a_disk, action { partman(); };
 	option MSG_Logging_functions, action { do_logging(); };
 	option MSG_Color_scheme, sub menu colors;
 	option MSG_Halt_the_system, exit,
@@ -211,17 +211,17 @@ menu layout, sub menu, y=-1, title  MSG_Choose_your_installation;
 
 menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
 	display action {
-		if (sizemult == current_cylsize)
+		if (sizemult == pm->current_cylsize)
 			menu->cursel = 1;
 		else if (sizemult == 1)
 			menu->cursel = 2;
 		};
 	option MSG_Megabytes, exit, action 
-		{ sizemult = MEG / sectorsize;
+		{ sizemult = MEG / pm->sectorsize;
 		  multname = msg_string(MSG_megname);
 		};
 	option MSG_Cylinders, exit, action 
-		{ sizemult = current_cylsize; 
+		{ sizemult = pm->current_cylsize; 
 		  multname = msg_string(MSG_cylname);
 		};
 	option MSG_Sectors, exit, action 
@@ -241,12 +241,12 @@ menu distmedium, title MSG_Select_medium, y=-5;
 	option MSG_Skip_group,exit, action { *(int *)arg = SET_SKIP_GROUP; };
 	option MSG_Abandon,   exit, action { *(int *)arg = SET_ABANDON; };
 
-menu distset, title MSG_Select_your_distribution;
+menu distset, title MSG_Select_your_distribution, exit;
 	display action { msg_display (MSG_distset); };
-	option MSG_Full_installation, exit, action { init_set_status(0);  };
-	option MSG_Full_installation_nox, exit, action { init_set_status(SFLAG_NOX); };
-	option MSG_Minimal_installation, exit, action { init_set_status(SFLAG_MINIMAL); };
-	option MSG_Custom_installation, exit, action { init_set_status(SFLAG_MINIMAL); customise_sets(); };
+	option MSG_Full_installation, exit, action { *(int *)arg = 1; init_set_status(0);  };
+	option MSG_Full_installation_nox, exit, action { *(int *)arg = 1; init_set_status(SFLAG_NOX); };
+	option MSG_Minimal_installation, exit, action { *(int *)arg = 1; init_set_status(SFLAG_MINIMAL); };
+	option MSG_Custom_installation, exit, action { *(int *)arg = 1; init_set_status(SFLAG_MINIMAL); customise_sets(); };
 
 menu ftpsource, y=-4, x=0, w=70, no box, no clear,
 	    exitstring MSG_Get_Distribution;
@@ -505,3 +505,12 @@ menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
 			config_network();
 		};
 	option MSG_quit_install, exit, action { yesno = SET_SKIP; };
+
+menu pmentry, x=50, y=5, sub menu, exit, default exit;
+	option "Prepare",			exit, action { md_get_info(); };
+	option "Prepare GPT",		exit, action { md_get_info(); };
+	option "Commit prepare",	exit, action { md_pre_disklabel(); };
+	option "Disk label",		exit, action { md_make_bsd_partitions(); };
+	option "Commit label",		exit, action { write_disklabel(); md_post_disklabel(); };
+	option "Toggle bootable",   exit, action { pm->bootable = !pm->bootable; };
+	option "Remove",			exit, action { partman_deldev(m, arg); };
diff --git a/distrib/utils/sysinst/savenewlabel.c b/distrib/utils/sysinst/savenewlabel.c
index b8567a9..a4467de 100644
--- a/distrib/utils/sysinst/savenewlabel.c
+++ b/distrib/utils/sysinst/savenewlabel.c
@@ -58,8 +58,12 @@ int
 savenewlabel(partinfo *lp, int nparts)
 {
 	FILE *f;
+	char *f_name = malloc(STRSIZE * sizeof(char));
 	int i;
 
+	strlcpy(f_name, "/tmp/disktab.", STRSIZE);
+	strlcat(f_name, pm->bsddiskname, STRSIZE);
+
 	/*
 	  N.B. disklabels only support up to 2TB (32-bit field for sectors).
 	  This function explicitly narrows from daddr_t (64-bit unsigned) to
@@ -67,40 +71,41 @@ savenewlabel(partinfo *lp, int nparts)
 	 */
 
 	/* Create /etc/disktab */
-	f = fopen("/tmp/disktab", "w");
+
+	f = fopen(f_name, "w");
 	if (logfp)
-		(void)fprintf(logfp, "Creating disklabel %s\n", bsddiskname);
+		(void)fprintf(logfp, "Creating disklabel %s in %s\n", pm->bsddiskname,
+						f_name);
 	scripting_fprintf(NULL, "cat <<EOF >>/etc/disktab\n");
 	if (f == NULL) {
 		endwin();
-		(void)fprintf(stderr, "Could not open /etc/disktab");
+		(void)fprintf(stderr, "Could not open %s for writing\n", f_name);
 		if (logfp)
-			(void)fprintf(logfp,
-			    "Failed to open /etc/disktab for appending.\n");
+			(void)fprintf(logfp, "Could not open %s for writing\n", f_name);
 		exit (1);
 	}
-	scripting_fprintf(f, "%s|NetBSD installation generated:\\\n", bsddiskname);
+	scripting_fprintf(f, "%s|NetBSD installation generated:\\\n", pm->bsddiskname);
 	scripting_fprintf(f, "\t:dt=%s:ty=winchester:\\\n", disktype);
-	scripting_fprintf(f, "\t:nc#%d:nt#%d:ns#%d:\\\n", dlcyl, dlhead, dlsec);
-	scripting_fprintf(f, "\t:sc#%d:su#%" PRIu32 ":\\\n", dlhead*dlsec,
-	    (uint32_t)dlsize);
-	scripting_fprintf(f, "\t:se#%d:%s\\\n", sectorsize, doessf);
-	if ((size_t)nparts > __arraycount(bsdlabel)) {
-		nparts = __arraycount(bsdlabel);
+	scripting_fprintf(f, "\t:nc#%d:nt#%d:ns#%d:\\\n", pm->dlcyl, pm->dlhead, pm->dlsec);
+	scripting_fprintf(f, "\t:sc#%d:su#%" PRIu32 ":\\\n", pm->dlhead*pm->dlsec,
+	    (uint32_t)pm->dlsize);
+	scripting_fprintf(f, "\t:se#%d:%s\\\n", pm->sectorsize, doessf);
+	if ((size_t)nparts > __arraycount(pm->bsdlabel)) {
+		nparts = __arraycount(pm->bsdlabel);
 		if (logfp)
 			(void)fprintf(logfp, "nparts limited to %d.\n", nparts);
 	}
 	for (i = 0; i < nparts; i++) {
 		scripting_fprintf(f, "\t:p%c#%" PRIu32 ":o%c#%" PRIu32
-		    ":t%c=%s:", 'a'+i, (uint32_t)bsdlabel[i].pi_size,
-		    'a'+i, (uint32_t)bsdlabel[i].pi_offset, 'a'+i,
-		    getfslabelname(bsdlabel[i].pi_fstype));
-		if (PI_ISBSDFS(&bsdlabel[i]))
+		    ":t%c=%s:", 'a'+i, (uint32_t)pm->bsdlabel[i].pi_size,
+		    'a'+i, (uint32_t)pm->bsdlabel[i].pi_offset, 'a'+i,
+		    getfslabelname(pm->bsdlabel[i].pi_fstype));
+		if (PI_ISBSDFS(&pm->bsdlabel[i]))
 			scripting_fprintf (f, "b%c#%" PRIu32 ":f%c#%" PRIu32
 			    ":", 'a'+i,
-			    (uint32_t)(bsdlabel[i].pi_fsize *
-			    bsdlabel[i].pi_frag),
-			    'a'+i, (uint32_t)bsdlabel[i].pi_fsize);
+			    (uint32_t)(pm->bsdlabel[i].pi_fsize *
+			    pm->bsdlabel[i].pi_frag),
+			    'a'+i, (uint32_t)pm->bsdlabel[i].pi_fsize);
 	
 		if (i < nparts - 1)
 			scripting_fprintf(f, "\\\n");
@@ -110,5 +115,6 @@ savenewlabel(partinfo *lp, int nparts)
 	fclose (f);
 	scripting_fprintf(NULL, "EOF\n");
 	fflush(NULL);
+	run_program(0, "sh -c 'cat /tmp/disktab.* >/tmp/disktab'");
 	return(0);
 }
diff --git a/distrib/utils/sysinst/sizemultname.c b/distrib/utils/sysinst/sizemultname.c
index 5829c73..ffd9c16 100644
--- a/distrib/utils/sysinst/sizemultname.c
+++ b/distrib/utils/sysinst/sizemultname.c
@@ -52,7 +52,7 @@ void
 set_sizemultname_cyl(void)
 {
 
-	sizemult = dlcylsize;
+	sizemult = pm->dlcylsize;
 	multname = msg_string(MSG_cylname);
 }
 
@@ -60,6 +60,6 @@ void
 set_sizemultname_meg(void)
 {
 
-	sizemult = MEG / sectorsize;
+	sizemult = MEG / pm->sectorsize;
 	multname = msg_string(MSG_megname);
 }
diff --git a/distrib/utils/sysinst/target.c b/distrib/utils/sysinst/target.c
index 36f108a..fb85a8c 100644
--- a/distrib/utils/sysinst/target.c
+++ b/distrib/utils/sysinst/target.c
@@ -146,20 +146,20 @@ backtowin(void)
 /*
  * Is the root partition we're running from the same as the root 
  * which the user has selected to install/upgrade?
- * Uses global variable "diskdev" to find the selected device for
+ * Uses global variable "pm->diskdev" to find the selected device for
  * install/upgrade.
  */
 int
 target_already_root(void)
 {
 
-	if (strcmp(diskdev, "") == 0)
+	if (strcmp(pm->diskdev, "") == 0)
 		/* No root partition was ever selected.
 		 * Assume that the currently mounted one should be used
 		 */
 		return 1;
 
-	return is_active_rootpart(diskdev, rootpart);
+	return is_active_rootpart(pm->diskdev, rootpart);
 }
 
 
diff --git a/distrib/utils/sysinst/upgrade.c b/distrib/utils/sysinst/upgrade.c
index 4969412..ba8a862 100644
--- a/distrib/utils/sysinst/upgrade.c
+++ b/distrib/utils/sysinst/upgrade.c
@@ -54,6 +54,7 @@ static int merge_X(const char *);
 void
 do_upgrade(void)
 {
+	int retcode = 0;
 
 	msg_display(MSG_upgradeusure);
 	process_menu(MENU_noyes, NULL);
@@ -94,7 +95,9 @@ do_upgrade(void)
 	wrefresh(stdscr);
 
 	/* Done with disks. Ready to get and unpack tarballs. */
-	process_menu(MENU_distset, NULL);
+	process_menu(MENU_distset, &retcode);
+	if (retcode == 0)
+		return;
 	if (get_and_unpack_sets(1, MSG_disksetupdoneupdate,
 	    MSG_upgrcomplete, MSG_abortupgr) != 0)
 		return;
@@ -171,6 +174,7 @@ merge_X(const char *xroot)
 void
 do_reinstall_sets(void)
 {
+	int retcode = 0;
 
 	unwind_mounts();
 	msg_display(MSG_reinstallusure);
@@ -185,7 +189,9 @@ do_reinstall_sets(void)
 		return;
 
 	/* Unpack the distribution. */
-	process_menu(MENU_distset, NULL);
+	process_menu(MENU_distset, &retcode);
+	if (retcode == 0)
+		return;
 	if (get_and_unpack_sets(0, NULL, MSG_unpackcomplete, MSG_abortunpack) != 0)
 		return;
 
