*-r*, *--read-only*::
Forced open in read-only mode.
+*-b*, *--sector-size* _sectorsize_::
+Specify the sector size of the disk. Valid values are 512, 1024, 2048, and 4096. The kernel is aware of the sector size for regular block devices. Use this option only on very old kernels, when working with disk images, or to override the kernel's default sector size. Since util-linux-2.17, *fdisk* distinguishes between logical and physical sector size. This option changes both sector sizes to the specified _sectorsize_.
+
*-z*, *--zero*::
Start with an in-memory zeroed partition table. This option does not zero the partition table on the disk; rather, it simply starts the program without reading the existing partition table. This option allows you to create a new partition table from scratch or from an *sfdisk*(8)-compatible script.
_(" --lock[=<mode>] use exclusive device lock (%s, %s or %s)\n"), "yes", "no", "nonblock");
fputs(_(" -r, --read-only forced open cfdisk in read-only mode\n"), out);
+ fputs(_(" -b, --sector-size <size> physical and logical sector size\n"), out);
+
fputs(USAGE_SEPARATOR, out);
fprintf(out, USAGE_HELP_OPTIONS(26));
const char *diskpath = NULL, *lockmode = NULL;
int rc, c, colormode = UL_COLORMODE_UNDEF;
int read_only = 0;
+ size_t user_ss = 0;
struct cfdisk _cf = { .lines_idx = 0 },
*cf = &_cf;
enum {
{ "color", optional_argument, NULL, 'L' },
{ "lock", optional_argument, NULL, OPT_LOCK },
{ "help", no_argument, NULL, 'h' },
+ { "sector-size", required_argument, NULL, 'b' },
{ "version", no_argument, NULL, 'V' },
{ "zero", no_argument, NULL, 'z' },
{ "read-only", no_argument, NULL, 'r' },
textdomain(PACKAGE);
close_stdout_atexit();
- while((c = getopt_long(argc, argv, "L::hVzr", longopts, NULL)) != -1) {
+ while((c = getopt_long(argc, argv, "b:L::hVzr", longopts, NULL)) != -1) {
switch(c) {
+ case 'b':
+ user_ss = strtou32_or_err(optarg,
+ _("invalid sector size argument"));
+ if (user_ss != 512 && user_ss != 1024 &&
+ user_ss != 2048 && user_ss != 4096)
+ errx(EXIT_FAILURE, _("invalid sector size argument"));
+ break;
case 'h':
usage();
break;
cf->cxt = fdisk_new_context();
if (!cf->cxt)
err(EXIT_FAILURE, _("failed to allocate libfdisk context"));
+ if (user_ss)
+ fdisk_save_user_sector_size(cf->cxt, user_ss, user_ss);
fdisk_set_ask(cf->cxt, ask_callback, (void *) cf);