mercredi 12 novembre 2014

how to resize root '/' filesystem and swap on a Exalogic vServer.


Prerequisites
- Access to OpsCenter with owner of vServer.
- Access to vServer with root user.
- Access to a computeNode with root user.

Resize FileSystem
On vServer or OpsCenter :
Shutdown the vServer to extend main volume.
- Connect to OpsCenter
- Go to “Vdc Management / mycloud / Accounts / myAccount”
- Select the vServer
- Click “Shutdown the server” or click on the red square.
Alternative :
- Connect to vServer with root user and execute the following command :
# shutdown -h now

On a compute Node :
Go to to OVM Repository and access directly to the vServers vDisks.

On the repository :   
# cd /OVS/Repositories/000.........22/
# ls
Assemblies  ISOs  Templates  VirtualDisks  VirtualMachines

- Identify the vServer :  
# grep 'simple_name' VirtualMachines/*/*.cfg
VirtualMachines/000..........75/vm.cfg:OVM_simple_name = 'myvserver-1'
VirtualMachines/000..........48/vm.cfg:OVM_simple_name = 'myvserver-2'
VirtualMachines/000..........bb/vm.cfg:OVM_simple_name = 'myvserver-3'
VirtualMachines/000..........3f/vm.cfg:OVM_simple_name = 'ExalogicControlOpsCenterPC2'
VirtualMachines/000..........b7/vm.cfg:OVM_simple_name = 'mytemplatevserver'
VirtualMachines/000..........30/vm.cfg:OVM_simple_name = 'ExalogicControl'
VirtualMachines/000..........4b/vm.cfg:OVM_simple_name = 'ldapvserver'
VirtualMachines/000..........90/vm.cfg:OVM_simple_name = 'ExalogicControlOpsCenterPC1'

- Identify the vDisk :  
# grep -i disk VirtualMachines/000..........b7/vm.cfg
disk = ['file:/OVS/Repositories/000.........22/VirtualDisks/000..........b7.img,hda,w']
[root@elp01cn01 000.........22]# cd /OVS/Repositories/000.........22/VirtualDisks/

- Make a vDisk backup :  
# ls -l 000..........b7.img
-rw-r--r--+ 1 root root 6292504576 Jul 15 14:16 000..........b7.img
# cp 000..........b7.img 000..........b7.img.orig

- Create a new disk with the desired size :  
# dd if=/dev/zero of=System12G.img bs=5M count=2400
2400+0 records in
2400+0 records out
12582912000 bytes (13 GB) copied, 21.5651 seconds, 583 MB/s

- Copy vServer vDisk content into file newly created :  
# dd if=000..........b7.img of=System12G.img conv=notrunc,noerror
12290048+0 records in
12290048+0 records out
6292504576 bytes (6.3 GB) copied, 65.0138 seconds, 96.8 MB/s

- Replace vDisk with newly file :  
# mv System12G.img 000..........b7.img
mv: overwrite `000..........b7.img'? y

Restart the vServer and resize VolumeGroups
On OpsCenter Console :
- Connect to OpsCenter
- Go to “Vdc Management / mycloud / Accounts / myAccount”
- Select the vServer
- Click “start the server”.

On vServer
- Connect on vServer with root user and list the current disks shows in vServer :
# fdisk -l

Disk /dev/xvda: 12.5 GB, 12582912000 bytes
255 heads, 63 sectors/track, 1529 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14         765     6040440   8e  Linux LVM

Disk /dev/dm-0: 5637 MB, 5637144576 bytes
255 heads, 63 sectors/track, 685 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn't contain a valid partition table


- Delete current partition and recreate new using the entire disk :
# fdisk /dev/xvda

The number of cylinders for this disk is set to 1529.
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 OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-1529, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-1529, default 1529):
Using default value 1529

- Reboot to use the new partition :
# reboot -n

Broadcast message from root (pts/0) (Tue Jul 15 14:38:48 2014):

The system is going down for reboot NOW!

- Control the physical volume :
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/xvda2
  VG Name               VolGroup00
  PV Size               5.76 GB / not usable 10.87 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              184
  Free PE               0
  Allocated PE          184
  PV UUID               SaMlQo-Ct55-8IhX-ZEaf-rT4X-gISK-XEwdvc

- Resize the physical volume to use entire disk :
# pvresize /dev/xvda2
  Physical volume "/dev/xvda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

- Scan the volume group :
# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  VolGroup00   1   2   0 wz--n- 11.59G 5.84G

- Scan the logical Volumes in VolumeGroup :
# lvscan
  ACTIVE            '/dev/VolGroup00/LogVol00' [5.25 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol01' [512.00 MB] inherit

- Extend the volume used for swap first :
# lvextend -L +1536M /dev/VolGroup00/LogVol01
  Extending logical volume LogVol01 to 2.00 GB
  Logical volume LogVol01 successfully resized

- Extend root filesystem with all the space free in volumeGroup :
# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 9.59 GB
  Logical volume LogVol00 successfully resized

- Disable the swap :
# swapoff /dev/mapper/VolGroup00-LogVol01

- Recreate the swap with the new logical volume :
#  mkswap /dev/mapper/VolGroup00-LogVol01
Setting up swapspace version 1, size = 2147479 kB

- Enable the swap with the new logical volume :
# swapon /dev/mapper/VolGroup00-LogVol01

- Control new filesystem size :
# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                          9516      3449      5576  39% /
/dev/xvda1                  99        23        71  25% /boot
tmpfs                     3998         0      3998   0% /dev/shm

Note : Another approach can be made by adding a disk to system VG instead of resizing. 

Aucun commentaire:

Enregistrer un commentaire