Agrandir un PV puis un LV sous Red Hat

De Wiki de Romain RUDIGER
Aller à : navigation, rechercher


Introduction

Redimensionner une partition ext3 stockée sur un LV en agrandissant le PV.

agrandir la partition

[root@serv ~]# parted
Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  271MB   271MB   primary  ext3         boot
 2      271MB   2418MB  2147MB  primary  linux-swap
 3      2418MB  19.3GB  16.9GB  primary               lvm
(parted) rm 3
(parted) mkpart
Partition type?  primary/extended? primary
File system type?  [ext2]?
Start? 2418MB
End? 24.7GB
(parted) set 3 lvm
New state?  [on]/off?
Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  271MB   271MB   primary  ext3         boot
 2      271MB   2418MB  2147MB  primary  linux-swap
 3      2418MB  24.7GB  22.3GB  primary               lvm

Rebooter le serveur pour faire prendre en compte la nouvelle table de partitions.

agrandir le PV puis le LV

[root@serv ~]# pvs
  /dev/cdrom: open failed: No medium found
  PV         VG   Fmt  Attr PSize  PFree
  /dev/sda3  vg00 lvm2 a-   15.72G    0
[root@serv ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[root@serv ~]# pvs
  PV         VG   Fmt  Attr PSize  PFree
  /dev/sda3  vg00 lvm2 a-   20.72G 5.00G
[root@serv ~]# lvextend  /dev/vg00/var /dev/sda3
  Extending logical volume var to 10.47 GB
  Logical volume var successfully resized
[root@serv ~]# df -h /var/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg00-var  5.3G  3.1G  2.0G  61% /var
[root@serv ~]# resize2fs /dev/vg00/var
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg00/var is mounted on /var; on-line resizing required
Performing an on-line resize of /dev/vg00/var to 2744320 (4k) blocks.
The filesystem on /dev/vg00/var is now 2744320 blocks long.

[root@serv ~]# df -h /var/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg00-var   11G  3.1G  6.6G  32% /var