LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Using parted command to create LVM partitions (https://www.linuxquestions.org/questions/linux-general-1/using-parted-command-to-create-lvm-partitions-4175533903/)

tesla75 02-13-2015 07:51 AM

Using parted command to create LVM partitions
 
Oracle Linux 6.6

To create Physical Volumes for Volume groups (LVM) , the disk need to be partitioned to LVM type ie. 'Linux LVM' type . In fdisk , this can done by choosing 8e when prompted for partition type.

Since it is easy to script (non-interactive), I use parted command rather than fdisk to create partitions


For creating standard partitions, I use the below 2 non-interactive steps in our scripts

Step1. Creating the partition table for the device

parted -s /dev/sda mklabel msdos

For gpt, I use

parted -s /dev/sda mklabel gpt

Step2. create a primary partition that starts after 1mb (to ensure proper alignement)

parted -s /dev/sda unit mib mkpart primary 1 100%



From the below link , I gathered that partition can be set to LVM type interactively using

set [partition number] lvm on

http://computernetworkingnotes.com/p...-in-linux.html

But, how can I incorporate this into step2 (non-interactive) shown above ?
How to create LVM Partition in Linux

syg00 02-13-2015 07:43 PM

Why not a step 3 ?.

And more to the point, why are you using a partition at all ?. Simply run pvcreate against the device node - no partition needed. Save you all that apparent angst.

veerain 02-14-2015 03:05 AM

Quote:

Originally Posted by tesla75 (Post 5316504)
Step2. create a primary partition that starts after 1mb (to ensure proper alignement)
parted -s /dev/sda unit mib mkpart primary 1 100%

Did you see output of running 'parted --help'.

You can use:

Code:

parted -s /dev/sda set 1 lvm on
Set 1 to your partition number. It works non-interactively also.


All times are GMT -5. The time now is 06:59 PM.