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:
-
Partition the disk (
sdb
): You can use a partitioning tool likefdisk
orparted
to create partitions onsdb
. For example, you can create a single partition spanning the entire disk.bashsudo 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
). -
Create a Physical Volume (PV): After partitioning, you need to initialize the partition as a physical volume for LVM.
bashsudo pvcreate /dev/sdb1
-
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 usevgcreate
. For extending an existing VG, you might have to check its name.bashsudo vgextend ubuntu-vg /dev/sdb1
Replace
ubuntu-vg
with the name of your volume group. -
Create a Logical Volume (LV): Once the volume group is extended, you can create a logical volume within it.
perlsudo lvcreate -l 100%FREE -n sdb-lv ubuntu-vg
This creates a logical volume named
sdb-lv
using all available space in the volume groupubuntu-vg
. -
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.bashsudo mkfs.ext4 /dev/ubuntu-vg/sdb-lv
-
Mount the Logical Volume: Create a mount point and mount the logical volume.
bashsudo 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.