Verificando o HD
A primeira coisa a se fazer quando se vai fazer esse tipo de ação é verificar como foi reconhecido seu novo HD, para isso execute o comando fdisk -l
Código: Selecionar todos
root@nimbus:~# fdisk -l
Disk /dev/sda: 1073.7 GB, 1073741824000 bytes
255 heads, 63 sectors/track, 130541 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00025bad
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 37888 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 5 130542 1048535041 5 Extended
/dev/sda5 5 254 1998848 83 Linux
/dev/sda6 254 130511 1046285312 83 Linux
/dev/sda7 130511 130542 248832 82 Linux swap / Solaris
Disk /dev/sdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Após executa-lo você pode perceber que o /dev/sdb foi o HD adicionado. Então vamos começar a trabalhar em cima dele.
Formatando o novo HD
Para formatar o HD usaremos o comando fdisk passando como parâmetro o HD:
Código: Selecionar todos
root@nimbus:~# fdisk /dev/sdb
Código: Selecionar todos
Command (m for help): n
Código: Selecionar todos
Command action
e extended
p primary partition (1-4)
Código: Selecionar todos
Partition number (1-4): 1
Código: Selecionar todos
First cylinder (1-65270, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270):
Using default value 65270
Código: Selecionar todos
Command (m for help): t
Selected partition 1
Código: Selecionar todos
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Código: Selecionar todos
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Adicionando o novo disco ao volume vg_bacula
Ao concluir a formatação do novo HD, temos que adicionar o novo disco ao volume vg_bacula. Porem antes de utlizarmos o disco como um volume físico (novo HD), temos que inicializá-lo.
Código: Selecionar todos
root@nimbus:~# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Código: Selecionar todos
root@nimbus:~# vgextend vg_bacula /dev/sdb1
Volume group "vg_bacula" successfully extended
Código: Selecionar todos
root@nimbus:~# vgdisplay
--- Volume group ---
VG Name vg_bacula
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.46 TiB
PE Size 4.00 MiB
Total PE 383438
Alloc PE / Size 255440 / 997.81 GiB
[b] Free PE / Size 127998 / 499.99 GiB[/b]
VG UUID y2hJ9m-ebOt-2ZJ7-xvCH-bvgX-T41I-pCo3e3
Código: Selecionar todos
root@nimbus:~# lvextend -L+499.99G /dev/vg_bacula/lv_bacula
Rodando novamente o vgdisplay não verá mais nenhum espaço livre:
Código: Selecionar todos
root@nimbus:~# vgdisplay
--- Volume group ---
VG Name vg_bacula
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.46 TiB
PE Size 4.00 MiB
Total PE 383438
Alloc PE / Size 383438 / 1.46 TiB
Free PE / Size 0 / 0
VG UUID y2hJ9m-ebOt-2ZJ7-xvCH-bvgX-T41I-pCo3e3
Redimencionando o disco
Após fazer a expanção do volume LVM só será necessário executar o comando de expansão do volume. Esse comando pode demorar um pouco, pois o mesmo tem que formatar o disco para o formato ext3 e verificar se tem alguma falha, porem em poucos minutos o seu servidor estará com o /bacula com tamanho maior e o melhor, sem ser necessário nem mesmo fazer o reboot do servidor. =D
Código: Selecionar todos
root@nimbus:~# resize2fs /dev/vg_bacula/lv_bacula
resize2fs 1.41.11 (14-Mar-2010)
Filesystem at /dev/vg_bacula/lv_bacula is mounted on /bacula; on-line resizing required
old desc_blocks = 63, new_desc_blocks = 94
Performing an on-line resize of /dev/vg_bacula/lv_bacula to 392640512 (4k) blocks.
resize2fs: Inappropriate ioctl for device While trying to add group #8547
Código: Selecionar todos
root@nimbus:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 1.9G 548M 1.3G 31% /
none 245M 232K 244M 1% /dev
none 249M 0 249M 0% /dev/shm
none 249M 64K 249M 1% /var/run
none 249M 0 249M 0% /var/lock
none 249M 0 249M 0% /lib/init/rw
/dev/sda1 36M 21M 14M 61% /boot
/dev/mapper/vg_bacula-lv_bacula
1463G 202M 1463G 1% /bacula
Até o próximo tutorial.