lvcreate: command not found

lvcreate is a Linux command used to create a logical volume (LV) in a Linux Logical Volume Manager (LVM) setup. A logical volume is a virtual block device that provides a layer of abstraction between the physical storage and the file system. This allows for more flexible and dynamic management of storage, such as resizing and moving of volumes without affecting the data.

lvcreate command is used basically to create a new logical volume in LVM. To create a basic LVM volume, you can use the below command:

$ sudo lvcreate -l 100%FREE -n lvtest Vol1
  Logical volume “lvtest” created

If you want to see the details of what you created, use the lvdisplay command:

$ sudo lvdisplay Vol1
  --- Logical volume ---
  LV Path                 /dev/Vol1/lvtest
  LV Name                 lvtest
  VG Name                 Vol1
  LV UUID                 4W2369-pLXy-jWmb-lIFN-SMNX-xZnN-3KN208
  LV Write Access         read/write
  LV Creation host, time  … -0400
  LV Status               available
  # open                  0
  LV Size                 2.00 GiB
  Current LE              513
  Segments                1
  Allocation              inherit
  Read ahead sectors      auto
  - currently set to      256
  Block device            253:2

The -l parameter defines how much of the available space on the volume group specified to use for the logical volume. Notice that you can specify the value as a percent of the free space in the volume group. This example used all (100%) of the free space for the new logical volume.

You can use the -l parameter to specify the size as a percentage of the available space or the -L parameter to specify the actual size in bytes, kilobytes (KB), megabytes (MB), or gigabytes (GB). The -n parameter allows you to provide a name for the logical volume (called lvtest in this example).

LVM command options are as shown below:

If you encounter the below error while running the command lvcreate:

lvcreate: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install lvm2
Ubuntu apt-get install lvm2
Alpine apk add lvm2
Arch Linux pacman -S lvm2
Kali Linux apt-get install lvm2
CentOS yum install lvm2
Fedora dnf install lvm2
Raspbian apt-get install lvm2

lvcreate Command Examples

1. Create a logical volume of 10 gigabytes in the volume group vg1:

# lvcreate -L 10G vg1

2. Create a 1500 megabyte linear logical volume named mylv in the volume group vg1:

# lvcreate -L 1500 -n mylv vg1

3. Create a logical volume called mylv that uses 60% of the total space in volume group vg1:

# lvcreate -l 60%VG -n mylv vg1

4. Create a logical volume called mylv that uses all the unallocated space in the volume group vg1:

# lvcreate -l 100%FREE -n mylv vg1
Related Post