diff --git a/sbin/gpt/gpt.8 b/sbin/gpt/gpt.8 index 8909812ac5b1..57c93c4b2df1 100644 --- a/sbin/gpt/gpt.8 +++ b/sbin/gpt/gpt.8 @@ -180,6 +180,7 @@ to destroy the table in a way that it can be recovered. .It Xo .Nm .Ic migrate +.Op Fl f .Op Fl s .Ar device ... .Xc @@ -187,6 +188,15 @@ The .Ic migrate command allows the user to migrate an MBR-based disk partitioning into a GPT-based partitioning. +By default the MBR is not migrated when it contains partitions of an unknown +type. +This can be overridden with the +.Fl f +option. +Specifying the +.Fl f +option will cause unknown partitions to be ignored and any data in it +to be lost. .Pp The .Fl s diff --git a/sbin/gpt/migrate.c b/sbin/gpt/migrate.c index d0f1485f13df..eb89941755ff 100644 --- a/sbin/gpt/migrate.c +++ b/sbin/gpt/migrate.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #define LABELSECTOR 1 #endif +static int force; static int slice; static void @@ -58,7 +59,7 @@ usage_migrate(void) { fprintf(stderr, - "usage: %s [-s] device\n", getprogname()); + "usage: %s [-fs] device\n", getprogname()); exit(1); } @@ -271,9 +272,11 @@ migrate(int fd) break; } default: - warnx("%s: error: unknown partition type (%d)", - device_name, mbr->mbr_part[i].part_typ); - return; + if (!force) { + warnx("%s: error: unknown partition type (%d)", + device_name, mbr->mbr_part[i].part_typ); + return; + } } } ent = tbl->map_data; @@ -329,8 +332,11 @@ cmd_migrate(int argc, char *argv[]) int ch, fd; /* Get the migrate options */ - while ((ch = getopt(argc, argv, "s")) != -1) { + while ((ch = getopt(argc, argv, "fs")) != -1) { switch(ch) { + case 'f': + force = 1; + break; case 's': slice = 1; break;