Заказывайте больше ссылкок по 50р на 1к сайтов в телеграме: @stalmokas

Working with LVM using fsdisk

Introduction

LVM (Logical Volume Manager) is a powerful tool that allows users to manage their storage in a flexible and efficient way. By using LVM, you can easily create, resize, and move logical volumes without the need to reformat your file systems. One of the key components of LVM is the fsdisk utility, which is used to interact with the file systems on your logical volumes.

Creating a Physical Volume

The first step in working with LVM is to create a physical volume (PV) using fsdisk. To do this, you need to select a block device, such as a hard drive or a partition, and initialize it as a physical volume. This can be done by running the command sudo fsdisk -pvcreate /dev/sdb1, where /dev/sdb1 is the block device you want to use.

Once the physical volume is created, you can verify its status by running sudo fsdisk -pvs. This will display information about the physical volumes in your system, including their size, free space, and UUID.

Creating a Volume Group

After creating a physical volume, the next step is to create a volume group (VG) using fsdisk. A volume group is a collection of one or more physical volumes that are treated as a single storage pool. To create a volume group, you can run the command sudo fsdisk -vgcreate myvg /dev/sdb1, where myvg is the name of the volume group and /dev/sdb1 is the physical volume you want to add to it.

Once the volume group is created, you can view information about it by running sudo fsdisk -vgs. This will show you details about the volume group, such as its size, physical volumes, and logical volumes.

Creating Logical Volumes

With the volume group set up, you can now create logical volumes (LV) using fsdisk. Logical volumes are virtual partitions that are created within a volume group and can be formatted with a file system. To create a logical volume, you can run the command sudo fsdisk -lvcreate -n mylv -l 100%VG myvg, where mylv is the name of the logical volume, 100%VG specifies the size of the logical volume, and myvg is the volume group where the logical volume will be created.

After creating the logical volume, you can format it with a file system, such as ext4 or xfs, using the mkfs command. For example, to format a logical volume with ext4, you can run sudo mkfs.ext4 /dev/myvg/mylv.

Managing Logical Volumes

Once you have created logical volumes, you can easily manage them using fsdisk. You can resize, move, or remove logical volumes as needed without affecting the data stored on them. To resize a logical volume, you can use the lvresize command. For example, to increase the size of a logical volume, you can run sudo fsdisk -lvresize -L +10G /dev/myvg/mylv.

If you need to move a logical volume to a different physical volume, you can use the lvmove command. This will allow you to move the data from one physical volume to another without any downtime. To remove a logical volume, you can use the lvremove command. This will delete the logical volume and free up the space within the volume group.

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

Сайт создан и монетизируется при помощи GPT сервиса Ggl2.ru
Close