Linux – How to extend the memory of /dev/mapper/vgroot-root

linuxubuntu-18.04

I am using ubuntu machine 18.04. I am trying to download a 6GB of file but i am getting Low Disk Space The volume "filesystem root" has only 769MB Disk free, though i have an hard disk 0f 500GB. I checked the partition, by using command df -h

df -h
Filesystem               Size  Used Avail Use% Mounted on
udev                      16G     0   16G   0% /dev
tmpfs                    3.2G  3.6M  3.2G   1% /run
/dev/mapper/vgroot-root   49G   42G  5.1G  90% /
tmpfs                     16G   92M   16G   1% /dev/shm
tmpfs                    5.0M  4.0K  5.0M   1% /run/lock
tmpfs                     16G     0   16G   0% /sys/fs/cgroup
/dev/loop0                97M   97M     0 100% /snap/core/9665
/dev/loop1                97M   97M     0 100% /snap/core/9804
/dev/loop2               450M  450M     0 100% /snap/pycharm-professional/211
/dev/mapper/vgroot-home  415G   24G  370G   7% /home
tmpfs                    3.2G   16K  3.2G   1% /run/user/125
tmpfs                    3.2G     0  3.2G   0% /run/user/999
tmpfs                    3.2G   56K  3.2G   1% /run/user/500231660

Here i can see /dev/mapper/vgroot-home has 370G free space. I have two questions here,

  1. I am in console with uid@hostname. All my workspace i kept in /home/uid/. So these will store in which memory /dev/mapper/vgroot-root or /dev/mapper/vgroot-home?. How can we find this?
  2. How can we increase space for /dev/mapper/vgroot-root? is there any way to reduce the space of /dev/mapper/vgroot-home and increase /dev/mapper/vgroot-root?

Best Answer

The username you're logged in with does not matter when it comes to where files are stored. Only the working directory does. Make sure that you're in a directory under /home when downloading the file.

The application you're using to download the file might store files in a different directory temporarily. This means that even if you're in /home, it might for example store files under /tmp temporarily. That would then result in the error message.

To increase the size of the vgroot-root partition, you'll first need to make sure that you have free space in your volume group. To do this, you can use the command vgs.

$ sudo vgs
  VG      #PV #LV #SN Attr   VSize  VFree
  vgroot    1   2   0 wz--n- <2.00t 497.84g

In the above example, you can see that the volume group has about 500 gigs of free space. We can then use lvresize to resize this filesystem.

$ sudo lvresize --resizefs -L+100G vgroot/root

The above command adds 100 gigs to the vgroot-root partition, then resizes the filesystem to match.

In your case the Unbuntu installer has probably used all of the volume group for partitions by default. In this case, you need to reduce the size of the vgroot-home partition first. You do this by using the following command.

$ sudo lvreduce --resizefs -L-100G vgroot/home

Change the sizes to the amount you want to change the partitions by. Make sure that you use the plus and minus signs properly. If you forget them, you'll set the partition to exactly that size which may not be what you want.

Note that this applies to the Ubuntu default filesystem type of ext3/ext4. If you used a non-default filesystem type, you may not be able to do an online-resize of the filesystem. If you didn't change anything though, you should be fine.

IMPORTANT

These commands should be safe, but any changes to your filesystem may result in lost data. Make sure that anything vital is backed up before attempting to make any changes.

You make also want to read up on Linux Logical Volume Manager (LVM) to learn more about how LVM works.