sfdisk: extend --part-type, support aliases
* add support for aliases to sfdisk scripts * add shortcuts and aliases to --part-type command Note that --part-type evaluates shortcuts and aliases as the last possibility (so after regular type string). This is necessary for backward compatibility. Example ('raid' type alias): # sfdisk --part-type /dev/sdc 1 raid # fdisk -l /dev/sdc ... Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 204799 202752 99M fd Linux raid autodetect Example ('L' type shortcut): # sfdisk --part-type /dev/sdc 1 L # fdisk -l /dev/sdc ... Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 204799 202752 99M 83 Linux Addresses: https://github.com/karelzak/util-linux/issues/958 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
f94e753b35
commit
5839a4ea03
|
@ -132,7 +132,9 @@ List the free unpartitioned areas on all or the specified devices.
|
||||||
.TP
|
.TP
|
||||||
.BR "\-\-part\-attrs \fIdevice partition-number " [ \fIattributes ]
|
.BR "\-\-part\-attrs \fIdevice partition-number " [ \fIattributes ]
|
||||||
Change the GPT partition attribute bits. If \fIattributes\fR is not specified,
|
Change the GPT partition attribute bits. If \fIattributes\fR is not specified,
|
||||||
then print the current partition settings. The \fIattributes\fR argument is a
|
then print the current partition settings.
|
||||||
|
.sp
|
||||||
|
The \fIattributes\fR argument is a
|
||||||
comma- or space-delimited list of bits. The currently supported attribute
|
comma- or space-delimited list of bits. The currently supported attribute
|
||||||
bits are: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable
|
bits are: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable
|
||||||
and GUID-specific bits in the range from 48 to 63. For example, the string
|
and GUID-specific bits in the range from 48 to 63. For example, the string
|
||||||
|
@ -144,8 +146,11 @@ then print the current partition label.
|
||||||
.TP
|
.TP
|
||||||
.BR "\-\-part\-type \fIdevice partition-number " [ \fItype ]
|
.BR "\-\-part\-type \fIdevice partition-number " [ \fItype ]
|
||||||
Change the partition type. If \fItype\fR is not specified, then print the
|
Change the partition type. If \fItype\fR is not specified, then print the
|
||||||
current partition type. The \fItype\fR argument is hexadecimal for MBR,
|
current partition type.
|
||||||
or a GUID for GPT. For backward compatibility the options \fB\-c\fR and
|
.sp
|
||||||
|
The \fItype\fR argument is hexadecimal for MBR,
|
||||||
|
GUID for GPT, type alias (e.g. "linux") or type shortcut (e.g. 'L').
|
||||||
|
For backward compatibility the options \fB\-c\fR and
|
||||||
\fB\-\-id\fR have the same meaning as this one.
|
\fB\-\-id\fR have the same meaning as this one.
|
||||||
.TP
|
.TP
|
||||||
.BR "\-\-part\-uuid \fIdevice partition-number " [ \fIuuid ]
|
.BR "\-\-part\-uuid \fIdevice partition-number " [ \fIuuid ]
|
||||||
|
@ -405,42 +410,48 @@ partition; existing partitions will be resized as required.
|
||||||
The partition
|
The partition
|
||||||
.I type
|
.I type
|
||||||
is given in hex for MBR (DOS) where 0x prefix is optional; a GUID string for
|
is given in hex for MBR (DOS) where 0x prefix is optional; a GUID string for
|
||||||
GPT; or a shortcut. It's recommended to use two letters for MBR hex codes to
|
GPT; a shortcut or an alias. It's recommended to use two letters for MBR hex codes to
|
||||||
avoid collision between shortcut 'E' and '0E' MBR hex code. For backward
|
avoid collision between deprecated shortcut 'E' and '0E' MBR hex code. For backward
|
||||||
compatibility sfdisk tries to interpret
|
compatibility sfdisk tries to interpret
|
||||||
.I type
|
.I type
|
||||||
as a shortcut as a first possibility. Supported shortcuts:
|
as a shortcut as a first possibility in partitioning scripts although on another places (e.g.
|
||||||
|
\fB\-\-part-type command)\fR it tries shortcuts as the last possibility.
|
||||||
|
|
||||||
|
Since v2.36 libfdisk supports partition type aliases as extension to shortcuts. The alias is a
|
||||||
|
simple human readable word (e.g. "linux").
|
||||||
|
|
||||||
|
Supported shortcuts and aliases:
|
||||||
.RS
|
.RS
|
||||||
.TP
|
.TP
|
||||||
.B L
|
.B L - alias 'linux'
|
||||||
Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT.
|
Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT.
|
||||||
.TP
|
.TP
|
||||||
.B S
|
.B S - alias 'swap'
|
||||||
swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT
|
swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT
|
||||||
.TP
|
.TP
|
||||||
.B E
|
.B Ex - alias 'extended'
|
||||||
extended partition; means 05 for MBR
|
MBR extended partition; means 05 for MBR. The original shortcut 'E' is deprecated due to collision with
|
||||||
|
0x0E MBR partition type.
|
||||||
.TP
|
.TP
|
||||||
.B H
|
.B H - alias 'home'
|
||||||
home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT
|
home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT
|
||||||
.TP
|
.TP
|
||||||
.B X
|
.B U - alias 'uefi'
|
||||||
linux extended partition; means 85 for MBR.
|
|
||||||
.TP
|
|
||||||
.B U
|
|
||||||
EFI System partition, means EF for MBR and C12A7328-F81F-11D2-BA4B-00A0C93EC93B for GPT
|
EFI System partition, means EF for MBR and C12A7328-F81F-11D2-BA4B-00A0C93EC93B for GPT
|
||||||
.TP
|
.TP
|
||||||
.B R
|
.B R - alias 'raid'
|
||||||
Linux RAID; means FD for MBR and A19D880F-05FC-4D3B-A006-743F0F84911E for GPT
|
Linux RAID; means FD for MBR and A19D880F-05FC-4D3B-A006-743F0F84911E for GPT
|
||||||
.TP
|
.TP
|
||||||
.B V
|
.B V - alias 'lvm'
|
||||||
LVM; means 8E for MBR and E6D6D379-F507-44C2-A23C-238F2A3DF928 for GPT
|
LVM; means 8E for MBR and E6D6D379-F507-44C2-A23C-238F2A3DF928 for GPT
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
The default
|
The default
|
||||||
.I type
|
.I type
|
||||||
value is
|
value is
|
||||||
.I L
|
.I linux
|
||||||
|
.sp
|
||||||
|
The shortcut 'X' for Linux extended partition (85) is deprecated in favour of 'Ex'.
|
||||||
|
|
||||||
.I bootable
|
.I bootable
|
||||||
is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. The
|
is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. The
|
||||||
|
|
|
@ -1152,7 +1152,10 @@ static int command_parttype(struct sfdisk *sf, int argc, char **argv)
|
||||||
backup_partition_table(sf, devname);
|
backup_partition_table(sf, devname);
|
||||||
|
|
||||||
/* parse <type> and apply to PT */
|
/* parse <type> and apply to PT */
|
||||||
type = fdisk_label_parse_parttype(lb, typestr);
|
type = fdisk_label_advparse_parttype(lb, typestr,
|
||||||
|
FDISK_PARTTYPE_PARSE_DATA
|
||||||
|
| FDISK_PARTTYPE_PARSE_ALIAS
|
||||||
|
| FDISK_PARTTYPE_PARSE_SHORTCUT);
|
||||||
if (!type)
|
if (!type)
|
||||||
errx(EXIT_FAILURE, _("failed to parse %s partition type '%s'"),
|
errx(EXIT_FAILURE, _("failed to parse %s partition type '%s'"),
|
||||||
fdisk_label_get_name(lb), typestr);
|
fdisk_label_get_name(lb), typestr);
|
||||||
|
@ -1467,7 +1470,7 @@ static void command_fdisk_help(void)
|
||||||
|
|
||||||
fputc('\n', stdout);
|
fputc('\n', stdout);
|
||||||
fputs(_(" <type> The partition type. Default is a Linux data partition.\n"), stdout);
|
fputs(_(" <type> The partition type. Default is a Linux data partition.\n"), stdout);
|
||||||
fputs(_(" MBR: hex or L,S,E,X,U,R,V shortcuts.\n"), stdout);
|
fputs(_(" MBR: hex or L,S,Ex,X,U,R,V shortcuts.\n"), stdout);
|
||||||
fputs(_(" GPT: UUID or L,S,H,U,R,V shortcuts.\n"), stdout);
|
fputs(_(" GPT: UUID or L,S,H,U,R,V shortcuts.\n"), stdout);
|
||||||
|
|
||||||
fputc('\n', stdout);
|
fputc('\n', stdout);
|
||||||
|
|
Loading…
Reference in New Issue