1

I am using LUKS for disk encryption for a Ubuntu 18.04 system. I'd like to find out how much free space is still available on my hard drive. gparted prints the following:

enter image description here

As you can see the entire disk is subdivided into three partitions. On startup LUKS tells me that the encrypted disk is called nvme0n1p3_crypt. However, there are nvme0n1p1 and nvme0n1p1 as well.

  1. Does this mean the are three partitions being all encrypted with the same key?

    The df -a -h command outputs among others the following:

    /dev/nvme0n1p2               705M  164M  490M  25% /boot
    /dev/nvme0n1p1               511M  6,1M  505M   2% /boot/efi
    

    Unfortunately, I cannot see the actual device which seems to be /dev/nvme0n1p3?

  2. Why doesnt't df list the encrypted disk and how can I find out the available free space?

    df /dev/nvme0n1p3 -h yields the following:

    Filesystem      Size  Used Avail Use% Mounted on
    udev            7,7G     0  7,7G   0% /dev
    
  3. This output seems weird, because the total available space is only 7,7G. This is not true as you can see above in the gparted output. The partition has roughly 475.75 GiB. Can you explain this?

  • OK, first of all, you have 3 questions in one post. The rules of the site is to have one question per post, so please edit this one to focus on one specific thing. Otherwise, this is to broad – Sergiy Kolodyazhnyy Mar 7 at 7:21
1

Does this mean the are three partitions being all encrypted with the same key?

No, this means partition is in use - aka mounted. It's not recommended to edit mounted/in-use filesystems, since data loss can occur. The third big partition is not mounted according to the column in the screenshot

Why doesnt't df list the encrypted disk and how can I find out the available free space?

df reports usage for only mounted filesystems. Filesystems that are not mounted will report usage for /dev filesystem. Here's example of mounted vs unmounted reports:

# unmount my second drive, reports usage for udev
$ udisksctl unmount -b /dev/sdb1
Unmounted /dev/sdb1.
$ df  /dev/sdb1
Filesystem     1K-blocks  Used Available Use% Mounted on
udev             4000948     0   4000948   0% /dev
# statvfs call can be done on mounted filesystem, hence we see usage report
$ udisksctl mount -b /dev/sdb1
Mounted /dev/sdb1 at /mnt/ubuntu.
$ df  /dev/sdb1
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sdb1      115247656 100662532   8707776  93% /mnt/ubuntu

The /dev/nvme0n1p3 does not seem to have proper mountpoint (directory) and instead reports ubuntu-vg. Try the following ( source )

$ sudo mount /dev/ubuntu-vg/root /mnt
$ df -h /dev/ubuntu-vg/root

Since you're using lvm you should use sudo lvs preferably to find out what logical volumes are actually called.

This output seems weird, because the total available space is only 7,7G. This is not true as you can see above in the gparted output. The partition has roughly 475.75 GiB. Can you explain this?

It can occur when filesystem is not resized after partitioning, even with non-lvm cases. So if you have recently resized/repartitioned that device it could be the cause. Again, probably you don't wanna use df with lvm.

  • df /dev/ubuntu-vg/root is still just checking the filesystem on /dev, though. Should be df /mnt. – Olorin Mar 7 at 7:53
  • @Olorin Once the device is mounted, then it should report filesystem usage. I've added an example. Of course, I don't have access to encrypted lvm, but same point should stand – Sergiy Kolodyazhnyy Mar 7 at 7:54
  • 1
    Oh, scratch that. Looks like df has started showing the usage of mounted disks. Nice. – Olorin Mar 7 at 8:06
  • Thanks. I do not understand why the last partition is not mounted. This cannot be true, because this is only partition I have. Besides, there it is not full, even though gparted indicates 0.00 unused memory. Does gparted does not understand LVM volumes or does the encryption cause this wrong output? – null Mar 8 at 10:17
  • 1
    @null Encryption likely is affecting it. GParted has lvm2 support according to their features page , so that's not the issue here. Then again, I can't comment much on the encryption part since I've not much experience with that yet. I'll look into it later, and in the meantime hopefully someone could address the encryption part of the question. I'll share the link to your question if I find someone who could address that. – Sergiy Kolodyazhnyy Mar 8 at 11:24
0

IIRC GParted doesn't really understand LVM volumes. Try the Disks tool.

  1. What does df / report? That would show the device mounted on /, which should be the encrypted LVM volume.
  2. df /some/file checks the filesystem on which that file exists. So df /dev/nvme0n1p3 is just checking the filesystem mounted on /dev.
  3. The filesystem on /dev is the udev virtual filesystem. Its size is the memory (RAM) you have (which would be around 8GB). That size has nothing to do with the hard disk size.
  • Just a side note, /dev can host device files either in memory or general filesystem ( see table ). The size reported is not necessarily RAM. I've 8GB of RAM, but 4 GB of /dev allocated. – Sergiy Kolodyazhnyy Mar 7 at 7:49
  • You'd be hard pressed to find an Ubuntu installation that uses a general filesystem for /dev. That hasn't been done in ages. – Olorin Mar 7 at 7:51
  • True. I'm just accounting for possibilities. – Sergiy Kolodyazhnyy Mar 7 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.