Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

parted

Create, delete, resize and list partitions — in a menu or with one command line (good for scripts).

Niveau
RHCSA-examen
Groep
Schijven en bestandssystemen
Root nodig
Ja
Pakket
parted

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

parted DEVICE opens a prompt; parted DEVICE COMMAND runs one command. Unlike fdisk, parted writes every change at once. Positions are start and end (like 1MiB 1GiB); use MiB/GiB for exact powers of 1024 and good alignment.

-s (script mode) never asks questions — so be careful.

Zo schrijf je het

parted [OPTION]... [DEVICE [COMMAND [ARGUMENT]...]...]

Belangrijkste delen

print [free|all]
Show the table (and free space or all devices).
mklabel gpt|msdos
New empty partition table (deletes all partitions).
mkpart [NAME|TYPE] [FSTYPE] START END
New partition (GPT: a name; MBR: primary/extended/logical).
rm N
Remove partition N.
resizepart N END
Change the end of a partition.
name N NAME
Name a GPT partition.
set N FLAG on|off
Set a flag: boot, esp, lvm, raid, swap, bios_grub, msftdata …
toggle N FLAG
Toggle a flag.
type N TYPE-UUID
Set the GPT type UUID (newer parted).
unit UNIT
Units: s, B, KiB, MiB, GiB, %, compact …
align-check minimal|optimal N
Check alignment.
rescue START END
Find a lost partition.
disk_set / disk_toggle FLAG
Flags of the whole disk.
select DEVICE
Choose another disk.
quit
Leave.

Opties 8

Meest gebruikt

-s, --script
Never ask; for scripts.
-l, --list
List the tables of all disks.
-a, --align none|cylinder|minimal|optimal
Alignment of new partitions (default optimal).
-m, --machine
Machine-readable output.
-j, --json
JSON output.
-f, --fix
Answer "fix" to questions in script mode.
-h, --help
Show help.
-v, --version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Show a disk

    parted /dev/vdb print

    Table type, partitions, sizes and flags.

  2. 2New GPT table

    parted -s /dev/vdb mklabel gpt

    Deletes all partitions on the disk at once.

  3. 3Create partitions in one go

    parted -s /dev/vdb mkpart data xfs 1MiB 2GiB
    parted -s /dev/vdb mkpart swap linux-swap 2GiB 3GiB

    GPT: the first word is the partition name.

  4. 4A partition for LVM

    parted -s /dev/vdb mkpart pv1 3GiB 100%
    parted -s /dev/vdb set 3 lvm on

    100% = to the end of the disk.

  5. 5Show free space in MiB

    parted /dev/vdb unit MiB print free

    Where can a new partition go?

  6. 6MBR with logical partitions

    parted -s /dev/vdc mklabel msdos mkpart primary 1MiB 1GiB mkpart extended 1GiB 100% mkpart logical 1GiB 2GiB

    More commands in one line.

  7. 7Grow a partition to the end of the disk

    parted /dev/vdb resizepart 3 100%

    After a VM disk was made bigger; then grow the PV or file system.

  8. 8EFI system partition

    parted -s /dev/vdd mkpart ESP fat32 1MiB 601MiB set 1 esp on

    For a UEFI boot disk.

  9. 9List all disks

    parted -l

    Every disk with its table.

  10. 10JSON for automation

    parted -j /dev/vdb print | jq '.disk.partitions[].size'

    Newer parted versions.

Let op

  • parted writes at once: there is no "quit without saving".
  • mkpart does not create a file system; use mkfs afterwards (the FSTYPE word only sets the type).

Exitcodes

0 :: Done. 1 :: Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man 8 parted