Esse artigo irá apresentar o procedimento de como expandir o file system “/”, usando o Oracle Enterprise Linux, versão 4 numa máquina virtual VMWare.
Será apresentada a expansão da partição “/” de 17 GB para 27 GB – serão adicionados 10 GB para a file system “/”.
O disco na máquina virtual possui 36 GB, deverão ser disponibilizados previamente.
*** FAZER UM BACKUP FULL DO SEU SISTEMA ANTES DE EXECUTAR ESSE PROCEDIMENTO ***
1) Coletar informações sobre o ambiente:
“df –h” – Para apresentar as partições de discos definidas.
[root@oraclelinux]# df –h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 17G 2.5G 13G 17% /
/dev/mapper/VolGroup00-LogVol03 713M 162M 515M 24% /tmp
/dev/mapper/VolGroup00-LogVol02 2.0G 72M 1.8G 4% /var/log
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 3.8G 0 3.8G 0% /dev/shm
“pvdisplay” - Para apresentar os atributos físicos do volume LVM.
Nota: PVSIZE e Free PE são as extensões físicas dos volumes.
[root@oraclelinux]# pvdisplay
/dev/hda: open failed: No medium found
*** Esta mensagem de erro refere-se à montagem do CDROM ***
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 35.90 GB / not usable 22.10 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 1148
Free PE 0
Allocated PE 1148
PV UUID sS7pDq-F8b0-oaU3-noLN-7dIv-lWSz-njgEFE
“vgdisplay” – Apresenta os atributos dos grupos de volumes dos LVMs.
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 35.88 GB
PE Size 32.00 MB
Total PE 1148
Alloc PE / Size 1148 / 35.88 GB
Free PE / Size 0 / 0
VG UUID sajlPQ-4izJ-PDh4-OqSg-mdh6-Iz4c-wZSUrQ
“lvdisplay” – Apresenta os atributos dos grupos dos volumes LVM. Basta olhar para o volume que deverá ser expandido.
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID VOK07i-dqHt-7qK4-42zB-RT85-P89B-CXEMaI
LV Write Access read/write
LV Status available
# ope 1
LV Size 16.59 GB - Esta é a partição a ser expandida.
Current LE 531
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
2) Baixar o servidor virtual e disponibilizar o espaço em disco para aumento.
É recomendável remover quaisquer snapshots antes de fazer este procedimento. Você deverá expandir os discos do servidor virtual usando uma interface GUI (opção – “Edit Settings”).
3) Usar o utilitário "fdisk"para criar uma nova partição sda. Você estará adicionando esta partição para um volume existente, criando espaço adicional.
[root@oraclelinux]# fdisk /dev/sda
The number of cylinders for this disk is set to 6004.
There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause
problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSʼs (e.g.,DOS FDISK,OS/2
FDISK)
Command (m for help): p
Disk /dev/sda: 49.3 GB, 49392123904 bytes - AQUI você verá o espaço em disco “físico”
disponível.
255 heads, 63 sectors/track, 6004 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 4699 37640295 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4) p
Partition number (1-4): 3
First cylinder (4700-6004, default 4700): - Usar o valor default para todas as partições.
Using default value 4700
Last cylinder or +size or +sizeM or +sizeK (4700-6004, default 6004):
Using default value 6004
Command (m for help): p
Disk /dev/sda: 49.3 GB, 49392123904 bytes
255 heads, 63 sectors/track, 6004 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 4699 37640295 8e Linux LVM
/dev/sda3 4700 6004 10482412+ 83 Linux
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sda: 49.3 GB, 49392123904 bytes
255 heads, 63 sectors/track, 6004 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 4699 37640295 8e Linux LVM
/dev/sda3 4700 6004 10482412+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
4) Verificar a nova partição criada.
[root@oraclelinux]# fdisk –l
Disk /dev/sda: 49.3 GB, 49392123904 bytes
255 heads, 63 sectors/track, 6004 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 4699 37640295 8e Linux LVM
/dev/sda3 4700 6004 10482412+ 8e Linux LVM
5) Adicionar o novo dispositivo de disco (/dev/sda3) para a configuração do LVM.
Nota: É necessário reiniciar o sistema operacional.
[root@oraclelinux]# pvcreate /dev/sda3
Device /dev/sda3 not found (or ignored by filtering). - Necessário REBOOT.
[root@oraclelinux]# reboot
Após o “reboot” executar.
[root@oraclelinux]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@oraclelinux]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 35.90 GB / not usable 22.10 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 1148
Free PE 0
Allocated PE 1148
PV UUID sS7pDq-F8b0-oaU3-noLN-7dIv-lWSz-njgEFE
"/dev/sda3" is a new physical volume of "10.00 GB" - NOVO Volume Físico.
PV Name /dev/sda3
VG Name
PV Size 10.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID RJ7vN1-d59J-d2a0-0Zb0-H6fB-Rzd1-sAe2vZ
6) Expandir o Volume Group existente.
[root@oraclelinux]# vgdisplay - Verifica o tamanho do VG e do espaço
disponível (Free PE / Size) antes de expandir.
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 35.88 GB
PE Size 32.00 MB
Total PE 1148
Alloc PE / Size 1148 / 35.88 GB
Free PE / Size 0 / 0
VG UUID sajlPQ-4izJ-PDh4-OqSg-mdh6-Iz4c-wZSUrQ
[root@oraclelinux]# vgextend VolGroup00 /dev/sda3
Volume group "VolGroup00" successfully extended
[root@oraclelinux]# vgdisplay - Verifica o espaço livre após expansão
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 2
Act PV 2
VG Size 45.84 GB
PE Size 32.00 MB
Total PE 1467
Alloc PE / Size 1148 / 35.88 GB
Free PE / Size 319 / 9.97 GB
VG UUID sajlPQ-4izJ-PDh4-OqSg-mdh6-Iz4c-wZSUrQ
7) Extensão lógica do volume da file system “/”.
[root@oraclelinux]# lvdisplay - Verifica o volume “LogVol00” que será expandido.
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID VOK07i-dqHt-7qK4-42zB-RT85-P89B-CXEMaI
LV Write Access read/write
LV Status available
# open 1
LV Size 16.59 GB
Current LE 531
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
Para estender o volume da file system usar o comando “lvextend”.
[root@oraclelinux]# lvextend -l +319 /dev/VolGroup00/LogVol00 /dev/sda3
Extending logical volume LogVol00 to 26.56 GB
Logical volume LogVol00 successfully resized
[root@oraclelinux]# lvdisplay - Verifica o volume “LogVol00” após a expansão.
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID VOK07i-dqHt-7qK4-42zB-RT85-P89B-CXEMaI
LV Write Access read/write
LV Status available
# open 1
LV Size 26.56 GB - Quantidade de espaço disponível (novo espaço).
Current LE 850
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
8) Aumentar a file system “/”.
[root@oraclelinux]# df –h - Verificar a file system antes de realizar a expansão.
Ver o tamanho do file system “/”.
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 17G 2.5G 13G 17% /
/dev/mapper/VolGroup00-LogVol03 713M 162M 515M 24% /tmp
/dev/mapper/VolGroup00-LogVol02 2.0G 72M 1.8G 4% /var/log
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 3.8G 0 3.8G 0% /dev/shm
[root@oraclelinux]# resize2fs /dev/VolGroup00/LogVol00 – Expandir o file system “/”.
resize2fs 1.39 (29-May-2011)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 6963200 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 6963200 blocks long.
[root@oraclelinux]# df –h - Verificar a file system após a expansão.
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 26G 2.5G 22G 11% /
/dev/mapper/VolGroup00-LogVol03 713M 162M 515M 24% /tmp
/dev/mapper/VolGroup00-LogVol02 2.0G 72M 1.8G 4% /var/log
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 3.8G 0 3.8G 0% /dev/shm
A file system “/” passou de 17GB para 26 GBs.
Em casos de problemas como na mensagem abaixo, onde é apresentada a mensagem que a file system “/” está montada, deve-se utilizaar o comando “ext2online”.
[root@oraclelinux ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.35 (28-Feb-2004)
/dev/VolGroup00/LogVol00 is mounted; can't resize a mounted filesystem!
Exemplo do comando “ext2online”.
ext2online /dev/VolGroup00/LogVol00
[root@oraclelinux]# df –h - Verificar a file system após a expansão.
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 26G 2.5G 22G 11% /
/dev/mapper/VolGroup00-LogVol03 713M 162M 515M 24% /tmp
/dev/mapper/VolGroup00-LogVol02 2.0G 72M 1.8G 4% /var/log
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 3.8G 0 3.8G 0% /dev/shm
Rubens Oliveira
DBA Oracle Consultor
olivert.dba@consultant.com