3

Yesterday I installed ubuntu server on an old laptop to use as home server for Jellyfin and other applications. Everything is going great, until I run the 'df -h' command to check available space on disk, and it says I only have 98G total on /.

homeserver@homeserver:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              380M  1.7M  379M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   98G   19G   75G  20% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  131M  1.7G   8% /boot
/dev/sda1                          1.1G  6.1M  1.1G   1% /boot/efi
tmpfs                              380M  4.0K  380M   1% /run/user/1000

The laptop has approximately a half a terabyte hard drive. lsblk output:

homeserver@homeserver:~$ lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                     7:0    0  55.7M  1 loop /snap/core18/2785
loop1                     7:1    0 268.5M  1 loop /snap/nextcloud/35878
loop2                     7:2    0  49.8M  1 loop /snap/snapd/18357
loop3                     7:3    0  63.3M  1 loop /snap/core20/1822
loop4                     7:4    0 111.9M  1 loop /snap/lxd/24322
loop5                     7:5    0  53.3M  1 loop /snap/snapd/19457
loop6                     7:6    0  63.4M  1 loop /snap/core20/1974
sda                       8:0    0 465.8G  0 disk
├─sda1                    8:1    0     1G  0 part /boot/efi
├─sda2                    8:2    0     2G  0 part /boot
└─sda3                    8:3    0 462.7G  0 part
  └─new_name-ubuntu--lv 253:0    0   100G  0 lvm  /media/drive
                                                  /
sr0                      11:0    1  1024M  0 rom

I tried to mount with: sudo mount /dev/sda3 /media/drive , however this error is shown: mount: /media/drive: unknown filesystem type 'LVM2_member'.

I tried following a guide on how to mount it, that's why it is called new_name-ubuntu--lv now, and it says /media/drive, yet I wasn't able to do it correctly.

Is there any way I can expand those 100G to take all the available space?

Just in case, this is the uname -a output:

Linux homeserver 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux 
2
  • I have the same question! I've got an sda3 drive that is massive (5.7 tb) and then a small volume 100G attached to that, how do I expand that volume and mount it?
    – Slug
    Commented Sep 30, 2023 at 4:06
  • This is LVM, you need to mount mapper volume to use it.
    – pbies
    Commented Sep 30, 2023 at 18:16

1 Answer 1

5
+50

You need to understand the difference between a partition and logical volume.

You are trying to mount a /dev/sda3 partition but there you already have LVM managing it (show as type lvm).

This part

└─new_name-ubuntu--lv 253:0    0   100G  0 lvm  /media/drive
                                                  /

Shows that you have logical volume already mounted to /media/drive and as / at the same time. That is probably a glitch.

There are 3 commands useful when managing LVM

  • pvdisplay - shows Physical volume
  • vgdisplay - shows Volume group
  • lvdisplay - shows Logcial volume

In your case your physical volume is new_name-ubuntu--lv.... The logical volume /dev/mapper/ubuntu--vg-ubuntu--lv....

Anyways to extend LVM you need to do the following

a) Find out which filesystem you have with lsblk --fs

NAME                     FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1                                                                                                   
├─nvme0n1p1              vfat        FAT32          9DE1-20E0                               505.1M     1% /boot/efi
├─nvme0n1p2              ext2        1.0            dfxxxx33f-dcde-4884-a09a-68ad7ff0029b    230.6M    46% /boot
└─nvme0n1p3              crypto_LUKS 2              db0sxsxe8-a3fb-4570-bea1-3f1fb93407e4                  
  └─nvme0n1p3_crypt      LVM2_member LVM2 001       izpVno-gxxl-7ur7-O60V-I5a7-5hdt-INEmmE                
    ├─magnetron--vg-root ext4        1.0            c49xxx2d-4219-4d38-afca-5a517b121b25       83G    30% /
    ├─magnetron--vg-swap swap        1              46fxxxxc-2a5c-437e-8df4-3ab122beb148                  [SWAP]
    └─magnetron--vg-home ext4        1.0            67xxxxba-ee76-4583-ad24-95517e015788    383.5G    69% /home

As you can see I have ext4 for my root and home. I don't know what type of filesystem you have, I'm using my ext4 as an example.

b) Check the free space for your volume group. You can use a shortcut vgs

Which should show you something along these lines:

  VG           #PV #LV #SN Attr   VSize  VFree  
  magnetron-vg   1   3   0 wz--n- <1.82t 257.02g

As you can see I have 257.02G of free space.

c) Check the sizes of logical volume(s) you have with lvs:

  LV   VG           Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home magnetron-vg -wi-ao----   <1.44t                                                    
  root magnetron-vg -wi-ao---- <127.94g                                                    
  swap magnetron-vg -wi-ao----    6.00g  

Now I know how much free space I have left and current sizes of the logical volumes.

d) To extend it you need to extend the logical volume. For my home it would be (you will find it at LV path when running lvdisplay). To take all available space you need to run:

lvextend -l +100%FREE /dev/magnetron-vg/home

e) Then you need to extend your filesystem. In my case ext4.

Warning: be sure your kernel and filesystem support online resizing when mounted - tune2fs -l /dev/magnetron-vg/home| grep resize_inode (if you get output it means your filesystem supports online resizing)

To resize ext4:

resize2fs /dev/magnetron-vg/home

To check everything went well:

e2fsck /dev/magnetron-vg/home

Note: You could do the lvm extension and ext4 resize in one command like lvresize --resizefs --size +100%FREE /dev/magnetron-vg/home, but I don't like that. I like to have as simple steps as possible. In case anything goes south you know exactly where it went wrong.

You must log in to answer this question.

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