New server created with 20GB Drive.
# fdisk -l Disk /dev/xvda : 21.5 GB, 21474836480 bytes 255 heads, 63 sectors /track , 2610 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: 0x00028fed Device Boot Start End Blocks Id System /dev/xvda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/xvda2 66 2611 20446208 8e Linux LVM Disk /dev/mapper/centos-swap : 1073 MB, 1073741824 bytes 255 heads, 63 sectors /track , 130 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/mapper/centos-root : 19.9 GB, 19860029440 bytes 255 heads, 63 sectors /track , 2414 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 |
# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 18.50g swap centos -wi-ao---- 1.00g |
Check Physical Volumes
# pvs PV VG Fmt Attr PSize PFree /dev/xvda2 centos lvm2 a-- 19.50g 0 |
Now I upgrade the cloud server
to
1024 MB RAM, 1 Core, 40 GB Disk
After upgrade…
# fdisk -l Disk /dev/xvda : 40.8 GB, 40802189312 bytes 255 heads, 63 sectors /track , 4960 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: 0x00028fed Device Boot Start End Blocks Id System /dev/xvda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/xvda2 66 2611 20446208 8e Linux LVM Disk /dev/mapper/centos-swap : 1073 MB, 1073741824 bytes 255 heads, 63 sectors /track , 130 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/mapper/centos-root : 19.9 GB, 19860029440 bytes 255 heads, 63 sectors /track , 2414 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 |
# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 18.50g swap centos -wi-ao---- 1.00g |
# pvs PV VG Fmt Attr PSize PFree /dev/xvda2 centos lvm2 a-- 19.50g 0 |
Create a new partition (n). Make it primary (p). The start and end should be the defaults provided by fdisk.
# fdisk /dev/xvda WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode ( command 'c' ) and change display units to sectors ( command 'u' ). Command (m for help): p Disk /dev/xvda : 40.8 GB, 40802189312 bytes 255 heads, 63 sectors /track , 4960 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: 0x00028fed Device Boot Start End Blocks Id System /dev/xvda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/xvda2 66 2611 20446208 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 (2611-4960, default 2611): Using default value 2611 Last cylinder, +cylinders or +size{K,M,G} (2611-4960, default 4960): Using default value 4960 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 or after you run partprobe(8) or kpartx(8) |
Reboot the VM so the kernel picks up the partition changes.
# shutdown -r now |
Check for the new partition
# fdisk -l Disk /dev/xvda : 40.8 GB, 40802189312 bytes 255 heads, 63 sectors /track , 4960 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: 0x00028fed Device Boot Start End Blocks Id System /dev/xvda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/xvda2 66 2611 20446208 8e Linux LVM /dev/xvda3 2611 4960 18869680 83 Linux Disk /dev/mapper/centos-swap : 1073 MB, 1073741824 bytes 255 heads, 63 sectors /track , 130 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/mapper/centos-root : 19.9 GB, 19860029440 bytes 255 heads, 63 sectors /track , 2414 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 |
Run “pvcreate /dev/xvda3” to make /dev/xvda3 a LVM partition.
# pvcreate /dev/xvda3 Physical volume "/dev/xvda3" successfully created |
Check for the name
# vgs VG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz--n- 19.50g 0 |
Run “vgextend centos /dev/xvda3” to add /dev/xvda3 to the centos volume group.
# vgextend centos /dev/xvda3 Volume group "centos" successfully extended |
Check again…
# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 18.50g swap centos -wi-ao---- 1.00g |
Root “lvresize -r -l +100%FREE centos/root” to resize the / partition.
# lvresize -r -l +100%FREE centos/root Size of logical volume centos /root changed from 18.50 GiB (4735 extents) to 36.49 GiB (9341 extents). Logical volume root successfully resized resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/centos-root is mounted on /; on-line resizing required old desc_blocks = 2, new_desc_blocks = 3 Performing an on-line resize of /dev/mapper/centos-root to 9565184 (4k) blocks. The filesystem on /dev/mapper/centos-root is now 9565184 blocks long. |
Run “df -H”. You should now see 30+ GB size on the / partition.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 36G 928M 34G 3% / tmpfs 496M 0 496M 0% /dev/shm /dev/xvda1 504M 62M 417M 13% /boot |
And fdisk again
# fdisk -l Disk /dev/xvda : 40.8 GB, 40802189312 bytes 255 heads, 63 sectors /track , 4960 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: 0x00028fed Device Boot Start End Blocks Id System /dev/xvda1 * 1 66 524288 83 Linux Partition 1 does not end on cylinder boundary. /dev/xvda2 66 2611 20446208 8e Linux LVM /dev/xvda3 2611 4960 18869680 83 Linux Disk /dev/mapper/centos-swap : 1073 MB, 1073741824 bytes 255 heads, 63 sectors /track , 130 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/mapper/centos-root : 39.2 GB, 39178993664 bytes 255 heads, 63 sectors /track , 4763 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 |