10. Resize LVM Linux

To mount sdb to an LVM (Logical Volume Manager) on Linux, you'll first need to prepare the disk and create the necessary partitions and volumes. Here's a step-by-step guide:

  1. Partition the disk (sdb): You can use a partitioning tool like fdisk or parted to create partitions on sdb. For example, you can create a single partition spanning the entire disk.

    bash
    sudo fdisk /dev/sdb

    Then follow the prompts to create a new partition (n), choose primary partition, select the default partition number, and use the entire disk (+1T).

  2. Create a Physical Volume (PV): After partitioning, you need to initialize the partition as a physical volume for LVM.

    bash
    sudo pvcreate /dev/sdb1
  3. Extend the Volume Group (VG): If you want to extend an existing volume group, you can use vgextend. If you want to create a new one, you can use vgcreate. For extending an existing VG, you might have to check its name.

    bash
    sudo vgextend ubuntu-vg /dev/sdb1

    Replace ubuntu-vg with the name of your volume group.

  4. Create a Logical Volume (LV): Once the volume group is extended, you can create a logical volume within it.

    perl
    sudo lvcreate -l 100%FREE -n sdb-lv ubuntu-vg

    This creates a logical volume named sdb-lv using all available space in the volume group ubuntu-vg.

  5. Format the Logical Volume: You'll need to format the newly created logical volume with a file system. Replace ext4 with your desired file system type.

    bash
    sudo mkfs.ext4 /dev/ubuntu-vg/sdb-lv
  6. Mount the Logical Volume: Create a mount point and mount the logical volume.

    bash
    sudo mkdir /mnt/sdb sudo mount /dev/ubuntu-vg/sdb-lv /mnt/sdb

    Now your sdb disk should be mounted to /mnt/sdb as an LVM.

Remember to replace volume group and logical volume names (ubuntu-vg and sdb-lv respectively) with your actual ones. Also, ensure you understand the implications of these operations on your system before proceeding.

Resize 

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

Eksekusi perubahan

resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv

Revision #2
Created 5 May 2024 12:28:26 by Sandi Wibowo
Updated 12 May 2024 11:58:35 by Sandi Wibowo