diff options
-rw-r--r-- | sbin/gpt/create.c | 20 | ||||
-rw-r--r-- | sbin/gpt/gpt.8 | 11 |
2 files changed, 25 insertions, 6 deletions
diff --git a/sbin/gpt/create.c b/sbin/gpt/create.c index 6591b93..54084c2 100644 --- a/sbin/gpt/create.c +++ b/sbin/gpt/create.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "map.h" #include "gpt.h" +static int force; static int primary_only; static void @@ -46,7 +47,7 @@ usage_create(void) { fprintf(stderr, - "usage: %s [-p] device ...\n", getprogname()); + "usage: %s [-fp] device ...\n", getprogname()); exit(1); } @@ -70,9 +71,15 @@ create(int fd) warnx("%s: error: device already contains a GPT", device_name); return; } - if (map_find(MAP_TYPE_MBR) != NULL) { - warnx("%s: error: device contains a MBR", device_name); - return; + map = map_find(MAP_TYPE_MBR); + if (map != NULL) { + if (!force) { + warnx("%s: error: device contains a MBR", device_name); + return; + } + + /* Nuke the MBR in our internal map. */ + map->map_type = MAP_TYPE_UNUSED; } /* @@ -206,8 +213,11 @@ cmd_create(int argc, char *argv[]) { int ch, fd; - while ((ch = getopt(argc, argv, "p")) != -1) { + while ((ch = getopt(argc, argv, "fp")) != -1) { switch(ch) { + case 'f': + force = 1; + break; case 'p': primary_only = 1; break; diff --git a/sbin/gpt/gpt.8 b/sbin/gpt/gpt.8 index a96d694..8909812 100644 --- a/sbin/gpt/gpt.8 +++ b/sbin/gpt/gpt.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 30, 2004 +.Dd November 12, 2004 .Os .Dt GPT 8 .Sh NAME @@ -138,12 +138,21 @@ as aliases for the most commonly used partition types. .It Xo .Nm .Ic create +.Op Fl f .Op Fl p .Ar device ... .Xc The .Ic create command allows the user to create a new (empty) GPT. +By default one can not create a GPT when the device contains a MBR, +however this can be overridden with the +.Fl f +option. +If the +.Fl f +option is specified, an existing MBR is destroyed and any partitions +described by the MBR are lost. .Pp The .Fl p |