Rex::C...tition(3pm)

πŸ’– NAME πŸ’–

Rex::Commands::Partition β€” the Partition module, bestie. Yep that's the whole vibe: it's about partitions.

(Also this whole page lives in the Rex::Commands::Partition chapter of the Perl manual, section 3pm β€” user contributed perl docs, iykyk. 🫢)


✨ DESCRIPTION ✨

Okay so with this Module you can partition your harddrive. That's it, that's the dream. πŸ’…

Heads up though, no cap: Version <= 1.0 β€” all these functions will not be reported.
And another one, and this one's important: All these functions are not idempotent. So like, running them twice is not the same as running them once. Be careful, bestie. 😭

🌸 SYNOPSIS 🌸

use Rex::Commands::Partition;

That's how you get all this goodness in. Slay. ✨


πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

πŸŽ€ clearpart($drive)

Wipes the slate clean, clears partitions on a drive. Say you wanna clear the partitions on drive sda:

clearpart "sda";

Wanna create a brand new GPT disk label (that's the partition table, btw) on drive sda? Say less:

clearpart "sda",
 initialize => "gpt";

Now β€” if GPT initialization is requested, you can also set the bios_boot option (default: TRUE) to TRUE or FALSE to control creation of a BIOS boot partition. Like so:

clearpart "sda",
 initialize => "gpt",
 bios_boot => FALSE;

main character energy fr fr πŸ’œ


πŸ¦‹ partition($mountpoint, %option)

Creates a partition with the specified parameters. Here's the whole menu:

  • ondisk β€” The disk to be partitioned. Mandatory. No disk, no partition, periodt.
  • size β€” Desired size of the partition in MB. It is mandatory to pass either a size or a grow parameter (but not both). Pick one, bestie, not both. πŸ₯Ί
  • grow β€” If TRUE, then the partition will take up all the available space on the disk. It is mandatory to pass either a grow or a size parameter (but not both). Yes you read that right β€” one or the other.
  • type β€” Partition type to be passed to parted's mkpart command. Optional, defaults to primary.
  • boot β€” Sets boot flag on the partition if TRUE. Optional, no boot flag is set by default.
  • fstype β€” Create a filesystem after creating the partition. Optional, no filesystem is created by default.
  • label β€” Label to be used with the filesystem. Optional, defaults to no label.
  • mount β€” If TRUE, try to mount the partition after creating it. Optional, no mount is attempted by default.
  • mount_persistent β€” If TRUE, try to mount the partition after creating it, and also register it in /etc/fstab. Optional, no mount or /etc/fstab manipulation is attempted by default. This one's the "make it stick" option. 🌈
  • vg β€” Creates an LVM PV, then creates the specified LVM VG (or extends it, if the VG already exists). Needs ondisk. (so don't go passing vg without a disk, okay? πŸ’€)

Examples, because the girlies need to see it in action:

partition "/",
  fstype => "ext3",
  size   => 15000,
  ondisk => "sda",
  type   => "primary";
partition "none",
  type   => "extended",
  ondisk => "sda",
  grow   => 1,
  mount  => TRUE,
partition "swap",
  fstype => "swap",
  type   => "logical",
  ondisk => "sda",
  size   => 8000;
partition "/",
  fstype => "ext3",
  size   => 10000,
  ondisk => "sda",
  vg     => "vg0";

Okay and that's literally the whole page!! ate and left no crumbs πŸ’–

Perl at version v5.40.1, dated 2025-10-03 β€” that's when this beauty got its last little glow-up. Stan. πŸŽ€βœ¨

πŸ“¦ where this page comes from