2

I'm a new linux user (Fedora, LXDE). Now I have some troubles with increasing the size of... partition? Directory? Filesystem? .../usr. This is my question.

What exactly I want to do is to "increase the size of /usr" in order to install new packages. Increasing is a separate problem - maybe I would need to increase size of something different (maybe even delete partition with Windows) - here I'm asking about naming.

If I'm increasing the size of /usr, am I increasing the size of partition /usr, directory /usr, filesystem /usr, block device /usr (because gnome-disk-utility says /dev/fedora/usr is a block device), or something different? Or "increasing" is a misconception here, or I'm increasing something different?

Sorry for the title, I didn't know how to name my problem (thus my question could be too subjective and deleted, I understand that).

EDIT 1: I'm asking in the context of my output of df command:

/dev/mapper/fedora-usr                           2,9G  2,7G   42M  99% /usr

EDIT 2: Well, now I have thought it through and consider that the size of /dev/mapper/fedora-usr is the size to increase.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Silv
  • 305
  • 1
  • 2
  • 12

2 Answers2

5

This is confusing. First, /usr is a directory. But any directory can also be a mount point, which is where a filesystem is anchored. The filesystem by itself is on a block device — this can be either a partition, a logical volume, or a file attached to a loopback device.

There are certain directories which by tradition are often separate mount points, and usr is one of them. I think the easiest way to find out the state of a given system is with the df command — give it the name of a directory, and it will tell you information about the filesystem that directory is under. For example, on my system:

$ df -h /usr
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   79G   19G   57G  25% /

Which shows that for me, /usr is on the "root" filesystem, which is on the device /dev/mapper/fedora-root, which is mounted mounted at /. On your system, based on your update, /usr is separate.

For comparison:

$ df -h /home/mattdm/
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/fedora-home   99G   74G   21G  79% /home

which tells me that my home directory is on a filesystem mounted at /home.

Whether or not a particular directory is a mount point, to make more space available under any directory, you need to increase the space on the filesystem on which that directory resides. In my case, since /usr is on the /dev/mapper/fedora-root filesystem mounted at /, I would need to increase the size of that /dev/mapper/fedora-root. In your case, /usr is the mount point for the /dev/mapper/fedora-usr filesystem, so you need to increase the size of that filesystem.

To make more space on /usr in your situation, you will first need to have a logical volume with enough space — you can add physical volumes to that if there is no room free. Then, you will need to grow the filesystem inside that logical volume too. (This can be done in one step with the --resizefs flag to lvextend.)

mattdm
  • 40,245
  • OK, /usr is a directory, so it follows that I have to increase the size of "a directory /usr"? I believe a directory cannot have its size, but I'm new to linux and its naming. On the other hand, you wrote: "too", so I understand that growing the filesystem isn't always the same as increasing the size that appears in the df output (but could be the same). I know that there are at least 3 "filesystem" meanings in the context of linux.

    Merging with @dr01's answer: you mean /usr is located on a partition, so I got to increase this partition, and the size in df output will grow?

    – Silv Jul 03 '17 at 11:20
  • Yes, /usr is mounted in its own partition, different from the root partition /. So you need 1) to increase that partition and 2) to increase the size of the filesystem accordingly. Once you've done that, the /usr directory will be able to hold more stuff. – dr_ Jul 03 '17 at 11:30
1

I'm taking on from @mattdm's good answer to show you the practical steps to do what you need.

The output of df

/dev/mapper/fedora-usr                           2,9G  2,7G   42M  99% /usr

shows that you are using LVM (Logical Volume Manager), and that the /usr directory is mounted on a LV (Logical Volume) named usr on the VG (Volume Group) named fedora.

Therefore you need to do this:

1) Add a new (physical or virtual) disk to the machine to provide the extra disk space; let's call it /dev/sdc.

2) Create a new partition /dev/sdc1 (of type 0x8E = Linux LVM) on the new disk:

fdisk /dev/sdc 

(I'm assuming you know how to proceed on this so I'm leaving out the details: press n, p, 1, etc.)

This is not necessary but recommended, because if you have other OSes accessing the disk they might not recognize LVM and see the whole unpartitioned disk as empty.

3) Initialize the new partition as a Physical Volume:

pvcreate /dev/sdc1 

4) Add the newly created PV to the existing Volume Group:

vgextend fedora /dev/sdc1 

5) Extend the Logical Volume usr - and the underlying filesystem as well - so that it takes all free space:

lvresize -l+100%FREE --resizefs /dev/mapper/fedora-usr

Your /usr partition is now larger of whatever the size of /dev/sdc was.

dr_
  • 29,602
  • OK, so you do mean that /usr is a partition, and I have to increase the size of "a partition /usr"? Also, from @mattdm's answer, I guess it's not true that /usr is a partition in every case (in the context of resizing). – Silv Jul 03 '17 at 11:03
  • Yes to everything you said. The minimal partitioning scheme is to put everything in /, but usually one creates a separate partition for /home. And is not uncommon to create also a separate partition for /var (so that if the logs in /var/log/ explode, they don't take down the root filesystem with them) or, as in your case, /usr. It all depends for what your machine is used. – dr_ Jul 03 '17 at 11:23
  • OK, to sum up, also according to your comment in @mattdm's answer and his answer: /usr is a mount point - for a directory named /usr (with slash because I mean the filesystem path) - and that directory is under the filesystem /dev/mapper/fedora-usr - and that filesystem is anchored on that mount point (which just means it's accessible from there, right?) - and it's located at the partition =?= block device /dev/fedora/usr (as in gnome-disks). My problem is with "partition" and "physical volume" - how are they related to each other and to the /dev/mapper/fedora-usr filesystem? – Silv Jul 03 '17 at 13:36
  • Not exactly. /dev/mapper/fedora-usr is a LVM device accessible (as all Linux devices) via a subdir of /dev. This LVM device is mounted (not anchored) at /usr. A volume must be split into one or more partitions, which have to be formatted - i.e. a filesystem must be written on them - prior to be usable. See https://unix.stackexchange.com/questions/87300/differences-between-volume-partition-and-drive What helps in confusing you here is that your disks use LVM, which is an abstraction (and a very useful tool) over standard partitions; see https://www.howtoforge.com/linux_lvm – dr_ Jul 04 '17 at 07:20
  • OK, I see you try to teach me, but I'm a very... [searching in dict]... recalcitrant, non-native english-speaking student. ; - ) I will think it over what you wrote. But for now, to be more confused, I see that: (1) usermount says /dev/mapper/fedora-usr is a "device", (2) fdisk says it's a "disk", (3) df says it's a "filesystem", (4) GParted doesn't displaying such a string, and (5) gnome-disks says (in "mount options") that you can "identify" it (what? mount point?) "as" /dev/mapper/fedora-usr. – Silv Jul 04 '17 at 08:30