FreeKB - LVM (Logical Volume Manager) lvcreate command (create a logical volume)
LVM (Logical Volume Manager) - lvcreate command (create a logical volume)

The lvcreate command can be used to create an LVM logical volume. In this example, a 1 GB logical volume named myLV is created from space in the volume group named myVG. This assumes that a volume group named myVG has been created.

  • kibibyte (k or KiB) - 1024 bytes
  • kilobyte (K or KB) - 1000 bytes
  • mebibyte (m or MiB) - 1024 kibibytes
  • megabyte (M or MB) - 1000 kilobytes
  • gibibyte (g or GiB) - 1024 mebibytes
  • gigabyte (G or GB) - 1000 megabytes
  • tebibyte (t or TiB) - 1024 gibibytes
  • terabyte (T or TB) - 1000 gigabytes
  • pibibyte (p or PiB) - 1024 tebibytes
  • petabyte (P or PB) - 1000 gigabytes
  • exbibyte (e or EiB) - 1024 pibibytes
  • exabyte (E or EX) - 1000 petabytes
~]# lvcreate --size 1G --name myLV myVG

 

Or, the --extents option can be used. Refer to what are LVM extents to understand what LVM extents are.

  • Percentage of available extents in the volume group (e.g. 100%FREE)
  • Percentage of total extents in the volume group (e.g. 50%VG)
  • Percentage of the available extents in the physical volume (e.g. 25%PVS)
  • Percentage of the total extents in the origin logical volume (e.g. 100%ORIGIN)
~]# lvcreate --extents 50%FREE --name myLV myVG

 

The lvdisplay command can be used to verify the logical volume has been created.

~]# lvdisplay
---Logical volume---
LV Path               /dev/myVG/myLV
LV Name               myLV
VG Name               myVG
LV UUID               EuBJ3c-Q8EU0M5ef-Qvip-KeyH-m2Sc-MGelKe
LV Creation host,time localhost.localdomain, 2013-10-11 15:40:12 -0500
LV Status             available
# open                1
LV Size               99.94 GiB
Current LE            3198
Segments              3
Allocation            inherit
Read ahead sectors    auto
- currently set to    256
Block device          253:9

 

Next, the mkfs command can be used to create a file system on myLV. In this example, the ext4 file system is created on myLV.

~]# mkfs.ext4 /dev/myVG/myLV

 

Now, myLV can be mounted. In this example, myLV is mounted to the /var directory.

~]# mount.ext4 /dev/myVG/myLV /var

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 014bc in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |