Remove the -k option to migrate. The option causes gpt(8) to preserve

the MBR after it is migrated to a GPT. While this was useful during
the early days when GPT support was under development, it's something
that users can use without knowing what they're getting themselves
into. The possible harm outweights the marginal usefulness it now has.
This commit is contained in:
Marcel Moolenaar 2004-10-31 02:20:17 +00:00
parent a1107cc375
commit d88642fe52
2 changed files with 25 additions and 39 deletions

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 7, 2004
.Dd October 30, 2004
.Os
.Dt GPT 8
.Sh NAME
@ -171,7 +171,6 @@ to destroy the table in a way that it can be recovered.
.It Xo
.Nm
.Ic migrate
.Op Fl k
.Op Fl s
.Ar device ...
.Xc
@ -181,14 +180,6 @@ command allows the user to migrate an MBR-based disk partitioning into a
GPT-based partitioning.
.Pp
The
.Fl k
option instructs
.Nm
to not destroy the current MBR.
This option is primarily useful for debugging and should not be used by
users.
.Pp
The
.Fl s
option prevents migrating
.Bx

View File

@ -51,14 +51,14 @@ __FBSDID("$FreeBSD$");
#define LABELSECTOR 1
#endif
static int keep, slice;
static int slice;
static void
usage_migrate(void)
{
fprintf(stderr,
"usage: %s [-ks] device\n", getprogname());
"usage: %s [-s] device\n", getprogname());
exit(1);
}
@ -299,30 +299,28 @@ migrate(int fd)
gpt_write(fd, lbt);
gpt_write(fd, tpg);
if (!keep) {
map = map_find(MAP_TYPE_MBR);
mbr = map->map_data;
/*
* Turn the MBR into a Protective MBR.
*/
bzero(mbr->mbr_part, sizeof(mbr->mbr_part));
mbr->mbr_part[0].part_shd = 0xff;
mbr->mbr_part[0].part_ssect = 0xff;
mbr->mbr_part[0].part_scyl = 0xff;
mbr->mbr_part[0].part_typ = 0xee;
mbr->mbr_part[0].part_ehd = 0xff;
mbr->mbr_part[0].part_esect = 0xff;
mbr->mbr_part[0].part_ecyl = 0xff;
mbr->mbr_part[0].part_start_lo = htole16(1);
if (mediasz > 0xffffffff) {
mbr->mbr_part[0].part_size_lo = htole16(0xffff);
mbr->mbr_part[0].part_size_hi = htole16(0xffff);
} else {
mbr->mbr_part[0].part_size_lo = htole16(mediasz);
mbr->mbr_part[0].part_size_hi = htole16(mediasz >> 16);
}
gpt_write(fd, map);
map = map_find(MAP_TYPE_MBR);
mbr = map->map_data;
/*
* Turn the MBR into a Protective MBR.
*/
bzero(mbr->mbr_part, sizeof(mbr->mbr_part));
mbr->mbr_part[0].part_shd = 0xff;
mbr->mbr_part[0].part_ssect = 0xff;
mbr->mbr_part[0].part_scyl = 0xff;
mbr->mbr_part[0].part_typ = 0xee;
mbr->mbr_part[0].part_ehd = 0xff;
mbr->mbr_part[0].part_esect = 0xff;
mbr->mbr_part[0].part_ecyl = 0xff;
mbr->mbr_part[0].part_start_lo = htole16(1);
if (mediasz > 0xffffffff) {
mbr->mbr_part[0].part_size_lo = htole16(0xffff);
mbr->mbr_part[0].part_size_hi = htole16(0xffff);
} else {
mbr->mbr_part[0].part_size_lo = htole16(mediasz);
mbr->mbr_part[0].part_size_hi = htole16(mediasz >> 16);
}
gpt_write(fd, map);
}
int
@ -331,11 +329,8 @@ cmd_migrate(int argc, char *argv[])
int ch, fd;
/* Get the migrate options */
while ((ch = getopt(argc, argv, "ks")) != -1) {
while ((ch = getopt(argc, argv, "s")) != -1) {
switch(ch) {
case 'k':
keep = 1;
break;
case 's':
slice = 1;
break;