Extend Linux VM’s Drive (Proxmox, VMware and Others)

In this example we are going to add a new disk 5GB and extend root (/) partition partition.

Edit VM and add new 5GB Drive. New drive /dev/vdc has been added.

fdisk -l

Disk /dev/vdc: 5368 MB, 5368709120 bytes, 10485760 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes

Use fdisk utility to partition new disk

fdisk /dev/vdc
 n --> New Partition
 p --> Primary 
 Enter --> Default Partition Number
 Enter --> Default First Sector
 Enter --> Default Last Sector
 w --> Save Partition Table

Create a physical volume using newly created partition

[root@10431 ~]# pvcreate /dev/vdc1
 Physical volume "/dev/vdc1" successfully created.

First check the volume groups name

[root@10431 ~]# vgs
 VG #PV #LV #SN Attr VSize VFree
 cl 2 2 0 wz--n- 68.99g 1020.00m

He here cl is Volume Group’s Name

Extend Volume Group

[root@10431 ~]# vgextend cl /dev/vdc1
 Volume group "cl" successfully extended

Get Logical Volume Name

[root@10431 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 66G 11G 56G 17%
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 8.4M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 1014M 231M 784M 23% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0

/dev/mapper/cl-root

Extend the logical volume

[root@10431 ~]# lvextend -l +100%FREE /dev/mapper/cl-root
 Size of logical volume cl/root changed from <66.00 GiB (16895 extents) to <71.99 GiB (18429 extents).
 Logical volume cl/root successfully resized.

Finally Resized
In Centos 7 default filesystem is xfs.
xfs file system supports only extend not reduce. So if you want to resize the filesystem use xfs_growfs rather than resize2fs.

[root@10431 ~]# xfs_growfs /dev/mapper/cl-root
meta-data=/dev/mapper/cl-root isize=512 agcount=16, agsize=1113856 blks
 = sectsz=512 attr=2, projid32bit=1
 = crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=17300480, imaxpct=25
 = sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
 = sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 17300480 to 18871296

Note: For ext4 filesystem use

resize2fs /dev/mapper/cl-root

Check new size

[root@10431 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 72G 11G 62G 15%
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 8.4M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 1014M 231M 784M 23% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0

New size changed from 56G to 62G

 

 

How to find out information about a LXC VPS CPU

Find CPU information

cat /proc/cpuinfo

or

[root@server ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 24
On-line CPU(s) list: 0-23
Thread(s) per core: 2
Core(s) per socket: 6
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 44
Model name: Intel(R) Xeon(R) CPU L5640 @ 2.27GHz
Stepping: 2
CPU MHz: 2266.000
BogoMIPS: 4533.49
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 12288K
NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22
NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23

Find out number of Virtual CPU Cores

cat /proc/cpuinfo | grep processor | wc -l

wget: command not found

-bash: wget: command not found

You get this error when wget isn’t installed

To install wget on CentOS 5, 6 or 7 use this command:

yum install wget -y

To install weget on Debian or Ubuntu

 sudo apt-get install wget