--- /n/sources/plan9/sys/src/9/boot/parts.c Wed Mar 12 09:50:03 2014 +++ /sys/src/9/boot/parts.c Fri Sep 11 05:59:31 2026 @@ -533,6 +533,29 @@ } static void +exportpartitions(SDunit *unit, char *var) +{ + SDpart *pp; + char buf[Maxsec]; + char *s, *se; + char *sep; + int i; + + s = buf; + se = buf + Maxsec; + sep = ""; + pp = unit->part; + for(i = 0; i < unit->npart; i++, pp++){ + if(!pp->valid || strcmp(pp->name, "data") == 0) + continue; + s = seprint(s, se, "%s%s %lld %lld", sep, pp->name, pp->start, pp->end); + sep = "/"; + } + if(s > buf) + setenv(var, buf); +} + +static void setpartitions(char *name, int ctl, int data) { SDunit sdunit; @@ -559,6 +582,12 @@ mbrbuf = malloc(Maxsec); partbuf = malloc(Maxsec); partition(unit); + /* + * export usb storage partition definitions for partfs + * if the boot loader didn't do it + */ + if(strncmp(unit->name, "/dev/sdU0.0/", 12) == 0 && getenv("sdB0part") == nil) + exportpartitions(unit, "sdB0part"); free(unit->part); } @@ -594,11 +623,10 @@ ctl = open(ctlname, ORDWR); data = open(dataname, OREAD); - free(ctlname); - free(dataname); - if (ctl >= 0 && data >= 0) setpartitions(dataname, ctl, data); + free(ctlname); + free(dataname); close(ctl); close(data); } --- /n/sources/plan9/sys/man/8/partfs Thu Mar 29 10:50:01 2012 +++ /sys/man/8/partfs Fri Sep 11 05:59:31 2026 @@ -66,6 +66,16 @@ to assist booting from USB disks. .PP The +.I 9boot +loaders do not set the variable, so with them +.IR boot (8) +builds it from the partition table of the USB disk itself, +provided +.B readparts +is set in +.IR plan9.ini (8). +.PP +The .B -s option causes .I partfs --- /n/sources/plan9/sys/man/8/plan9.ini Fri May 11 10:50:09 2012 +++ /sys/man/8/plan9.ini Fri Sep 11 05:59:31 2026 @@ -738,6 +738,12 @@ .IR 9boot ) normally does this and passes the partitions found in .BR #ec/sd\fICn\fPpart . +When the loader has not, +.IR boot (8) +sets +.B sdB0part +itself from the partitions of the first USB disk, for +.IR partfs (8). .SS \fLfs=\fIa.b.c.d .SS \fLauth=\fIa.b.c.d These specify the IP address of the file and authentication server