2

New to Linux, I want to increase the size of disk space in fedora-root and it appears that theres ~16GB of available space in other filesystems. Is this a correct assessment? Below I provide the result of commands df and pvscan.

[lobster@localhost ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  4.9M  3.9G   1% /run 
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   22G   20G  612M  98% /
tmpfs                    3.9G  144K  3.9G   1% /tmp
/dev/sda1                976M  128M  782M  15% /boot
tmpfs                    797M   20K  797M   1% /run/user/42
tmpfs                    797M   11M  787M   2% /run/user/1000

[lobster@localhost ~]$ sudo pvscan
[sudo] password for lobster: 
PV /dev/sda2   VG fedora          lvm2 [24.00 GiB / 0    free]
Total: 1 [24.00 GiB] / in use: 1 [24.00 GiB] / in no VG: 0 [0   ]

I recognize this question is similar to No more space in root filesystem, how could I increase the size? However, when I run the solution from this thread I receive the following

[lobster@localhost ~]$ sudo lvextend --size +3.9G --resizefs /dev/fedora/root
Rounding size to boundary between physical extents: 3.90 GiB.
Insufficient free space: 999 extents needed, but only 0 available

Please help me understand in the simplest possible terms how I can increase roots disk space. Thank you.

Edit: Additional Information

[lobster@localhost ~]$ sudo fdisk -l /dev/sda
Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 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
Disklabel type: dos Disk identifier: 0x4bf237d2

Device    Boot   Start      End  Sectors Size Id Type
/dev/sda1         2048  2099199  2097152   1G 83 Linux
/dev/sda2    * 2099200 52426751 50327552  24G 8e Linux LVM
3
  • tmpfs isn’t a disk-based filesystem. Free space in other filesystems doesn’t matter anyway. // Instead, provide the output of fdisk -l /dev/sda. Don’t get your hope up though, there’s probably not enough physical space in your device.
    – Daniel B
    Commented Jul 28, 2018 at 17:20
  • I think this lvm2 [24.00 GiB / 0 free] is explains all. You have no space on physical drive.
    – Alex
    Commented Jul 28, 2018 at 18:25
  • @DanielB [lobster@localhost ~]$ sudo fdisk -l /dev/sda [sudo] password for lobster: Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 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 Disklabel type: dos Disk identifier: 0x4bf237d2 Device Boot Start End Sectors Size Id Type /dev/sda1 2048 2099199 2097152 1G 83 Linux /dev/sda2 * 2099200 52426751 50327552 24G 8e Linux LVM Commented Jul 28, 2018 at 21:59

1 Answer 1

2

Misunderstanding

it appears that there's ~16GB of available space in other filesystems

Well, if this available space was on disk(s), there might be a way to do what you want; but devtmpfs and tmpfs store data in RAM. RAM is volatile, you cannot use it for long-term storage.

Even if you could, these 3.9G values do not add. Ram-based filesystems take from a common pool. Adding files to one of them would reduce the space available to others.


Abstraction layers

In your case there are few layers of abstraction. Let's name them (outer first):

  • the physical device /dev/sda
    • partitions, among them the one used by LVM: /dev/sda2
      • the virtual device provided by LVM: /dev/mapper/fedora-root
        • the filesystem

Changes in each layer are made with different actions/commands. In general, if you want to expand a filesystem and it requires few layers to be modified, you start from the most outer one; if you want to shrink, you start from the most inner, the filesystem itself.


Overview

So what is available for you? Your /dev/sda is 52428800 sectors of 512 bytes. The sectors are numbered from 0 to 52428799. Among them:

  • The sector 0 is MBR.
  • Sectors 1-2047 probably hold (a part of) your bootloader. You shouldn't touch them. It's about 1 MiB anyway, not a significant space.
  • Sectors 2048 - 52426751 are your two partitions. We will go back to them in a moment.
  • Sectors 52426752 - 52428799 are probably unused. Another 1 MiB, almost nothing.

Run fdisk -l and lsblk to see if there are other devices available. This is a general advice, I guess if they were there you would know.

OK, how about /dev/sda2? It's Linux LVM, pvscan told you the whole space is distributed. The vast majority of it builds /dev/mapper/fedora-root which holds your root filesystem (mounted under /). The size of the filesystem is about 22 GiB. This is less than 24 GiB reported by pvscan; possible reasons:

  • LVM holds your swap partition, about 2 GiB (likely, run lvscan and swapon to confirm);
  • or the filesystem is smaller than the /dev/mapper/fedora-root virtual device (unlikely);
  • other (unlikely).

How about /dev/sda1? It holds the filesystem mounted under /boot. Most likely you don't need the whole 1 GiB for it, it could be smaller. If you shrink it, you will be able to create a new partition (like sda3), add it to LVM and expand the root filesystem. If you shrink it too much, you will encounter problems during the OS upgrade. You probably could get couple of hundreds MiB out of it and avoid future problems anyway, but

  • it's only few hundreds MiB;
  • if anything goes wrong, your OS may not boot.

Your options (summary)

  1. Use ncdu or similar tool to identify large files/directories in the root filesystem; think, investigate if you can delete them. This way maybe you can gain some free space without resizing the filesystem.
  2. Reduce the swap partition (if any) and reconfigure your LVM to be able to expand the root filesystem eventually. You haven't told us about your swap, it's hard to say how much you can gain or if there is any sense in it in the first place. In general you do need some amount of swap space.
  3. Shrink the filesystem currently mounted as /boot (discussed above).
  4. Physically attach another device (like /dev/sdb) and add it or its partition(s) to LVM. The information you provided makes me believe this is the only way to significantly increase your root filesystem. If it's a virtual machine we're talking about, you may be able to expand the existing device /dev/sda (not usually possible for truly physical device) instead of adding a separate new one.

Notes

  • It's good you're using LVM. It makes most of the above options simpler.
  • Expanding the filesystem itself will be the last step. I don't know what type it is. Some filesystem types (ext4, btrfs) support on-line manipulation; this means you can expand a filesystem when it's mounted, very useful for a root filesystem.
  • To guide you in more detail (actual commands etc.) we need to know what option you choose. Covering them all would make the question and answer(s) very broad, you would also need to provide a lot of additional information. Therefore
    • (meta note) I suggest to let this question be "what ways of increasing root disk space do I have?" After you make your decision, you can ask another question for details (or maybe there is a similar question already). We can link from here to the detailed question later.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .