NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

install/55382: sysinst doesn't create boot ext2fs in MBR Ext2 partition



>Number:         55382
>Category:       install
>Synopsis:       sysinst doesn't create boot ext2fs in MBR Ext2 partition
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    install-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 12 19:00:00 +0000 2020
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.0
>Organization:
>Environment:
System: NetBSD 9.0 (RAMDISK) #0: Fri Feb 14 00:06:28 UTC 2020
mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/cobalt/compile/RAMDISK
Architecture: maybe all
Machine: currently only cobalt is affected
>Description:
NetBSD/cobalt requries to have an Ext2fs partition for its bootstrap
and sysinst in NetBSD 8.0 and prior handles it.

On NetBSD 9.0 sysinst still create an Ext2fs boot partition
on cobalt, but the partition is not allocated in the MBR partition
for Linux but in NetBSD partition. 


>How-To-Repeat:

MBR partition is allocated as the following if ""

---

Set "the sizes for the system partitions" as following:
---

 You can now change the sizes for the system partitions.  The default is to
 allocate all the space to the root file system.  However, you may wish to
 have separate /usr (additional system files), /var (log files etc) or /home
 (users' home directories) file systems.

 Free space will be added to the partition marked with a '+'.

       Size (sec)                            Filesystem
       ----------------------------------- - --------------------
    a: 10240                                 /stand
    b: 643072 (963248)                     + /
    c: 65536                                 <swap>
    d: 0                                     /tmp (mfs)
    e: 0                                     /usr
    f: 0                                     /var
       ----------------------------------- - --------------------
    h: Add a user defined partition
    i: Clone external partition(s)
    j: Change input units (sectors/cylinders/MB/GB)
   >x: Go on.  Free space 320176 sec.

---

Then the "/stand" boot partition ("/ext2" in -current)
is allocated in the "NetBSD parptition":

---

 We now have your disklabel partitions for wd0 below.  This is your last   
 chance to change them. 
 
 Flags: (N)ewfs.  Total size: 507M, free: 1536B

     Start (sec)    End (sec)   Size (sec)  FS type Flag Filesystem
    ------------ ------------ ------------ -------- ---- ----------------
 a:        20546       983793       963248   4.2BSD N    /
 b:       983795      1049327        65533     swap
 c:        10304      1049327      1039024 NetBSD partition
 d:            0      1049327      1049328 Whole disk
 e:        10305        20544        10240 Linux Ex N    /stand
    ------------ ------------ ------------ -------- ---- ----------------
 g: Change input units (sectors/cylinders/MB/GB)
 h: Edit name of the disk
 i: Clone external partition(s)
 j: Cancel
>x: Partition sizes ok

---

The boot Linux Ext2 should be allocated at region from 63 to 10304.

>Fix:

I don't understand design and implementation of new sysinst at all,
but the following changes make sysinst allocate Ext2fs partition
in the Linux partition in MBR:

---

Index: bsddisklabel.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/sysinst/bsddisklabel.c,v
retrieving revision 1.23.2.10
diff -u -p -d -r1.23.2.10 bsddisklabel.c
--- bsddisklabel.c	10 Feb 2020 21:39:37 -0000	1.23.2.10
+++ bsddisklabel.c	12 Jun 2020 18:47:00 -0000
@@ -76,7 +76,7 @@ default_parts_init[] =
 #endif
 #ifdef PART_BOOT_TYPE
 	  .fs_type = PART_BOOT_TYPE,
-#if PART_BOOT_TYPE == FS_MSDOS
+#if (PART_BOOT_TYPE == FS_MSDOS) || (PART_BOOT_TYPE == FS_EX2FS)
 	  .flags = PUIFLAG_ADD_OUTER,
 #endif
 #endif
@@ -100,7 +100,7 @@ default_parts_init[] =
 #endif
 #ifdef PART_BOOT1_TYPE
 	  .fs_type = PART_BOOT1_TYPE,
-#if PART_BOOT1_TYPE == FS_MSDOS
+#if (PART_BOOT1_TYPE == FS_MSDOS) || (PART_BOOT1_TYPE == FS_EX2FS)
 	  .flags = PUIFLAG_ADD_OUTER,
 #endif
 #endif
@@ -119,7 +119,7 @@ default_parts_init[] =
 #endif
 #ifdef PART_BOOT2_TYPE
 	  .fs_type = PART_BOOT2_TYPE,
-#if PART_BOOT2_TYPE == FS_MSDOS
+#if (PART_BOOT2_TYPE == FS_MSDOS) || (PART_BOOT2_TYPE == FS_EX2FS)
 	  .flags = PUIFLAG_ADD_OUTER,
 #endif
 #endif
@@ -961,7 +967,8 @@ fill_defaults(struct partition_usage_set
 				wanted->infos[i].type = pt->generic_ptype;
 		}
 		if (wanted->parts->parent != NULL &&
-		    wanted->infos[i].fs_type == FS_MSDOS)
+		    (wanted->infos[i].fs_type == FS_MSDOS ||
+		     wanted->infos[i].fs_type == FS_EX2FS))
 			wanted->infos[i].flags |=
 			    PUIFLG_ADD_INNER|PUIFLAG_ADD_OUTER;
 
@@ -1008,8 +1015,8 @@ fill_defaults(struct partition_usage_set
 	 * empty disk. Merge the partitions in target range that are already
 	 * there (match with wanted) or are there additionaly.
 	 * The only thing outside of target range that we care for
-	 * are FAT partitions and a potential swap partition - we assume one
-	 * is enough.
+	 * are FAT partitions, EXT2FS partitions, and a potential
+	 * swap partition - we assume one is enough.
 	 */
 	size_t num = wanted->num;
 	if (parts->parent) {
@@ -1020,7 +1027,8 @@ fill_defaults(struct partition_usage_set
 			    parts->parent, pno, &info))
 				continue;
 			if (info.nat_type->generic_ptype != PT_swap &&
-			    info.fs_type != FS_MSDOS)
+			    info.fs_type != FS_MSDOS &&
+			    info.fs_type != FS_EX2FS)
 				continue;
 			merge_part_with_wanted(parts->parent, pno, &info,
 			    wanted, num, true);
Index: disklabel.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/sysinst/disklabel.c,v
retrieving revision 1.10.2.9
diff -u -p -d -r1.10.2.9 disklabel.c
--- disklabel.c	10 Feb 2020 21:39:37 -0000	1.10.2.9
+++ disklabel.c	12 Jun 2020 18:47:01 -0000
@@ -582,6 +582,9 @@ dl_init_types(void)
 				pt = PT_root; break;
 		case FS_SWAP:	pt = PT_swap; break;
 		case FS_MSDOS:	pt = PT_FAT; break;
+		case FS_EX2FS:	pt = PT_EXT2; break;
+		case FS_SYSVBFS:
+				pt = PT_SYSVBFS; break;
 		default:	pt = PT_unknown; break;
 		}
 		dl_types[i].generic_ptype = pt;
@@ -707,6 +710,9 @@ disklabel_get_generic_type(enum part_typ
 	case PT_FAT:
 	case PT_EFI_SYSTEM:
 			nt = FS_MSDOS; break;
+	case PT_EXT2:	nt = FS_EX2FS; break;
+	case PT_SYSVBFS:
+			nt = FS_SYSVBFS; break;
 	default:	nt = FS_UNUSED; break;
 	}
 
Index: mbr.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/sysinst/mbr.c,v
retrieving revision 1.19.2.6
diff -u -p -d -r1.19.2.6 mbr.c
--- mbr.c	10 Feb 2020 21:39:37 -0000	1.19.2.6
+++ mbr.c	12 Jun 2020 18:47:02 -0000
@@ -1117,6 +1117,8 @@ mbr_map_part_type(unsigned int t)
 		return PT_FAT;
 	case MBR_PTYPE_EFI:
 		return PT_EFI_SYSTEM;
+	case MBR_PTYPE_LNXEXT2:
+		return PT_EXT2;
 	case MBR_PTYPE_NETBSD:
 		return PT_root;
 	}
@@ -1279,6 +1281,8 @@ mbr_get_generic_part_type(enum part_type
 		return mbr_get_gen_type_desc(MBR_PTYPE_NETBSD);
 	case PT_FAT:
 		return mbr_get_gen_type_desc(MBR_PTYPE_FAT32L);
+	case PT_EXT2:
+		return mbr_get_gen_type_desc(MBR_PTYPE_LNXEXT2);
 	case PT_EFI_SYSTEM:
 		return mbr_get_gen_type_desc(MBR_PTYPE_EFI);
 	default:
@@ -1386,6 +1390,9 @@ mbr_do_get_part_info(const struct disk_p
 		case MBR_PTYPE_EFI:
 			info->fs_type = FS_MSDOS;
 			break;
+		case MBR_PTYPE_LNXEXT2:
+			info->fs_type = FS_EX2FS;
+			break;
 		case MBR_PTYPE_XENIX_ROOT:
 		case MBR_PTYPE_XENIX_USR:
 			info->fs_type = FS_SYSV;
Index: partitions.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/sysinst/partitions.h,v
retrieving revision 1.4.2.6
diff -u -p -d -r1.4.2.6 partitions.h
--- partitions.h	28 Jan 2020 10:17:58 -0000	1.4.2.6
+++ partitions.h	12 Jun 2020 18:47:02 -0000
@@ -91,6 +91,8 @@ enum part_type {
 	PT_root,		/* the NetBSD / partition (bootable) */
 	PT_swap,		/* the NetBSD swap partition */
 	PT_FAT,			/* boot partition (e.g. for u-boot) */
+	PT_EXT2,		/* boot partition (for Linux appliances) */
+	PT_SYSVBFS,		/* boot partition (for some SYSV machines) */
 	PT_EFI_SYSTEM,		/* (U)EFI boot partition */
 };
 
Index: arch/cobalt/md.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/sysinst/arch/cobalt/md.c,v
retrieving revision 1.8.2.3
diff -u -p -d -r1.8.2.3 md.c
--- arch/cobalt/md.c	28 Jan 2020 10:17:57 -0000	1.8.2.3
+++ arch/cobalt/md.c	12 Jun 2020 18:47:02 -0000
@@ -281,12 +281,12 @@ md_parts_use_wholedisk(struct disk_parti
 	struct disk_part_info boot_part = {
 		.size = PART_BOOT / 512,
 		.fs_type = PART_BOOT_TYPE,
-		.fs_sub_type = MBR_PTYPE_FAT12,
+		.fs_sub_type = MBR_PTYPE_LNXEXT2,
 		.last_mounted = PART_BOOT_MOUNT,
 	};
 
 	boot_part.nat_type = parts->pscheme->get_fs_part_type(
-	    PT_root, boot_part.fs_type, boot_part.fs_sub_type);
+	    PT_EXT2, boot_part.fs_type, boot_part.fs_sub_type);
 
 	return parts_use_wholedisk(parts, 1, &boot_part);
 }

---

 You can now change the sizes for the system partitions.  The default is to
 allocate all the space to the root file system.  However, you may wish to
 have separate /usr (additional system files), /var (log files etc) or /home
 (users' home directories) file systems.

 Free space will be added to the partition marked with a '+'.
 Other markers: '@' external partition.

       Size (sec)                            Filesystem
       ----------------------------------- - --------------------
   >a: 10240                               @ /ext2
    b: 774144 (973488)                     + /
    c: 65536                                 <swap>
    d: 0                                     /tmp (mfs)
    e: 0                                     /usr
    f: 0                                     /var
       ----------------------------------- - --------------------
    h: Add a user defined partition
    i: Clone external partition(s)
    j: Change input units (sectors/cylinders/MB/GB)
    x: Go on.  Free space 199344 sec.

---

 We now have your disklabel partitions for wd0 below.  This is your last   
 chance to change them. 
 
 Flags: (N)ewfs.  Total size: 507M, free: 5120K

     Start (sec)    End (sec)   Size (sec)  FS type Flag Filesystem
    ------------ ------------ ------------ -------- ---- ----------------
 a:        10304       973551       963248   4.2BSD N    /
 b:       973553      1039088        65536     swap
 c:        10304      1049327      1039024 NetBSD partition
 d:            0      1049327      1049328 Whole disk
 e:           63        10302        10240 Linux Ex N    /ext2
    ------------ ------------ ------------ -------- ---- ----------------
 g: Change input units (sectors/cylinders/MB/GB)
 h: Edit name of the disk
 i: Clone external partition(s)
 j: Cancel
>x: Partition sizes ok

---

I have no idea what "PUIFLAG_foo" flags mean and
what "enum part_type" (PT_foo) values mean at all
so all changes are applied blindly per implementation
for current existing "PT_FAT" ones.

---
Izumi Tsutsui



Home | Main Index | Thread Index | Old Index