While help set
(as well as the man page) just gives you an uncommented list of flags, it does not tell you which flags are supported by which partition scheme.
The invalid token message seems to be just what you get when a flag is unavailable. There should be a more user friendly error message.
In parted 3.2, for GPT partitions, the flags swap
, root
, lba
are unavailable:
static int
gpt_partition_is_flag_available (const PedPartition *part,
PedPartitionFlag flag)
{
switch (flag)
{
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
case PED_PARTITION_BOOT:
case PED_PARTITION_BIOS_GRUB:
case PED_PARTITION_HPSERVICE:
case PED_PARTITION_MSFT_RESERVED:
case PED_PARTITION_MSFT_DATA:
case PED_PARTITION_DIAG:
case PED_PARTITION_APPLE_TV_RECOVERY:
case PED_PARTITION_HIDDEN:
case PED_PARTITION_LEGACY_BOOT:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
case PED_PARTITION_ESP:
return 1;
case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default:
return 0;
}
return 0;
}
MSDOS only supports these flags:
static int
msdos_partition_is_flag_available (const PedPartition* part,
PedPartitionFlag flag)
{
switch (flag) {
case PED_PARTITION_HIDDEN:
if (part->type == PED_PARTITION_EXTENDED)
return 0;
else
return 1;
case PED_PARTITION_BOOT:
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
case PED_PARTITION_LBA:
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
case PED_PARTITION_ESP:
case PED_PARTITION_DIAG:
return 1;
default:
return 0;
}
}
So, what's up with the swap
flag?
Turns out it's supported by DVH:
static int
dvh_partition_is_flag_available (const PedPartition* part,
PedPartitionFlag flag)
{
switch (flag) {
case PED_PARTITION_ROOT:
case PED_PARTITION_SWAP:
case PED_PARTITION_BOOT:
return 1;
...as well as MAC partitions:
static int
mac_partition_is_flag_available (
const PedPartition* part, PedPartitionFlag flag)
{
switch (flag) {
case PED_PARTITION_BOOT:
case PED_PARTITION_ROOT:
case PED_PARTITION_SWAP:
case PED_PARTITION_LVM:
case PED_PARTITION_RAID:
return 1;
The good news is that Linux doesn't really care much about partition types in the first place. So you can use any partition for swap, regardless whether the partition table says so.
According to the code above, for msdos partition label, you cannot set hidden
flag if the partition is extended. This is a good way to test the error message given by parted:
(parted) mklabel msdos # new dos partition
(parted) mkpart primary 1MiB 2MiB # primary
(parted) mkpart extended 2MiB 10MiB # extended
(parted) mkpart logical 3MiB 4MiB # logical
(parted) set 1 hidden on # OK
(parted) set 2 hidden on # FAIL
parted: invalid token: hidden # very helpful message
Flag to Invert? # I didn't mistype
(parted) set 5 hidden on # OK
So there we are. Unsupported flags just get invalid token message, and kind of implies you mistyped it or something, but you didn't do anything wrong, it's just parted not supporting these flags in some cases.