====== Gestion disques & partitions =====
== Partition non LVM ==
* rafraichissement disque iSCSI étendu
[root@hyper-v2 ~]# rescan-scsi-bus.sh -s
Scanning SCSI subsystem for new devices
Searching for resized LUNs
RESIZED: Host: scsi6 Channel: 00 Id: 00 Lun: 00
Vendor: OSNEXUS Model: QuantaStor Rev: 380
Type: Direct-Access ANSI SCSI revision: 06
0 new or changed device(s) found.
1 remapped or resized device(s) found.
[6:0:0:0]
0 device(s) removed.
* création ou extention de partition (avec outil graphique)
cfdisk /dev/vdb
* resize de partition
[root@hyper-v2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 111,8G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 110,2G 0 part
├─ol-root 252:0 0 70G 0 lvm /
└─ol-home 252:1 0 40,2G 0 lvm /home
sdb 8:16 0 200G 0 disk
└─sdb1 8:17 0 100G 0 part /VM1
[root@hyper-v2 ~]# growpart /dev/sdb 1
CHANGED: partition=1 start=2048 old: size=209711104 end=209713151 new: size=419428319 end=419430366
[root@hyper-v2 ~]# xfs_growfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=6553472 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=26213888, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 26213888 to 52428539
[root@hyper-v2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 111,8G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 110,2G 0 part
├─ol-root 252:0 0 70G 0 lvm /
└─ol-home 252:1 0 40,2G 0 lvm /home
sdb 8:16 0 200G 0 disk
└─sdb1 8:17 0 200G 0 part /VM1
* Formater une partition
[root@oracle1 ~]# mkfs.xfs -f /dev/vdb1
meta-data=/dev/vdb1 isize=512 agcount=4, agsize=655295 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=2621179, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=25600, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Discarding blocks...Done.
* charger modification FSTAB sans rebooter
mount -a
----
----
== Création d'un LVM ==
[root@oracle4 sources]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 10G 0 rom
xvda 202:0 0 20G 0 disk
├─xvda1 202:1 0 1G 0 part /boot
└─xvda2 202:2 0 19G 0 part
├─ol-root 252:0 0 17G 0 lvm /
└─ol-swap 252:1 0 2G 0 lvm [SWAP]
xvdb 202:16 0 15G 0 disk
[root@oracle4 sources]# cfdisk /dev/xvdb
[root@oracle4 sources]# pvcreate /dev/xvdb
Physical volume "/dev/xvdb" successfully created.
[root@oracle4 sources]# vgcreate vg_u01 /dev/xvdb
Volume group "vg_u01" successfully created
[root@oracle4 sources]# vgdisplay
--- Volume group ---
VG Name vg_u01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <15,00 GiB
PE Size 4,00 MiB
Total PE 3839
Alloc PE / Size 0 / 0
Free PE / Size 3839 / <15,00 GiB
VG UUID kZqQI9-s9FN-z2lV-b7N9-kvgV-Arhm-Bi53U9
[root@oracle4 sources]# lvcreate -n lv_u01 -L 14g vg_u01
Logical volume "lv_u01" created.
[root@oracle4 sources]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_u01/lv_u01
LV Name lv_u01
VG Name vg_u01
LV UUID c9kGnB-9LGE-VxrO-UHVE-7zYu-JEMb-HzsmYI
LV Write Access read/write
LV Creation host, time oracle4.labo.local, 2024-09-17 19:43:17 +0200
LV Status available
# open 0
LV Size 14,00 GiB
Current LE 3584
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:2
[root@oracle4 sources]# mkfs -t ext4 /dev/vg_u01/lv_u01
mke2fs 1.45.6 (20-Mar-2020)
En train de créer un système de fichiers avec 3670016 4k blocs et 917504 i-noeuds.
UUID de système de fichiers=899c9a48-e4b5-4145-95b1-42b51948587a
Superblocs de secours stockés sur les blocs :
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocation des tables de groupe : complété
Écriture des tables d'i-noeuds : complété
Création du journal (16384 blocs) : complété
Écriture des superblocs et de l'information de comptabilité du système de
fichiers : complété
[root@oracle4 sources]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 10G 0 rom
xvda 202:0 0 20G 0 disk
├─xvda1 202:1 0 1G 0 part /boot
└─xvda2 202:2 0 19G 0 part
├─ol-root 252:0 0 17G 0 lvm /
└─ol-swap 252:1 0 2G 0 lvm [SWAP]
xvdb 202:16 0 15G 0 disk
└─vg_u01-lv_u01 252:2 0 14G 0 lvm
[root@oracle4 sources]# mkdir /u01
[root@oracle4 sources]# vi /etc/fstab
mount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.
/dev/vg_u01/lv_u01 /u01 ext4 defaults 0 0
\\
== Extension d'un LVM ==
* on rafraîchit le storage via cfdisk (on ne fait rien, ouvrir et quitter pour forcer le rafraichissement du storage)
cfdisk /dev/sdd
* on rafraîchit le lvm
[root@oracle2 ~]# pvscan
[root@oracle2 ~]# lvscan
* on étend le PV
[root@oracle2 ~]# pvresize /dev/sdd
* on étend le LV
[root@oracle2 ~]# lvextend /dev/vg_u07/lv_u07 -l +100%FREE
* on étend le FS (EXT4)
[root@oracle2 ~]# lvextend /dev/vg_u07/lv_u07 -l +100%FREE
* ou on étend le FS (XFS)
[root@oracle2 ~]# xfs_growfs /dev/mapper/vg_u07-lv_u07
\\
== Extension LVM Swap ==
pvresize /dev/xvda3
lvextend /dev/ol/swap -L10g
swapon --show
swapoff -v /dev/ol/swap
mkswap /dev/ol/swap
swapon -va
lsblk