Operation:

  • sudo vgs: ubuntu-vg 1 1 0 wz--n- 462.69g 362.69g
  • df -T / : /dev/mapper/ubuntu--vg-ubuntu--lv ext4 102626232 24338224 73028744 25% /
  • sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  • sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

Never did this before on an encrypted drive. Is this the proper procedure? Obviously a complete image back up is in order, however, are there any gotchas, caveats, pitfalls that I should be aware of before proceeding?

  • AcornTickler@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 hour ago

    This might not be what you are looking for but in such cases I just use GParted running on a Linux Mint bootable thumb drive.

    Though I don’t know if a similarly capable CLI alternative exists for headless servers.

  • tehfishman@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    4 hours ago

    Might be less confusing if you take a look at what you have with lsblk first. That might give you a better view of your existing disk layout so you know what you need to do. To your specific question though, I’m pretty sure resizing the LUKS volume is done with some sub-command in crypysetup. I’m not at a proper computer to check, but it’s definitely in the man page.

    All that assumes you have LUKS underneath LVM, which is fairly standard practice.

    Hope that helps get you pointed in the right direction.

    • irmadlad@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 hours ago

      Results of lsblk:

      NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS

      loop0 7:0 0 63.8M 1 loop /snap/core20/2866

      loop1 7:1 0 63.9M 1 loop /snap/core20/2318

      loop2 7:2 0 87M 1 loop /snap/lxd/29351

      loop3 7:3 0 38.8M 1 loop /snap/snapd/21759

      loop4 7:4 0 91.7M 1 loop /snap/lxd/38800

      loop5 7:5 0 49.3M 1 loop /snap/snapd/26865

      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

      └─dm_crypt-0 253:0 0 462.7G 0 crypt

      └─ubuntu--vg-ubuntu--lv 253:1    0   100G  0 lvm   /
      
      • NotEasyBeingGreen@slrpnk.net
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 hours ago

        Ah great. It looks like you have a mostly empty encrypted partition with LVM on top of it. If memory serves you might be able to resize the logical volume and the ext4 filesystem in a single command.

  • themachine@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    5 hours ago

    You can’t resize the filesystem without first resizing the crypted volume.

    You would expand this LV. Expand the crypted volume. The decrypt the volume and expand the underlying filesystem.

    • irmadlad@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      5 hours ago

      hmmmm…I thought that the command sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv would extend the encrypted volume, and this command sudo resize2fs /dev/ubuntu-vg/ubuntu-lv would extend the filesystem.

        • irmadlad@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          5 hours ago

          Is the LUKS volume created right on the disk on a raw partition?

          Yes. I’m sorry for the confusion and incomplete info. I’m flying a little blind here. The first two commands in the OP were to check what I have, and the last two were to extend the LUKS and then the filesystem.

          • themachine@lemmy.world
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 hours ago

            I saw in another comment your lsblk output and yes I see the LUKS partition spans the whole disk.

            So yes, the commands you listed should be sufficient. It will extend the decrypted logical volume to use the remaining free space of your volume group.

            • irmadlad@lemmy.worldOP
              link
              fedilink
              English
              arrow-up
              1
              ·
              3 hours ago

              Thank you very much for your patience in trying to tweeze out all the proper info out of me. I feel like a slightly educated dumbass now. LOL Thanks again.

          • i_am_not_a_robot@discuss.tchncs.de
            link
            fedilink
            English
            arrow-up
            2
            ·
            4 hours ago

            lv* commands are for LVM logical volumes. They’re not related to LUKS. Unless your LVM “physical” volume is on a LUKS encrypted device, you aren’t using LUKS. You’ll need to make the LUKS encrypted PV larger before you can grow your LV.

            Unless your PV is already taking up the whole disk, in which case whether it is LUKS encrypted or not is irrelevant and the question you want to be asking is “how do I resize my LVM LV to fill the rest of my LVM PV?”, which is probably what the commands you have do.

            • irmadlad@lemmy.worldOP
              link
              fedilink
              English
              arrow-up
              1
              ·
              4 hours ago

              how do I resize my LVM LV to fill the rest of my LVM PV

              Again, apologies for my confusion and not being able to articulate coherently or precisely.

  • kat@lemmy.blehiscool.com
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 hours ago

    Do a backup image of the partition first before you run these commands.

    If you decide to use all free space: sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

    Should suffice I’m pretty sure.

    • irmadlad@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 hours ago

      sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

      As I understand (which is limited in this scenario) this command extends the LUKS and then you would have to follow up with sudo resize2fs /dev/ubuntu-vg/ubuntu-lv to extend the file system.

      • kat@lemmy.blehiscool.com
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 hours ago

        I’m pretty sure ⁠-r⁠ flag actually stands for ⁠–resizefs⁠. When you include it, ⁠lvextend⁠ automatically runs the appropriate resize command (⁠resize2fs⁠) for you in the background immediately after the volume is expanded.

        Which makes it a convenient, single-step process.