How to add Unallocated Space to Swap and Root?

General support questions
names_are_useless
Posts: 7
Joined: 2017/10/17 20:58:20

How to add Unallocated Space to Swap and Root?

Postby names_are_useless » 2017/10/17 21:43:09

Hello everyone, I wanted to ask this question in #centos, but I think I somehow got IP banned during the Freenode Nickname Setup process and so can't access that IRC channel.

Anyways, I'm here because I have a PC dual booting Windows 10 and CentOS 7. Unfortunately CentOS 7 does not run very well on this machine, which I'm thinking is related to the fact that I only have about 1 GB of space left for root and only assigned 1 GB of swap space. So I would like to extend Swap from 1 to 2 GB and add the rest of the Unallocated Space I've unassigned from Windows onto Root. However, I'm very new to Partitioning and not sure how to do this.

Here is details about the Unallocated Space that comes up in Disk (I would post a screenshot, but I've been unsuccessful in my ability to install a Paint-like program like XPaint or GIMP; <code>yum install xpaint</code> comes back with <code>No package xpaint available.</code> even as I'm running under root):
Size: 11 GB (10,737,418,240 bytes)
Devicie: /dev/sda
Contents: Unallocated Space


I've tried looking through several guides, and this is the easiest to follow: https://www.vembu.com/blog/increase-swa ... -centos-7/
So I've performed the following ...
swapon -s

Code: Select all

Filename            Type      Size   Used   Priority
/dev/dm-1                                 partition   1126396   0   -1

free -m

Code: Select all

              total        used        free      shared  buff/cache   available
Mem:          15929        1172       13696         199        1061       14229
Swap:          1099           0        1099

df -h

Code: Select all

Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root  8.7G  7.6G  1.1G  88% /
devtmpfs             7.8G     0  7.8G   0% /dev
tmpfs                7.8G  148K  7.8G   1% /dev/shm
tmpfs                7.8G  9.1M  7.8G   1% /run
tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda7           1014M  143M  872M  15% /boot
/dev/sda1            496M   43M  454M   9% /boot/efi
tmpfs                1.6G   16K  1.6G   1% /run/user/0


I don't see the 11 GB shown when I perform any of these commands, but I've tried to continue anyways.
fdisk /dev/sda (since the Unallocated Space should be in /dev/sda, right?)

Code: Select all

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):

I type n to create a new partition, but instead of being asked primary or extended like in the guide, I get:

Code: Select all

Partition number (9-128, default 9):


This is where I've stopped, as I don't know what I want the partition number to be, and if because I didn't have to select a primary or extended partition that there could be something wrong.

Oh, and my root and swap spaces are in /dev/sda8, as you can see when I perform this command:

Code: Select all

[root@localhost ~]# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 238.5G  0 disk
├─sda1        8:1    0   500M  0 part /boot/efi
├─sda2        8:2    0   128M  0 part
├─sda3        8:3    0 204.7G  0 part
├─sda4        8:4    0   450M  0 part
├─sda5        8:5    0    12G  0 part
├─sda6        8:6    0     1M  0 part
├─sda7        8:7    0     1G  0 part /boot
└─sda8        8:8    0   9.8G  0 part
  ├─cl-root 253:0    0   8.7G  0 lvm  /
  └─cl-swap 253:1    0   1.1G  0 lvm  [SWAP]


So, could someone here help me out? I'm a bit fearful of screwing up one of my Windows partitions. And I am open to installing GUI software if it would make the process easier.

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

Re: How to add Unallocated Space to Swap and Root?

Postby TrevorH » 2017/10/17 22:32:31

I wanted to ask this question in #centos


The freenode web gateway is banned in #centos as it's used by too many spammers and trolls. You'll also need to register and sign in with nickserv before you can join.

CentOS 7 does not run very well on this machine, which I'm thinking is related to the fact that I only have about 1 GB of space left for root and only assigned 1 GB of swap space.


Take a step back and let's not jump to conclusions. The data you posted in your free -m output shows zero swap space is used so whatever your problem is, it's not that. Yes, you are tight on space on your / filesystem but that won't make it slow nor will it cause it to "not run very well" unless that means you're getting continual "out of space" errors?

How about a better description of "does not run very well"? Maybe some stats to demonstrate that? Can you show the output of vmstat -SM 5 5 for example when it next shows the problem?
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

names_are_useless
Posts: 7
Joined: 2017/10/17 20:58:20

Re: How to add Unallocated Space to Swap and Root?

Postby names_are_useless » 2017/10/17 22:51:02

Thank you for the post Trevor!

Here is the result when I run the command:

Code: Select all

[root@localhost ~]# vmstat -SM 5 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0  14333      3    681    0    0    78     6   93  162  2  1 98  0  0
 1  0      0  14332      3    681    0    0     0     0  681 1509  2  1 97  0  0
 1  0      0  14335      3    677    0    0     0   166 1054 2270  3  1 96  0  0
 0  0      0  14330      3    684    0    0     0     2  855 2172  4  1 96  0  0
 0  0      0  14338      3    675    0    0     0     0  604 1426  3  1 97  0  0


As for "does not run very well":
  • CentOS 7 freezes up often, requiring a manual restart. Is there a common pattern as to when the freezing occurs? I've not noticed one.
  • If I try and start CentOS 7 in the GUI login, it will freeze up. The only way to get to Desktop is to boot into Terminal and startx.
  • I've installed some KDE utilities and Gparted to see if they'd be easier to edit partitions: GParted looks to be the easiest tool for the job. Unfortunately I only have 412MB of free space in root left. Adding disk space is very much needed.

Current df -h

Code: Select all

Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root  8.7G  8.3G  412M  96% /
devtmpfs             7.8G     0  7.8G   0% /dev
tmpfs                7.8G   88K  7.8G   1% /dev/shm
tmpfs                7.8G  9.1M  7.8G   1% /run
tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda7           1014M  143M  872M  15% /boot
/dev/sda1            496M   43M  454M   9% /boot/efi
tmpfs                1.6G   12K  1.6G   1% /run/user/0


With the KDE utilities, I can save Screenshots with KSnapshot now. Here's what GParted says:
(/dev/sda is the free space, /dev/sda8 is where root and swap are stored)
Attachments
snapshot1.png
snapshot1.png (207.17 KiB) Viewed 274 times

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

Re: How to add Unallocated Space to Swap and Root?

Postby TrevorH » 2017/10/17 23:03:24

CentOS 7 freezes up often, requiring a manual restart. Is there a common pattern as to when the freezing occurs? I've not noticed one.
If I try and start CentOS 7 in the GUI login, it will freeze up. The only way to get to Desktop is to boot into Terminal and startx.


Those don't sound like disk space related issues. Is there anything in your logs after it does this? Look in /var/log/messages for one thing. Is the machine accessible from the network when it does this - i.e. can you ssh to it from elsewhere?

But you're right, you do need more space. So what you have is a disk with a GPT label on it so adding a new partition is easy so do that with whatever tool you're happiest using. Tag it as an LVM partition and when you've saved it (might need a reboot) then use pvcreate /dev/sda9 (device name might be different, check first!) then use the vgextend command to add that new PV to your current 'cl' volume group. Now you can use lvextend -r command to add some of that to your root filesystem (the -r tells it to resize the filesystem too). The man page for each of those commands will tell you more about how to run them.

I don't think, on the current evidence, that you need more swap.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

names_are_useless
Posts: 7
Joined: 2017/10/17 20:58:20

Re: How to add Unallocated Space to Swap and Root?

Postby names_are_useless » 2017/10/18 00:01:03

So I allocated the 10GB of space to a "lvm2 pv" in GParted. Unfortunately I don't know what to put after pvcreate:

Code: Select all

[root@localhost ~]# pvcreate /dev/sda9
  Device /dev/sda9 not found (or ignored by filtering).
  [root@localhost ~]# pvcreate root-swap-ex
  Device root-swap-ex not found (or ignored by filtering).
[root@localhost ~]# pvcreate /dev/root-swap-ex
  Device /dev/root-swap-ex not found (or ignored by filtering).


Well, I'm an idiot. I accidentally wiped messages and messages-20171017 as root (I really should stop running "touch" as root!). I did find a backup from October 10th, so maybe that will help?
Attachments
messages-20171010.zip
(46.31 KiB) Downloaded 5 times
snapshot2.png
snapshot2.png (196.81 KiB) Viewed 262 times
Last edited by names_are_useless on 2017/10/18 00:05:00, edited 1 time in total.

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

Re: How to add Unallocated Space to Swap and Root?

Postby TrevorH » 2017/10/18 00:04:15

[root@localhost ~]# pvcreate /dev/sda9
Device /dev/sda9 not found (or ignored by filtering).


Did you reboot after creating it and trying to run that? If not, try it.

You'd need to look in the current /var/log/messages to see the current errors (if there are any). I doubt if backup versions will be of any use.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

names_are_useless
Posts: 7
Joined: 2017/10/17 20:58:20

Re: How to add Unallocated Space to Swap and Root?

Postby names_are_useless » 2017/10/18 00:11:23

Ok, I just rebooted after creating the Partition in GParted. Unfortunately, when I reboot, the 10GB is Unallocated again, and I still get this:

Code: Select all

[root@localhost ~]# pvcreate /dev/sda9
  Device /dev/sda9 not found (or ignored by filtering).


Can you explain one method, step by step, of how I would go about creating a partition from this 10GB of Unallocated Space?

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

Re: How to add Unallocated Space to Swap and Root?

Postby TrevorH » 2017/10/18 08:24:03

I'd use fdisk to do it, or gdisk. Make sure you use 'w' to write the updated partition table at the end or 'q' to quit without saving if you're not sure you did it right.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

names_are_useless
Posts: 7
Joined: 2017/10/17 20:58:20

Re: How to add Unallocated Space to Swap and Root?

Postby names_are_useless » 2017/10/18 18:02:18

fdisk has been recommended in the various guide I've looked up online, and I've tried to partition the Unallocated Partition with fdisk before:
fdisk /dev/sda (since the Unallocated Space should be in /dev/sda, right?)

Code: Select all

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):

I type n to create a new partition, but instead of being asked primary or extended like in the guide, I get:

Code: Select all

Partition number (9-128, default 9):


This is where I've stopped, as I don't know what I want the partition number to be, and if because I didn't have to select a primary or extended partition that there could be something wrong.

Let me provide some more detail: if I select "9" (meaning the new partition would be "/dev/sda9", correct?), then I'm asked to select the First and Last sectors. According to the main guide I'm using, says I should select the defaults, but I get told the last sector is out of range:

Code: Select all

First sector: (34-500118158, default: 430610432): 430610432
Last sector, +sector or +size{K,M,G,T,P} (430610432-451581951, default 451581951): 451581951
Value out of range.

It then asks me to input the Last sector again. What should I select?

While going through all this, I'm beginning to wonder if I'm better off reinstalling CentOS 7, and where this time around I'll set swap and root to higher values that better reflect the Recommended disk space needed for CentOS 7 (so at least 20 GB in total). But, will the Unallocated Space be recognized during a reinstall? And even if it is, there are two other problems:
  • It took nearly a dozen times before CentOS 7 installation completed: the other times it usually froze (and it was one specific file). Through some kind of miracle, it installed correctly once, and I've kept it this way since then. Now, maybe this freezing is in relation to the very small 10GB I assigned together to swap and root (at the time I figured meeting the Min Specs was fine), but maybe the freezing issues could be related to the general hardware I'm using (I'm using a Dell Precision 7510 laptop, but if you'd like I could post the full specs). In fact, remembering this, I'm really apprehensive of going through all this again (it was about a weeks worth of tries before CentOS 7 installed correctly).
  • I'm always nervous about the BIOS not recognizing Linux after installing it on a dual-boot system, based on my experience dual-installing Windows and Linux on one machine (on other machines I've installed Ubuntu and Linux Mint in place of CentOS, which I'm generally more comfortable with), where sometimes Windows will become the only Primary Boot option in the BIOS, meaning I can't boot to GRUB and get to the Linux OS I just installed (I always install Windows first and THEN Linux, the other way around I've always found Windows just wiping the Linux partitions). Never a problem this one successful install though.

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

Re: How to add Unallocated Space to Swap and Root?

Postby TrevorH » 2017/10/18 21:32:39

Post the output from fdisk -lu /dev/sda
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke