0

I was trying to install software into a CentOS Linux. It shows that I don't have enough space. When I do df -h I get the following result

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  6.7G  6.7G     0 100% /
devtmpfs                 1.4G     0  1.4G   0% /dev
tmpfs                    1.4G     0  1.4G   0% /dev/shm
tmpfs                    1.4G  8.7M  1.4G   1% /run
tmpfs                    1.4G     0  1.4G   0% /sys/fs/cgroup
/dev/sda1                497M  157M  341M  32% /boot
tmpfs                    282M     0  282M   0% /run/user/0

Then I checked the Virtual Box settings it shows that Virtual size is 59.7 GB but the actual size is 6.84 GB

How do I increase the size to 59.7 GB?

  • 1
    probably you've partitioned the disk incorrectly. The hard disk size is 59.7GB but the root partition is only 6.7GB, the remaining is just blank space. Run `fdisk -l` to see – phuclv Mar 06 '19 at 15:57
  • Yes, you are right. How do I increase the root partition to 59.7GB? when I run `fdisk -l` I get this @phuclv `Disk /dev/sda: 64.0 GB, 63962087424 bytes, 124925952 sectors /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 16777215 7875584 8e Linux LVM` – truthtriumphs Mar 06 '19 at 16:11

1 Answers1

0

From your comment /dev/sda2 is around ~8GB (since it looks like fdisk uses 1KiB sector, but I'm not sure about that)

/dev/sda: 64.0 GB, 63962087424 bytes, 124925952 sectors

Device      Boot    Start       End         Sectors     Size    Id Type
/dev/sda1   *       2048        1026047     512000      83      Linux
/dev/sda2           1026048     16777215    7875584     8e      Linux LVM

Just run gparted to resize /dev/sda2 to the end of the hard drive, and then resize your LVM partition. For more information about resize LVM partition read How can I resize an LVM partition? (i.e: physical volume)

phuclv
  • 26,555
  • 15
  • 113
  • 235
  • thanks for the comment. I need to expand it 60 GB, the article that you linked shows "How to shrink" Is there a way to expand? – truthtriumphs Mar 07 '19 at 05:35
  • Hi @phuclv, I did run the following, it does seem to have given another 8% free. Here is what I did `[root@localhost ~]# lvextend -l 100%VG /dev/mapper/centos-root Size of logical volume centos/root changed from 6.67 GiB (1707 extents) to 6.71 GiB (1717 extents). Logical volume root successfully resized.` Here is the result `[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 6.7G 5.5G 1.3G 82% /` Still wondering how do get to use the 60 GB, which is not showing in any of the disk usage? – truthtriumphs Mar 07 '19 at 05:40
  • @truthtriumphs did you resize /dev/sda2 as I said? Because `6.67 GiB (1707 extents) to 6.71 GiB (1717 extents)` looks like the partition is still the same size, so LVM can't resize it any bigger than that – phuclv Mar 07 '19 at 06:09
  • Thanks!! I missed that step. I am trying to resize it – truthtriumphs Mar 07 '19 at 06:11
  • @phclv I don't see a /dev/sda2 patition. Here is the result of `df -h` command `/dev/mapper/centos-root 6.7G 5.6G 1.2G 83% / devtmpfs 1.4G 0 1.4G 0% /dev tmpfs 1.4G 0 1.4G 0% /dev/shm tmpfs 1.4G 8.7M 1.4G 1% /run tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup /dev/sda1 497M 157M 341M 32% /boot tmpfs 282M 0 282M 0% /run/user/0` Kindly forgive me I am just learning how Linux does partitions – truthtriumphs Mar 07 '19 at 06:17
  • of course you can't see /dev/sda2 if you run `df -h` because it isn't mounted anywhere. It's just a container for LVM to store its partitions (which is the /dev/mapper you saw above). You need to use a disk partitioner like gparted to resize the container first before you can store more things in it – phuclv Mar 07 '19 at 06:24
  • Thanks @phuclv I am connecting via Putty. I did install gparted when type in `gparted` I get the following result `[root@localhost ~]# gparted (gpartedbin:12004): Gtk-WARNING **: cannot open display:` I did try using parted. How do I fix this? – truthtriumphs Mar 07 '19 at 06:39
  • if you can setup display forwarding then you can use GUI apps through SSH. Otherwise you need a CLI partitioner, but I've never partitioned a disk from command line so I'm not sure about that – phuclv Mar 07 '19 at 06:46
  • Thanks @phuclv. I managed to use X11 to forward to my Windows client where I am using my Putty. I am able to get GUI programs from Putty SSH. For e.g if type i `[root@localhost ~]# libreoffice` I get the LiberOffice program in Windows. But when I type `gparted` I get the following error. `[root@localhost ~]# gparted /usr/sbin/gpartedbin: symbol lookup error: /usr/sbin/gpartedbin: undefined symbol: _ZN4Glib17SignalProxyNormal13connect_impl_EbON4sigc9slot_baseEb` – truthtriumphs Mar 07 '19 at 07:56
  • @truthtriumphs to resize the 8e LVM container from command line you can use `sfdisk`. See [Resize extended partition lvm](https://unix.stackexchange.com/q/379549/44425) – phuclv Mar 08 '19 at 02:23
  • Thanks @phuclv. I ended up deleting everything and recreating another VM... – truthtriumphs Mar 10 '19 at 06:56