The last LBA depends on the disk size. It seems like a good idea to
ignore it when using the --force option, in order to make it possible
to apply the script on smaller disks.
Addresses: https://github.com/util-linux/util-linux/issues/3186
Signed-off-by: Karel Zak <kzak@redhat.com>
*first-lba*::
Specify the first usable sector for GPT partitions. This header is ignored if the script and device sector size differ. In this case *sfdisk* uses label specific default.
*last-lba*::
-Specify the last usable sector for GPT partitions. This header is ignored if the script and device sector size differ. In this case *sfdisk* uses label specific default.
+Specify the last usable sector for GPT partitions. This header is ignored if the script and device sector size differ. In this case *sfdisk* uses label specific default. The last-lba header is ignored if *--force* is specified, making the script usable on disks with different sizes.
*table-length*::
Specify the maximal number of GPT partitions.
*grain*::
ignored++;
continue;
}
- if (!created) { /* create a new disklabel */
+ if (!created) {
+ /* ignore "last-lba" and use default if --force specified */
+ if (sf->force && fdisk_script_get_header(dp, "last-lba")) {
+ fdisk_info(sf->cxt, _("Ignoring last-lba script header."));
+ fdisk_script_set_header(dp, "last-lba", NULL);
+ }
+
+ /* create a new disklabel */
rc = fdisk_apply_script_headers(sf->cxt, dp);
created = !rc;
if (rc) {
fdisk_warn(sf->cxt, _(
"Failed to apply script headers, disk label not created"));
}
-
if (rc == 0 && fdisk_get_collision(sf->cxt))
follow_wipe_mode(sf);
}