[Parted-maintainers] Bug#1021403: [parted] /usr/sbin/parted: invalid token: swap

Colin Watson cjwatson at debian.org
Fri Oct 7 17:29:01 BST 2022


Control: severity -1 normal
Control: fixed -1 3.5-1

On Fri, Oct 07, 2022 at 05:29:14PM +0200, Jean-Marc LACROIX wrote:
> Severity: critical

"makes unrelated software on the system (or the whole system) break, or
causes serious data loss, or introduces a security hole on systems where
you install the package"

A difficulty with using the CLI, or even a missing feature in the CLI,
doesn't fall into any of these categories.

> According documentation available in man it seems possible to create one
> partition of type "swap" by using "set" option on command line.
> 
> After many tests done with Linux "parted" command and Ansible module
> "parted", it seems that it is not possible to set one logical partition as a
> swap partition with the flag option available into parted tool.
> 
> My disk uses for test has following partitions...
> 
> ansible at thinkpad-410:~$ sudo fdisk -l /dev/sda
> Disque /dev/sda : 931,51 GiB, 1000204886016 octets, 1953525168 secteurs
> Modèle de disque : HGST HTS721010A9
> Unités : secteur de 1 × 512 = 512 octets
> Taille de secteur (logique / physique) : 512 octets / 4096 octets
> taille d'E/S (minimale / optimale) : 4096 octets / 4096 octets
> Type d'étiquette de disque : dos
> Identifiant de disque : 0x483880d2
> 
> Périphérique Amorçage    Début        Fin   Secteurs Taille Id Type
> /dev/sda1    *            2048   48828415   48826368  23,3G 83 Linux
> /dev/sda2             48830462 1953523711 1904693250 908,2G  5 Étendue
> /dev/sda5             48830464   68360191   19529728   9,3G 8e LVM Linux
> /dev/sda6             68362240   70361087    1998848   976M 82 partition
> d'échange Linux / Solaris

This says that it's already a swap partition, so I'm not sure why you
need to set it as one.  Can you explain further?

(On an MBR partition table like this, all that setting the "swap" flag
does is set the partition type to 0x82.)

> /dev/sda7             70363136   74266623    3903488   1,9G 8e LVM Linux
> /dev/sda8             74268672  279068671  204800000  97,7G 8e LVM Linux
> 
> and when i try to set one partition with swap, then ...
> 
> ansible at thinkpad-410:~$ sudo  /usr/sbin/parted -s -m -a optimal /dev/sda --
> unit KiB set 6 swap on
> /usr/sbin/parted: invalid token: swap
> 
> I have also tried, but without success...
> 
> ansible at thinkpad-410:~$ sudo  /usr/sbin/parted -s -m -a optimal /dev/sda --
> unit KiB set 6 swap on set 6 lvm off
> /usr/sbin/parted: invalid token: swap

This was fixed in parted 3.4.64.  From the NEWS file:

  Add use of the swap partition flag to msdos disk labeled disks.

But since it's already of the correct type, maybe you can just skip that
bit on older versions of parted?

(Or, if your automation is building the entire system from scratch, then
another option might be to use GPT instead of MBR.)

-- 
Colin Watson (he/him)                              [cjwatson at debian.org]



More information about the Parted-maintainers mailing list