Trying to increase the size of the logical drive! `please help

Issues related to applications and software problems
Post Reply
kamistry
Posts: 2
Joined: 2018/07/18 22:21:31

Trying to increase the size of the logical drive! `please help

Post by kamistry » 2018/07/18 22:30:25

First of all Sorry, I'm new to Centos 7. My hosting company has pretty much said I need to figure out how to increase the size of the logical drive through Centos 7. I've got to the stage of logging in, and lost executing the command to increase the drive, but hitting this last hurdle.

Can anyone help? Original drive size 20G have increased within my Cloud Server to 60G but have been told for it to take effect, I must increase the drive manually in Centos 7.

Using terminaL on MAC. Keep getting an error..

Insufficient free space: 2560 (if I increase by 10G) or 6400 (if I increase by 25G) extents needed, but only 0 available


[root@server45 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 18G 18G 18M 100% /
devtmpfs 2.9G 0 2.9G 0% /dev
tmpfs 3.0G 0 3.0G 0% /dev/shm
tmpfs 3.0G 12M 2.9G 1% /run
tmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup
/dev/sda1 497M 215M 283M 44% /boot
tmpfs 597M 0 597M 0% /run/user/0
[root@server45 ~]# fdisk -i
fdisk: invalid option -- 'i'
Usage:
fdisk [options] <disk> change partition table
fdisk [options] -l <disk> list partition table(s)
fdisk -s <partition> give partition size(s) in blocks

Options:
-b <size> sector size (512, 1024, 2048 or 4096)
-c[=<mode>] compatible mode: 'dos' or 'nondos' (default)
-h print this help text
-u[=<unit>] display units: 'cylinders' or 'sectors' (default)
-v print program version
-C <number> specify the number of cylinders
-H <number> specify the number of heads
-S <number> specify the number of sectors per track

[root@server45 ~]# fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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
Disk label type: dos
Disk identifier: 0x000ab0c3

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 41943039 20458496 8e Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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


Disk /dev/mapper/centos-root: 18.8 GB, 18798870528 bytes, 36716544 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

[root@server45 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.51g 0
[root@server45 ~]# lvextend -L +25G /dev/mapper/centos-root
Insufficient free space: 6400 extents needed, but only 0 available
[root@server45 ~]# lvextend -L +25G /dev/mapper/centos-root
Insufficient free space: 6400 extents needed, but only 0 available
[root@server45 ~]# lvextend -L +10G /dev/mapper/centos-root
Insufficient free space: 2560 extents needed, but only 0 available
[root@server45 ~]#

User avatar
TrevorH
Forum Moderator
Posts: 23644
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Trying to increase the size of the logical drive! `please help

Post by TrevorH » 2018/07/18 23:09:14

You need to either:
delete the existing /dev/sda2 and recreate it starting on the exact same sector number as it does now and ends on the last sector of your newly enlarged disk, save it, reboot, run pvresize /dev/sda2
OR
add a new partition, say /dev/sda3, occupying the empty space between the end of /dev/sda2 and the end of your disk. Tag that as type 0x8e (LVM) and save the changes, reboot then run pvcreate on the new partition then vgextend to add that new PV to your existing VG.

First option is probably slightly more dangerous than the second but as long as you triple check that the newly recreated partition starts on the exact sector number of the old one, you should be ok.

In both cases, you will now have freespace in your VG and you can run the lvextend you wanted to run before. This time, add -r to the command and it will resize the filesystem on top of the LV for you.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

kamistry
Posts: 2
Joined: 2018/07/18 22:21:31

Re: Trying to increase the size of the logical drive! `please help

Post by kamistry » 2018/07/18 23:14:26

Thanks Trevor, thats just nearly made my brain blow up. But i'll give it try in the morning. I do have the option to pay the hosting company..

Post Reply