How to resize existing partitions on a vm.
1)add a new virtual drive to vm within vserver.
2)use fdisk to create a new disk device. type Extended, id 8e, use all space, start cyl.-1 and end with
highest cyl.
[root@cms40dev4 ~]# fdisk /dev/sdb
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@cms40dev4 ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 13054.
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): p
Disk /dev/sdb: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 13054 104856223+ 8e Linux LVM
Command (m for help): q
3)confirm os sees new hd
[root@cms40dev4 ~]# ls -l /dev/sd*
brw-r----- 1 root disk 8, 0 Apr 11 01:55 /dev/sda
brw-r----- 1 root disk 8, 1 Apr 11 01:56 /dev/sda1
brw-r----- 1 root disk 8, 2 Apr 11 01:55 /dev/sda2
brw-r----- 1 root disk 8, 16 Apr 12 12:31 /dev/sdb
brw-r----- 1 root disk 8, 17 Apr 12 12:31 /dev/sdb1
4)create one, new big phys. volume
[root@cms40dev4 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Check it-
[root@cms40dev4 ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [49.75 GB / 0 free]
PV /dev/sdb1 lvm2 [100.00 GB]
Total: 2 [149.75 GB] / in use: 1 [49.75 GB] / in no VG: 1 [100.00 GB]
5)extend existing vol grp with new one.
[root@cms40dev4 ~]# vgextend VolGroup00 /dev/sdb1
Volume group "VolGroup00" successfully extended
[root@cms40dev4 ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [49.75 GB / 0 free]
PV /dev/sdb1 VG VolGroup00 lvm2 [99.97 GB / 99.97 GB free]
Total: 2 [149.72 GB] / in use: 2 [149.72 GB] / in no VG: 0 [0 ]
6)extend each partition as needed using free space
[root@cms40dev4 ~]# lvextend -L 45000M /dev/VolGroup00/LogVol02
Rounding up size to full physical extent 43.97 GB
Extending logical volume LogVol02 to 43.97 GB
Logical volume LogVol02 successfully resized
[root@cms40dev4 ~]# lvextend -l +100%FREE /dev/VolGroup00/LogVol03
Extending logical volume LogVol03 to 100.91 GB
Logical volume LogVol03 successfully resized
Check it
[root@cms40dev4 ~]# lvscan
ACTIVE '/dev/VolGroup00/LogVol02' [43.97 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol03' [100.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [2.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit
7)expand both partition's file systems to match the larger partition sizes.
[root@cms40dev4 ~]# /sbin/resize2fs /dev/VolGroup00/LogVol03
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol03 is mounted on /opt; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol03 to 26451968 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol03 is now 26451968 blocks long.
[root@cms40dev4 ~]# /sbin/resize2fs /dev/VolGroup00/LogVol02
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol02 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol02 to 11526144 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol02 is now 11526144 blocks long.
[root@cms40dev4 ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [49.75 GB / 0 free]
PV /dev/sdb1 VG VolGroup00 lvm2 [99.97 GB / 0 free]
Total: 2 [149.72 GB] / in use: 2 [149.72 GB] / in no VG: 0 [0 ]
[root@cms40dev4 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol02
43G 3.7G 37G 10% /
/dev/mapper/VolGroup00-LogVol03
98G 35G 59G 38% /opt
/dev/mapper/VolGroup00-LogVol00
2.9G 70M 2.7G 3% /tmp
/dev/sda1 244M 20M 211M 9% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
No comments:
Post a Comment