Rate This Document
Findability
Accuracy
Completeness
Readability

How Do I Quickly Create Multiple WAL and DB Partitions?

The following uses /dev/nvme0n1 as an example. If there are multiple NVMe or SATA/SAS SSDs, change /dev/nvme0n1 to the actual drive letters.

Plan the WAL and DB partitions according to the NVMe drive space. In this example, the NVMe SSD is divided into twelve 60 GB partitions as WAL partitions and twelve 180 GB partitions as DB partitions.

  1. Create a partition.sh script.
    1
    vi partition.sh
    
  2. Add the following content:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    #!/bin/bash
    device=/dev/nvme0n1
    parted $device mklabel gpt -s
    
    for j in `seq 1 12`
    do
    ((b = $(( $j * 8 ))))
    ((a = $(( $b - 8 ))))
    ((c = $(( $b - 6 ))))
    str="%"
    echo $a
    echo $b
    echo $c
    parted $device mkpart primary ${a}${str} ${c}${str}
    parted $device mkpart primary ${c}${str} ${b}${str}
    done
    
  3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  4. Run the script to create partitions.
    1
    bash partition.sh