diff options
author | Karel Zak | 2015-04-13 17:24:45 +0200 |
---|---|---|
committer | Karel Zak | 2015-04-13 17:24:45 +0200 |
commit | aeb9a30ba4e99bfaf33a0986562766d8480a3e4c (patch) | |
tree | 64ad6992debbd9a73eaa9f8ff7286a2716a17d1a | |
parent | sfdisk: enable bootbits protection (diff) | |
download | kernel-qcow2-util-linux-aeb9a30ba4e99bfaf33a0986562766d8480a3e4c.tar.gz kernel-qcow2-util-linux-aeb9a30ba4e99bfaf33a0986562766d8480a3e4c.tar.xz kernel-qcow2-util-linux-aeb9a30ba4e99bfaf33a0986562766d8480a3e4c.zip |
fdisk: add --protect-boot
Now fdisk erases the begin of the device when create a new disk label, it seems
like disadvantage for some use-cases.
Reported-by: Jean-Loup 'clippix' Bogalho <clippix@lse.epita.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | disk-utils/fdisk.8 | 4 | ||||
-rw-r--r-- | disk-utils/fdisk.c | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/disk-utils/fdisk.8 b/disk-utils/fdisk.8 index 1350d0257..fb298220e 100644 --- a/disk-utils/fdisk.8 +++ b/disk-utils/fdisk.8 @@ -53,6 +53,10 @@ to override the kernel's ideas.) Since util-linux-2.17, \fBfdisk\fR differentia between logical and physical sector size. This option changes both sector sizes to .IB sectorsize . .TP +\fB\-B\fR, \fB\-\-protect\-boot\fP +Don't erase the begin of the first disk sector when create a new disk label. This +feature is supported for GPT and MBR. +.TP \fB\-c\fR, \fB\-\-compatibility\fR[\fI=mode\fR] Specify the compatibility mode, 'dos' or 'nondos'. The default is non-DOS mode. For backward compatibility, it is possible to use the option without diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 48c4d1734..29bcb7183 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -680,6 +680,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) fputs(USAGE_OPTIONS, out); fputs(_(" -b, --sector-size <size> physical and logical sector size\n"), out); + fputs(_(" -B, --protect-boot don't erase bootbits when creat a new label\n"), out); fputs(_(" -c, --compatibility[=<mode>] mode is 'dos' or 'nondos' (default)\n"), out); fputs(_(" -L, --color[=<when>] colorize output (auto, always or never)\n"), out); fprintf(out, @@ -737,6 +738,7 @@ int main(int argc, char **argv) { "units", optional_argument, NULL, 'u' }, { "version", no_argument, NULL, 'V' }, { "output", no_argument, NULL, 'o' }, + { "protect-boot", no_argument, NULL, 'B' }, { NULL, 0, NULL, 0 } }; @@ -754,7 +756,7 @@ int main(int argc, char **argv) fdisk_set_ask(cxt, ask_callback, NULL); - while ((c = getopt_long(argc, argv, "b:c::C:hH:lL::o:sS:t:u::vV", + while ((c = getopt_long(argc, argv, "b:Bc::C:hH:lL::o:sS:t:u::vV", longopts, NULL)) != -1) { switch (c) { case 'b': @@ -766,6 +768,9 @@ int main(int argc, char **argv) fdisk_save_user_sector_size(cxt, sz, sz); break; } + case 'B' + fdisk_enable_bootbits_protection(cxt, 1); + break; case 'C': fdisk_save_user_geometry(cxt, strtou32_or_err(optarg, |