Skip to main content
grammar
Source Link
tukan
  • 2.3k
  • 13
  • 20

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 gogoes south you know exactly where it went wrong.

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 go south you know exactly where it went wrong.

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.

Bounty Ended with 50 reputation awarded by Slug
Source Link
tukan
  • 2.3k
  • 13
  • 20

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 go south you know exactly where it went wrong.