Outils pour utilisateurs

Outils du site


adminsys:partition

Lister les disques disponibles

root@1664:~# fdisk -l
Disk /dev/sda: 10 GiB, 17179869184 bytes, 33554432 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: ext2
Disk identifier: 0x417f3a84

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       2048   999423   997376  487M 83 Linux
/dev/sda2       1001470 33552383 391920914  20G   5 Extended
/dev/sda5       1001472 45682383 981550912  40G  8e Linux LVM


Disk /dev/sdc: 40 GiB, 214179869184 bytes, 39854554432 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

Créer la partition et mettre la partition en type LVM: 8e

fdisk /path/volume
fdisk /dev/sdc
n : new / p : primary / 1: partition / t : 8e / w : write / q : sortir

Création de la partition en "Physical Volumes" (PV)

La partition doit maintenant être transformée, ou enregistrée comme pouvant faire parti d’un groupe de volumes.

PVCREATE /physique

pvcreate /path/volume
pvcreate /dev/sdc1

 Physical volume "/path/volume" successfully created

Afficher les informations sur les volumes physiques en LVM:

pvdisplay

"/path/volume" is a new physical volume of "XXX.XX GiB"
  --- NEW Physical volume ---
  PV Name               /path/volume
  VG Name
  PV Size               XXX.XX GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               BMFw-HNfA-Kdldji-jCH5JO-KILV-tYQq-aOFX

Création des volumes groupes (VG) à partir des PV

VGCREATE NOMVOLUMEGROUPE /physique

vgcreate Nom-Volume-Groupe /path/volume
vgcreate VolGRDATA00 /dev/sdc1


**Afficher les informations sur les groupes de volumes physiques :**
<code>
vgdisplay

Création des volumes logiques (LV) à partir des VG

LVCREATE NOMVOLUMELOGIQUE VOLUMEGROUPE

lvcreate -n Nom-Du-Volume-Logique -L 39g Nom-Volume-Groupe
lvcreate -n data -L 39g VolGRDATA00

Afficher les informations sur les volumes logiques :

lvdisplay

Agrandir le volume logique:

lvextend -l100%VG Nom-Volume-Groupe/Nom-Du-Volume-Logique
lvextend -l100%VG VolGRDATA00/data

Formatage du volume logique

mkfs.ext4 /dev/mapper/Nom-Du-Volume-Groupe-Nom-Du-Volume-Logique
mkfs.ext4 /dev/mapper/VolGRDATA00-data

Ajouter du volume dans /etc/fstab

echo "UUID= /data1              ext4    defaults        0 0   ">> /etc/fstab
tune2fs -l /dev/mapper/VolGRDATA00-data | grep UUID>> /etc/fstab

Faire les modifications dans /etc/fstab

vi /etc/fstab

Vérifier bien la nouvelle ligne

cat /etc/fstab | grep UUID
UUID=XXXX-XXXX-XXXX-XXXX-XXXX /data1              ext4    defaults        0 0

Monter le disque

mkdir -p /data1
mount -a

Étendre votre disque

Volumétrie initiale

toot@extra:~# df
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/EXTRA--VG-DATA         459G  374G   85G  81% /nextcloud

[sam. avril 22 18:50:51] root@extra:~# fdisk -l
Disk /dev/xvdb: 500 GiB, 536870912000 bytes, 1048576000 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: dos
Disk identifier: 0x047bacf3

Device     Boot Start        End    Sectors   Size Id Type
/dev/xvdb1       2048 1035156250 1035154203 493,6G 8e Linux LVM


Disk /dev/mapper/EXTRA--VG-DATA: 493,6 GiB, 529996447744 bytes, 1035149312 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


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 18 GiB, 19327352832 bytes, 37748736 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

Volumétrie changée

[sam. avril 22 18:56:31] root@extra:~# fdisk -l

Disk /dev/xvdb: 600 GiB, 644245094400 bytes, 1258291200 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: dos
Disk identifier: 0x047bacf3

Device     Boot Start        End    Sectors   Size Id Type
/dev/xvdb1       2048 1035156250 1035154203 493,6G 8e Linux LVM


Disk /dev/mapper/EXTRA--VG-DATA: 493,6 GiB, 529996447744 bytes, 1035149312 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


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 18 GiB, 19327352832 bytes, 37748736 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

Extension de la partition

[sam. avril 22 19:00:57] root@extra:~# parted /dev/xvdb
GNU Parted 3.4
Using /dev/xvdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  530GB  530GB  primary               lvm

(parted) resizepart 1
End?  [530GB]? 643GB
(parted) quit                                                             
Information: You may need to update /etc/fstab.

Extension du volume physique: PV “Physical Volume”

[sam. avril 22 19:02:00] root@extra:~# pvresize /dev/xvdb1                
  Physical volume "/dev/xvdb1" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
[sam. avril 22 19:04:24] root@extra:~# pvs
  PV         VG        Fmt  Attr PSize    PFree   
  /dev/xvda3 ubuntu-vg lvm2 a--   <19,00g 1020,00m
  /dev/xvdb1 EXTRA-VG  lvm2 a--  <598,84g <105,24g

Extension du volume logique: LV “Logical Volume”

root@extra:~# lvs
  LV        VG        Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  DATA      EXTRA-VG  -wi-ao---- <493,60g                                                    
root@extra:~# lvextend -l +100%FREE /dev/mapper/EXTRA--VG-DATA
  Size of logical volume EXTRA-VG/DATA changed from <493,60 GiB (126361 extents) to <598,84 GiB (153302 extents).
  Logical volume EXTRA-VG/DATA successfully resized.
root@extra:~# lvs
  LV        VG        Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  DATA      EXTRA-VG  -wi-ao---- <598,84g                                                    
root@extra:~# lvscan 
  ACTIVE            '/dev/EXTRA-VG/DATA' [<598,84 GiB] inherit

Extension du filesystem de la partition: LV “Logical Volume”

[sam. avril 22 19:10:05] root@extra:~# resize2fs /dev/EXTRA-VG/DATA
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/EXTRA-VG/DATA is mounted on /nextcloud; on-line resizing required
old_desc_blocks = 62, new_desc_blocks = 75
The filesystem on /dev/EXTRA-VG/DATA is now 156981248 (4k) blocks long.
toot@extra:~# df
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/EXTRA--VG-DATA         589G  374G  187G  67% /nextcloud



http://www.davidrusseltrask.com/blog/2020/4/14/extending-a-linux-lvm-partition-after-expanding-a-virtual-hard-drive-using-parted

adminsys/partition.txt · Dernière modification : 2023/04/22 17:21 de tonio