We do not use sector-size from dumps to create partition tables,
because it's always necessary to use real device specific settings.
The new sector-size value is usable when you use the dump as
a description of the device or disk image.
Addresses: https://github.com/karelzak/util-linux/issues/869
Signed-off-by: Karel Zak <kzak@redhat.com>
Specify minimal size in bytes used to calculate partitions alignment. The
default is 1MiB and it's strongly recommended to use the default. Do not
modify this variable if you're not sure.
Specify minimal size in bytes used to calculate partitions alignment. The
default is 1MiB and it's strongly recommended to use the default. Do not
modify this variable if you're not sure.
+.TP
+.B sector-size
+Specify sector size. This header is informative only and it is not used when
+sfdisk creates a new partition table, in this case the real device specific
+value is always used and sector size from the dump is ignored.
.RE
.sp
Note that it is only possible to use header lines before the first partition
.RE
.sp
Note that it is only possible to use header lines before the first partition
struct fdisk_label *lb;
int rc;
char *p = NULL;
struct fdisk_label *lb;
int rc;
char *p = NULL;
if (!dp || (!cxt && !dp->cxt))
return -EINVAL;
if (!dp || (!cxt && !dp->cxt))
return -EINVAL;
if (!rc && fdisk_is_label(cxt, GPT)) {
struct fdisk_labelitem item = FDISK_LABELITEM_INIT;
if (!rc && fdisk_is_label(cxt, GPT)) {
struct fdisk_labelitem item = FDISK_LABELITEM_INIT;
/* first-lba */
rc = fdisk_get_disklabel_item(cxt, GPT_LABELITEM_FIRSTLBA, &item);
/* first-lba */
rc = fdisk_get_disklabel_item(cxt, GPT_LABELITEM_FIRSTLBA, &item);
}
if (!rc && fdisk_get_grain_size(cxt) != 2048 * 512) {
}
if (!rc && fdisk_get_grain_size(cxt) != 2048 * 512) {
snprintf(buf, sizeof(buf), "%lu", fdisk_get_grain_size(cxt));
rc = fdisk_script_set_header(dp, "grain", buf);
}
snprintf(buf, sizeof(buf), "%lu", fdisk_get_grain_size(cxt));
rc = fdisk_script_set_header(dp, "grain", buf);
}
+ if (!rc) {
+ snprintf(buf, sizeof(buf), "%lu", fdisk_get_sector_size(cxt));
+ rc = fdisk_script_set_header(dp, "sector-size", buf);
+ }
DBG(SCRIPT, ul_debugobj(dp, "read context done [rc=%d]", rc));
return rc;
DBG(SCRIPT, ul_debugobj(dp, "read context done [rc=%d]", rc));
return rc;
} else if (strcmp(name, "last-lba") == 0) {
name = "lastlba";
num = 1;
} else if (strcmp(name, "last-lba") == 0) {
name = "lastlba";
num = 1;
+ } else if (strcmp(name, "sector-size") == 0) {
+ name = "sectorsize";
+ num = 1;
} else if (strcmp(name, "label-id") == 0)
name = "id";
} else if (strcmp(name, "label-id") == 0)
name = "id";