How do I get this command to work: lvcreate -l 100%FREE-17G gentoo -n crypt_root
- User
How do I get this command to work: lvcreate -l 100%FREE-17G gentoo -n crypt_root
- Assistant
It seems like you're trying to create a logical volume with a size that is 100% of the free space available minus 17GB. However, your syntax for stating the size ("100%FREE-17G") is not correct for the
lvcreatecommand.The
-loption specifies logical extents, so the unit subtraction directly in it may not work as expected. Instead, you can use a more straightforward approach to allocate the size.First, calculate the amount of free extents in your volume group, find the total size of the volume group, and then create the logical volume specifying the size.
Here's a step-by-step approach:
-
Find the free extents in your volume group:
shvgdisplay gentooThis command will show you details about the volume group, including the amount of free extents.
-
Calculate the size you want for the logical volume: Assuming you have the free space available in gigabytes (GB), you want to leave 17GB free. Subtract 17GB from the total free space.
Suppose the total free space is 100GB,
code100GB - 17GB = 83GB -
Create the logical volume with the calculated size: Now you can create the logical volume with the
-Loption to specify the size directly.shlvcreate -L 83G -n crypt_root gentoo
Alternatively, if you want to use extents directly:
-
Find out the total free extents:
shvgdisplay gentoo | grep "Free PE / Size"Suppose it shows "Free PE / Size 25500 / 100.0 GB" which means you have 25500 total free extents.
-
Calculate the extents you need to leave free: Divide 17GB by the size of each extent to find out how many extents correspond to 17GB. The size of each extent is also shown in the
vgdisplayoutput, often under "PE Size".Suppose the PE Size is 4MB:
sh17GB / 4MB = 17 * 1024 / 4 = 4352 extents -
Subtract these extents from the total free extents:
sh25500 - 4352 = 21148 extents -
Create the logical volume with the calculated extents:
-