Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active May 5, 2023 07:14
Show Gist options
  • Save mjf/f9e295512a394d1b90ce to your computer and use it in GitHub Desktop.
Save mjf/f9e295512a394d1b90ce to your computer and use it in GitHub Desktop.
PAL - Partitioning Automation Language

PAL

Partitioning Automation Language

Version: 0.1
Author: Matous Jan Fialka
Copyright: Released under the terms of The MIT License
Manual section:3
Manual group:automation

SYNOPSIS

pal [CODE] [< FILE]

where:

CODE
PAL code to proceed (preceeds any PAL code comming from FILE).
FILE
File containing PAL code to proceed (defaults to STDIN if no file is regirected to standard input),

SYNTAX

Expressed using the Augmented Backus-Naur Form (ABNF) the PAL has the following syntax:

PAL = [[NUM / DFL] CMD [ARG]] ["@" TGT] [[";"] PAL] ["#" IGN]

NUM = DEC / "0x" HEX

DEC = DIG [DEC]

HEX = (DIG / "a" / "b" / "c" / "d" / "e" / "f") [HEX]

DIG = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"

DFL = "D" / "DEFAULT"

CMD = "M" / "MBR"
    / "T" / "PARTBL"
    / "P" / "PAR"
    / "R" / "RAID"
    / "V" / "PHYVOL"
    / "G" / "VOLGRP"
    / "L" / "LOGVOL"
    / "F" / "FILESYS"

ARG = OPT ["," ARG]

TGT = DEV ["," TGT]

where:

PAL
Partitioning Automation Language,
NUM
PAL command sequential number (optional),
CMD
PAL command,
ARG
PAL command argument (optional),
TGT
PAL command target,
OPT
PAL command argument option (or set of options),
DEV
PAL command target device (or set of devices).
IGN
PAL remarks (optional comments; "ignored")
Notes:

The ARG varies for every CMD (see COMMAND ARGUMENTS and EXAMPLES below).

All characters with decimal number less than 33 in ASCII character table except the End of Line (EoL) characters are skipped in case of file input or treated as squeezed and transformed to semicolon (";") characters in case of command line arguments. In case of file input the EoL characters are treated as squeezed and transformed to semicolon (";") characters.

COMMAND ARGUMENTS

The arguments for PAL commands are as follows:

MBR

"d" ["elete"]

Delete (zero) the MBR if it exists.

PARTBL

"d" ["elete"] / "g" ["pt"] / "m" ["sdos"] / "0x" HEX

Delete partition table or set partition table to either GUID Partition Table (GPT), MSDOS or any other either named or hexanumerical type (defaults to gpt).

EXAMPLES

Complex example, including fully expanded forms of abbreviated commands written in remarks (21 operations in total, numbers denote the order of expansion), is the following:

#! /usr/bin/env pal
#
# 01 PARTBL delete @ sda
# 03 PARTBL delete @ sdb
# 05 PARTBL delete @ sdc
# 07 PARTBL delete @ sdd
#
# 02 PARTBL GPT @ sda
# 04 PARTBL GPT @ sdb
# 06 PARTBL GPT @ sdc
# 08 PARTBL GPT @ sdd
#
Td,g

#
# 09 PAR RAID @ sda
# 10 PAR RAID @ sdb
# 11 PAR RAID @ sdc
# 12 PAR RAID @ sdd
#
Pr

@sd[a-d]

#
# 13 RAID 5 md0 @ sda1 sdb1 sdc1 sdd1+
#
R5@sd[abc]1:sdd1+

#
# 14 PHYVOL pv0 @ md0
#
V@md0

#
# 15 VOLGRP vg0 100% @ pv0
#
[email protected]

#
# 16 LOGVOL lv0 300M @ vg0
# 17 LOGVOL lv1   8G @ vg0
# 18 LOGVOL lv2 100% @ vg0
#
L.3,8,@VG00

#
# 19 FILESYS /boot ext2 @ lv_boot
# 20 FILESYS swap  swap @ lv_swap
# 21 FILESYS /      xfs @ lv_root
#
F/boot:2,s,/@lv[0-2]

Completely abbreviated (minified to only 79 characters) version of the above example is the following:

pal Td,g Pr @sd[a-d] R5@sd[abc]1:sdd1+ V@md0 G@pv0 L.3,8,@VG00 F/boot:2,s,/@lv[0-2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment