0

I have already partition/installed server and its partition is like following

# parted -l
Model: ATA TOSHIBA THNSNJ51 (scsi)
Disk /dev/sda: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number  Start   End    Size    Type      File system  Flags
 1      1049kB  324GB  324GB   primary
 2      324GB   405GB  80.5GB  primary                lvm
 3      405GB   406GB  1074MB  primary   xfs          boot
 4      406GB   512GB  106GB   extended
 5      406GB   512GB  106GB   logical                lvm

Following is output of lsblk

# lsblk
NAME                              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                                 8:0    0  477G  0 disk
├─sda1                              8:1    0  302G  0 part
├─sda2                              8:2    0   75G  0 part
├─sda3                              8:3    0    1G  0 part /boot
├─sda4                              8:4    0    1K  0 part
└─sda5                              8:5    0   99G  0 part
  ├─cl_m1-root                    253:0    0   89G  0 lvm  /
  └─cl_m1-swap                    253:1    0   10G  0 lvm  [SWAP]

blkid command is saying this /dev/sda5 as Type LVM2_member, which i couldnt understand

# blkid
/dev/sdb1: UUID="2019-03-18-19-33-14-00" LABEL="my" TYPE="udf" PTTYPE="dos"
/dev/sda3: UUID="eaf7cef9-4107-4d30-ac51-80e678897888" TYPE="xfs"
/dev/sda5: UUID="7x2wp0-KTva-jJ7y-copN-brui-jzJC-6gVqJc" TYPE="LVM2_member"

Now i want to create same partition with parted command but i dont know how to partition last part sda4 and sda5(/ and swap), I tried below

# setup partition table on disk
    parted -s /dev/sda mklabel msdos
    parted -s /dev/sda mkpart primary    1049k  324G 
    parted -s /dev/sda mkpart primary    324G   405G
    parted -s /dev/sda mkpart primary    405G   406G
    parted -s /dev/sda mkpart extended   406G   512G
    parted -s set 2 lvm  on
    parted -s set 3 boot on
    parted -s set 4 lvm  on

I am new to sys admin stuff, excuse if i missed some obvious point

ImranRazaKhan
  • 115
  • 2
  • 13

2 Answers2

1

Read Logical Volume Manager documentation. The partitions flagged as lvm are physical volumes, containing logical volumes.

Partitioning is not needed for most LVM using systems. Let the installer carve out a /boot partition, then create and extend volume groups with entire disks.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32
0

I run following to achieve it

part /boot --fstype=xfs  --onpart=/dev/sda3
part pv.192 --onpart=/dev/sda5 --size 1 --grow
volgroup centos pv.192
logvol /     --fstype="xfs"   --name=root --vgname=centos --percent=90 --grow
logvol swap  --fstype="swap"  --name=swap --vgname=centos --size=2048 --grow
TOTAL=`parted -s /dev/sda unit GB print free | grep Free | awk '{print $3}'`
parted -s /dev/sda mkpart primary xfs 1049k 324GB
parted -s /dev/sda mkpart primary xfs 324GB 405GB
parted -s /dev/sda mkpart primary xfs 405GB 406GB
parted -s /dev/sda mkpart extended 406GB ${TOTAL^^}
parted -s /dev/sda mkpart logical xfs 406GB ${TOTAL^^}
parted -s set 2 lvm  on
parted -s set 3 boot on
ImranRazaKhan
  • 115
  • 2
  • 13