Index: sbin/geom/class/part/geom_part.c =================================================================== --- sbin/geom/class/part/geom_part.c +++ sbin/geom/class/part/geom_part.c @@ -87,7 +87,7 @@ static void gpart_show_geom(struct ggeom *, const char *, int); static int gpart_show_hasopt(struct gctl_req *, const char *, const char *); static void gpart_write_partcode(struct ggeom *, int, void *, ssize_t); -static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *); +static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *, ssize_t); static void gpart_print_error(const char *); static void gpart_backup(struct gctl_req *, unsigned int); static void gpart_restore(struct gctl_req *, unsigned int); @@ -1145,13 +1145,16 @@ } static void -gpart_write_partcode_vtoc8(struct ggeom *gp, int idx, void *code) +gpart_write_partcode_vtoc8(struct ggeom *gp, int idx, void *code, + ssize_t size) { char dsf[128]; struct gprovider *pp; const char *s; int installed, fd; + assert(size == VTOC_BOOTSIZE); + installed = 0; LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { s = find_provcfg(pp, "index"); @@ -1273,7 +1276,7 @@ } else { if (partsize != VTOC_BOOTSIZE) errx(EXIT_FAILURE, "invalid bootcode"); - gpart_write_partcode_vtoc8(gp, idx, partcode); + gpart_write_partcode_vtoc8(gp, idx, partcode, partsize); } } else if (bootcode == NULL) Index: sbin/geom/class/virstor/geom_virstor.c =================================================================== --- sbin/geom/class/virstor/geom_virstor.c +++ sbin/geom/class/virstor/geom_virstor.c @@ -183,6 +183,7 @@ goto out; } bcopy(md, sector, size); + bzero(sector + size, sectorsize - size); if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) != (ssize_t)sectorsize) { error = errno; Index: sbin/geom/misc/subr.c =================================================================== --- sbin/geom/misc/subr.c +++ sbin/geom/misc/subr.c @@ -302,6 +302,7 @@ goto out; } bcopy(md, sector, size); + bzero(sector + size, sectorsize - size); if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) != sectorsize) { error = errno;