Pour patitionner un volume, on peut utiliser parted ou fdisk. À moins d’être expert·e parted il vaut mieux utiliser fdisk car les modifications restent en RAM avant la modification finale, alors que pour parted tout se valide au fur et à mesure et peut être compliqué en cas d’erreur.
Partitionner un volume
On veut partitionner un volume vdb.
Affichage des informations sur les volumes
Listing des volumes disponibles :
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 200M 0 part /boot/efi ├─vda3 252:3 0 500M 0 part /boot └─vda4 252:4 0 9.3G 0 part / vdb 252:16 0 5G 0 disk vdc 252:32 0 5G 0 disk vdd 252:48 0 5G 0 disk
Les disques sans partition sont :
vdb 252:16 0 5G 0 disk vdc 252:32 0 5G 0 disk vdd 252:48 0 5G 0 disk
Partitionnement avec fsdik
On partionne avec fdisk en pointant le volume à partitionner :
# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.37.4). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x5d70e9a4.
Touche m pour l’aide :
Command (m for help): m
Help:
DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag
Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition
Misc m print this menu u change display/entry units x extra functionality (experts only)
Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file
Save & Exit w write table to disk and exit q quit without saving changes
Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table
Créer une partition GPT vide :
Command (m for help): g Created a new GPT disklabel (GUID: 518EB602-8B77-8242-B465-ED249D302C4B).
Ajouter une partition :
First sector: 2048 : Pour garder 1Mo de debut de disque
Last sector: +1G : Important le +1G, sinon il va croire que c’est un SECTEUR
Command (m for help): n Partition number (1-128, default 1): 1 First sector (2048-10485726, default 2048): 2048 Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485726, default 10485726): +1G
Created a new partition 1 of type 'Linux filesystem' and of size 1 GiB.
Afficher la table des partitions :
Command (m for help): p Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 518EB602-8B77-8242-B465-ED249D302C4B
Device Start End Sectors Size Type /dev/vdb1 2048 2099199 2097152 1G Linux filesystem
Welcome to fdisk (util-linux 2.37.4). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x5d70e9a4.
Command (m for help): m
Help:
DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag
Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition
Misc m print this menu u change display/entry units x extra functionality (experts only)
Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file
Save & Exit w write table to disk and exit q quit without saving changes
Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table
Command (m for help): g Created a new GPT disklabel (GUID: 518EB602-8B77-8242-B465-ED249D302C4B).
Command (m for help): n Partition number (1-128, default 1): 1 First sector (2048-10485726, default 2048): 2048 // Pour garder 1Mo de debut de disque Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485726, default 10485726): +1G // Important le +1G, sinon il va croire que c'est un SECTEUR
Created a new partition 1 of type 'Linux filesystem' and of size 1 GiB.
Command (m for help): p Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 518EB602-8B77-8242-B465-ED249D302C4B
Device Start End Sectors Size Type /dev/vdb1 2048 2099199 2097152 1G Linux filesystem
Command (m for help): w // W = pour ECRIRE la config
Vérification :
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 200M 0 part /boot/efi ├─vda3 252:3 0 500M 0 part /boot └─vda4 252:4 0 9.3G 0 part / vdb 252:16 0 5G 0 disk └─vdb2 252:18 0 1G 0 part vdc 252:32 0 5G 0 disk vdd 252:48 0 5G 0 disk
# lsblk // Affiche les informations des volumes # lsblk -fp // Affiche les informations détaillées des volumes # lsblk -fs // Idem mais affichage différent
# fdisk // Partitionner un volume, lire les instructions de l'aide