LVM Guide · 4 min read · Oct 08, 2025

Guida per principianti a LVM - Pagina 9

Ora facciamo lo stesso processo di nuovo, questa volta sostituendo /dev/sdc e /dev/sde:

mdadm --manage /dev/md0 --fail /dev/sdc1  
 mdadm --manage /dev/md0 --remove /dev/sdc1  
 mdadm --manage /dev/md1 --fail /dev/sde1  
 mdadm --manage /dev/md1 --remove /dev/sde1
fdisk /dev/sdc  
 fdisk /dev/sde
mdadm --manage /dev/md0 --add /dev/sdc1  
 mdadm --manage /dev/md1 --add /dev/sde1
cat /proc/mdstat

Aspetta fino al termine della sincronizzazione.

Successivamente creiamo gli array RAID /dev/md2 da /dev/sdb2 e /dev/sdc2 così come /dev/md3 da /dev/sdd2 e /dev/sde2.

mdadm --create /dev/md2 --auto=yes -l 1 -n 2 /dev/sdb2 /dev/sdc2
server1:~# mdadm --create /dev/md2 --auto=yes -l 1 -n 2 /dev/sdb2 /dev/sdc2  
 mdadm: array /dev/md2 started.
mdadm --create /dev/md3 --auto=yes -l 1 -n 2 /dev/sdd2 /dev/sde2
server1:~# mdadm --create /dev/md3 --auto=yes -l 1 -n 2 /dev/sdd2 /dev/sde2  
 mdadm: array /dev/md3 started.

I nuovi array RAID devono essere sincronizzati prima di procedere, quindi dovresti controllare

cat /proc/mdstat
server1:~# cat /proc/mdstat  
 Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]  
 md3 : active raid1 sde2[1] sdd2[0]  
       59464512 blocks [2/2] [UU]  
       [=>...................]  resync =  5.1% (3044224/59464512) finish=5.5min speed=169123K/sec  
 
 md2 : active raid1 sdc2[1] sdb2[0]  
       59464512 blocks [2/2] [UU]  
       [=>...................]  resync =  5.5% (3312512/59464512) finish=9.3min speed=100379K/sec  
 
 md0 : active raid1 sdc1[0] sdb1[1]  
       24418688 blocks [2/2] [UU]  
 
 md1 : active raid1 sde1[0] sdd1[1]  
       24418688 blocks [2/2] [UU]  
 
 unused devices: 

Dopo che la sincronizzazione è terminata, prepariamo /dev/md2 e /dev/md3 per LVM:

pvcreate /dev/md2 /dev/md3
server1:~# pvcreate /dev/md2 /dev/md3  
   Physical volume "/dev/md2" successfully created  
   Physical volume "/dev/md3" successfully created

ed aggiungiamo /dev/md2 e /dev/md3 al nostro gruppo di volumi fileserver:

vgextend fileserver /dev/md2 /dev/md3
server1:~# vgextend fileserver /dev/md2 /dev/md3  
   Volume group "fileserver" successfully extended

Ora eseguiamo i nostri *comandi di visualizzazione:

pvdisplay
server1:~# pvdisplay  
   --- Physical volume ---  
   PV Name               /dev/md0  
   VG Name               fileserver  
   PV Size               23.29 GB / not usable 0  
   Allocatable           yes (but full)  
   PE Size (KByte)      4096  
   Total PE             5961  
   Free PE               0  
   Allocated PE         5961  
   PV UUID               7JHUXF-1R2p-OjbJ-X1OT-uaeg-gWRx-H6zx3P  
   
   --- Physical volume ---  
   PV Name               /dev/md1  
   VG Name               fileserver  
   PV Size               23.29 GB / not usable 0  
   Allocatable           yes  
   PE Size (KByte)      4096  
   Total PE             5961  
   Free PE               18  
   Allocated PE         5943  
   PV UUID               pwQ5AJ-RwVK-EebA-0Z13-d27d-2IdP-HqT5RW  
   
   --- Physical volume ---  
   PV Name               /dev/md2  
   VG Name               fileserver  
   PV Size               56.71 GB / not usable 0  
   Allocatable           yes  
   PE Size (KByte)      4096  
   Total PE             14517  
   Free PE               14517  
   Allocated PE         0  
   PV UUID               300kTo-evxm-rfmf-90LA-4YOJ-2LG5-t4JHnf  
   
   --- Physical volume ---  
   PV Name               /dev/md3  
   VG Name               fileserver  
   PV Size               56.71 GB / not usable 0  
   Allocatable           yes  
   PE Size (KByte)      4096  
   Total PE             14517  
   Free PE               14517  
   Allocated PE         0  
   PV UUID               LXFSW6-7LQX-ZGGU-dV95-jQgg-TK44-U5JOjO
vgdisplay
server1:~# vgdisplay  
   --- Volume group ---  
   VG Name               fileserver  
   System ID  
   Format                lvm2  
   Metadata Areas        4  
   Metadata Sequence No  26  
   VG Access             read/write  
   VG Status             resizable  
   MAX LV                0  
   Cur LV                3  
   Open LV               3  
   Max PV                0  
   Cur PV                4  
   Act PV                4  
   VG Size               159.98 GB  
   PE Size               4.00 MB  
   Total PE             40956  
   Alloc PE / Size       11904 / 46.50 GB  
   Free  PE / Size       29052 / 113.48 GB  
   VG UUID               dQDEHT-kNHf-UjRm-rmJ3-OUYx-9G1t-aVskI1
lvdisplay
server1:~# lvdisplay  
   --- Logical volume ---  
   LV Name                /dev/fileserver/share  
   VG Name                fileserver  
   LV UUID                bcn3Oi-vW3p-WoyX-QlF2-xEtz-uz7Z-4DllYN  
   LV Write Access        read/write  
   LV Status             available  
   # open                 1  
   LV Size               40.00 GB  
   Current LE            10240  
   Segments              2  
   Allocation            inherit  
   Read ahead sectors     0  
   Block device           253:0  
   
   --- Logical volume ---  
   LV Name                /dev/fileserver/backup  
   VG Name                fileserver  
   LV UUID                vfKVnU-gFXB-C6hE-1L4g-il6U-78EE-N8Sni8  
   LV Write Access        read/write  
   LV Status             available  
   # open                 1  
   LV Size               5.00 GB  
   Current LE            1280  
   Segments              1  
   Allocation            inherit  
   Read ahead sectors     0  
   Block device           253:1  
   
   --- Logical volume ---  
   LV Name                /dev/fileserver/media  
   VG Name                fileserver  
   LV UUID                H1gagh-wTwH-Og0S-cJNQ-BgX1-zGlM-LwLVzE  
   LV Write Access        read/write  
   LV Status             available  
   # open                 2  
   LV Size               1.50 GB  
   Current LE            384  
   Segments              1  
   Allocation            inherit  
   Read ahead sectors     0  
   Block device           253:2

Se i tuoi output sembrano simili, hai sostituito con successo i tuoi piccoli dischi rigidi con quelli più grandi.

Ora che abbiamo più spazio su disco ( 2 23.29GB + 2 56.71GB = 160GB) potremmo ingrandire i nostri volumi logici. Fino ad ora sai come ingrandire le partizioni ext3 e reiserfs, quindi ingrandiamo ora il nostro volume logico di backup che utilizza xfs:

lvextend -L10G /dev/fileserver/backup
server1:~# lvextend -L10G /dev/fileserver/backup  
   Extending logical volume backup to 10.00 GB  
   Logical volume backup successfully resized

Per ingrandire il filesystem xfs, eseguiamo

xfs_growfs /dev/fileserver/backup
server1:~# xfs_growfs /dev/fileserver/backup  
 meta-data=/dev/fileserver/backup isize=256    agcount=8, agsize=163840 blks  
        =                       sectsz=512   attr=0  
 data     =                       bsize=4096   blocks=1310720, imaxpct=25  
        =                       sunit=0      swidth=0 blks, unwritten=1  
 naming   =version 2              bsize=4096  
 log      =internal               bsize=4096   blocks=2560, version=1  
        =                       sectsz=512   sunit=0 blks  
 realtime =none                   extsz=65536  blocks=0, rtextents=0  
 data blocks changed from 1310720 to 2621440

L’output di

df -h

dovrebbe ora apparire così:

server1:~# df -h  
 Filesystem            Size  Used Avail Use% Mounted on  
 /dev/sda2              19G  666M   17G   4% /  
 tmpfs                  78M     0   78M   0% /lib/init/rw  
 udev                   10M  116K  9.9M   2% /dev  
 tmpfs                  78M     0   78M   0% /dev/shm  
 /dev/sda1             137M   17M  114M  13% /boot  
 /dev/mapper/fileserver-share  
                      40G  177M   38G   1% /var/share  
 /dev/mapper/fileserver-backup  
                      10G  272K   10G   1% /var/backup  
 /dev/mapper/fileserver-media  
                      1.5G   33M  1.5G   3% /var/media

Questo è tutto! Se sei arrivato fin qui, ora dovresti essere abituato a LVM e LVM su RAID.

9 Link

Share: X/Twitter LinkedIn

Ricevi i nuovi post nella tua casella di posta.

Nessuno spam. Disiscriviti in qualsiasi momento.