LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-13-2015, 08:51 AM   #1
tesla75
LQ Newbie
 
Registered: May 2013
Posts: 15

Rep: Reputation: Disabled
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
 
Old 02-13-2015, 08:43 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,284

Rep: Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165
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.
 
1 members found this post helpful.
Old 02-14-2015, 04:05 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by tesla75 View Post
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.

Last edited by veerain; 02-14-2015 at 04:06 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rebuild partitions/label from existing partitions - used parted on wrong drive zedmelon Linux - Software 4 07-26-2013 04:42 PM
[SOLVED] the LVM concept freaks me out so I want out and create partitions to my own logic aletta Linux - Newbie 9 02-02-2012 11:03 PM
LXer: Back Up (And Restore) LVM Partitions With LVM Snapshots LXer Syndicated Linux News 0 04-17-2007 12:16 PM
LVM versus parted scott.anderson Linux - Software 0 07-19-2005 10:28 AM
Create software RAID partitions first, then create filesystem partitions on top of th stefanlasiewski Linux - Software 1 04-28-2004 05:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration