problem with adding space

General support questions
s_bd
Posts: 7
Joined: 2021/08/28 09:36:05
Location: IND

problem with adding space

Post by s_bd » 2021/08/28 09:53:12

Hi, I'm relatively new to CentOS admin. I'm running it on VMWare. I want to extend existing space of 20gb to 50gb. I tried out given procedure to extend space without success. Appreciate any help on this.

Code: Select all

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux
/dev/sda4        41943040   104857599    31457280   8e  Linux LVM

/dev/sda4 is the new LVM created. I need the same to be added to /dev/sda3 to extend its space to 50gb. I'm unable to understand how to add this LVM to /dev/sda3. Could anyone please help.

Code: Select all

[root@localhost ~]# df -kh
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        895M     0  895M   0% /dev
tmpfs           910M     0  910M   0% /dev/shm
tmpfs           910M   11M  900M   2% /run
tmpfs           910M     0  910M   0% /sys/fs/cgroup
/dev/sda3        18G   15G  2.8G  85% /
/dev/sda1       297M  207M   91M  70% /boot
tmpfs           182M   20K  182M   1% /run/user/1000

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: problem with adding space

Post by TrevorH » 2021/08/28 11:56:32

You cannot do that since /dev/sda3 is not currently an LVM partition, it's just a plain filesystem on a plain partition. You cannot add LVM space to a non-LVM target.

However, since /dev/sda3 is right next to /dev/sda4 and there is nothing in between, you could delete /dev/sda4 (assuming that it has no other LVM LVs inside it containing data you care about) and then run something to extend the /dev/sda3 plain partition to occupy the freespace. The 'gparted' utility is in EPEL but I think I would download a standalone boot medium like sysrescuecd and boot that to run it since your / filesystem is on /dev/sda3 and it might be tricky to resize it if it is in use. This does mean that your / filesytem will end up occupying all of the existing space and as much of what is now /dev/sda4 as you give it.

Also, be aware that if you have 4 primary partitions on an MSDOS labelled disk then that is all it can handle, you will not be able to add a /dev/sda5 if all of sda1-4 exist.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: problem with adding space

Post by jlehtone » 2021/08/28 12:19:57

Some additional commands that give info about storage:

Code: Select all

lsblk
pvs
vgs
lvs
blkid
findmnt
The 'lsblk' is already quite revealing.

s_bd
Posts: 7
Joined: 2021/08/28 09:36:05
Location: IND

Re: problem with adding space

Post by s_bd » 2021/08/28 12:39:51

Thank you both: TrevorH and jlehtone. I'll try to work on the suggested things.

s_bd
Posts: 7
Joined: 2021/08/28 09:36:05
Location: IND

Re: problem with adding space

Post by s_bd » 2021/08/28 18:28:44

i'm trying to add space as suggested but seeing very different result.

Code: Select all

     Device Boot      Start         End      Blocks   Id  System
/dev/sda3p3            2048    37132287    18565120   83  Linux

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

[root@localhost ~]# df -kh .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G   16G  2.7G  85% /

version: 3.10.0-1160.11.1.el7.x86_64 #1
so basically it's not adding the space from 41943039. It's taking 2048 which is /dev/sda1. Actually i want to add space to /dev/sda3.

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: problem with adding space

Post by TrevorH » 2021/08/28 18:48:05

What did you do?

I see two things there. First and rather worryingly, you seem to have a partition table inside /dev/sda3 and that is not correct and should not be there. Hopefully it has not overwritten the data you had on there.

Second, you have not extended the filesystem on the partition that you resized. Theoretically gparted should have done that for you.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

s_bd
Posts: 7
Joined: 2021/08/28 09:36:05
Location: IND

Re: problem with adding space

Post by s_bd » 2021/08/29 06:08:29

hi TrevorH, so i'm trying to do this way.

Code: Select all

[sbd@localhost ~]$ df -kh
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        895M     0  895M   0% /dev
tmpfs           910M   15M  896M   2% /dev/shm
tmpfs           910M   11M  900M   2% /run
tmpfs           910M     0  910M   0% /sys/fs/cgroup
/dev/sda3        18G   16G  2.7G  85% /
/dev/sda1       297M  207M   91M  70% /boot
tmpfs           182M   24K  182M   1% /run/user/1000

[root@localhost ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000140f5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

[root@localhost ~]# df -kh /opt
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G   16G  2.7G  85% /
Then i'm trying to add diskspace (using fdisk /dev/sda3) on /dev/sda3 since /opt is mounted on /dev/sda3 and it's consuming space which i need to increase. Is that way correct?

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: problem with adding space

Post by TrevorH » 2021/08/29 11:48:41

We need to know exactly what you did to get to where you are now. You have already successfully extended the partition /dev/sda3 and it is now larger than it was. As I said in my last post, as part of that enlargement you seem to have managed to create a partition table on /dev/sda3 and that is not correct. We need to know how you did that so that we can work out if the existing data that you have on /dev/sda3 is safe or not.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

s_bd
Posts: 7
Joined: 2021/08/28 09:36:05
Location: IND

Re: problem with adding space

Post by s_bd » 2021/08/29 13:17:58

yes. i do see that space has been added to the partition. But it does not reflect when i check the same:

Code: Select all

[root@localhost ~]# df -kh
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        895M     0  895M   0% /dev
tmpfs           910M   15M  896M   2% /dev/shm
tmpfs           910M   11M  900M   2% /run
tmpfs           910M     0  910M   0% /sys/fs/cgroup
/dev/sda3        18G   16G  2.7G  85% /        <----this one where i'm looking for adding space
/dev/sda1       297M  207M   91M  70% /boot
tmpfs           182M   20K  182M   1% /run/user/1000
/dev/sda3 has /opt, /sys and few other things. /dev/sda1 has the /boot mounted on it.
I don't see any data loss apparently. no important data is there on /dev/sda3.

So, can i add this space which is reflecting when i check with: fdisk -l

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: problem with adding space

Post by jlehtone » 2021/08/29 14:07:27

TrevorH wrote:
2021/08/29 11:48:41
We need to know exactly what you did to get to where you are now.
s_bd wrote:
2021/08/29 13:17:58
yes.
Is that the answer to Trevor's question?

You have posted same outputs repeatedly, but you have not shown what operations did you do.
In fact, the only shown change so far was removal of partition /dev/sda4.

Partition is a group of consecutive LBA's, sectors on storage media.
Filesystem is both user data and metadata about the files that is stored in sectors.

If I buy six consecutive blocks along Broadway Street in Manhattan, the buildings in those blocks will not automatically be replaced by one six-block long skyscraper. No, I have to demolish some and expand (build) the remaining to get me a larger manor.

Same here, the filesystem has to be told to take into use all the sectors within the partition. It depends on the type of filesystem, whether and how it can be resized.

Post Reply