Site icon techbeatly

Enable LVM flag on partition using parted in Linux

Recently we have noticed some issue with one of our filesystem having issue and realized wrong flags on partition which was used as a Physical Volume (PV) in LVM (Logical Volume Management). You must properly set the lvm flag using any tool like fdisk or parted.

Open parted tool

[root@lpcl02c132 ~]# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted

Check the partitions and free space. We can see /dev/sda is already selected; otherwise you use the correct disk.

(parted) print free
Model: DELL PERC H730P Adp (scsi)
Disk /dev/sda: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 1075MB 1074MB primary xfs boot
2 1075MB 71.4GB 70.3GB primary lvm
3 71.4GB 109GB 37.6GB primary lvm
4 109GB 600GB 491GB extended
5 109GB 136GB 26.8GB logical lvm
6 136GB 137GB 1078MB logical lvm
137GB 600GB 463GB Free Space

Create a partition with xfs format.

(parted) mkpart logical xfs 137GB 317G

Check current partions; you can see the partition 7 with 180GB size which we have created just now.

(parted) print free
Model: DELL PERC H730P Adp (scsi)
Disk /dev/sda: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 1075MB 1074MB primary xfs boot
2 1075MB 71.4GB 70.3GB primary lvm
3 71.4GB 109GB 37.6GB primary lvm
4 109GB 600GB 491GB extended
5 109GB 136GB 26.8GB logical lvm
6 136GB 137GB 1078MB logical lvm
7 137GB 317GB 180GB logical
317GB 600GB 283GB Free Space

Enable lvm flag on partiton 7

(parted) set 7 lvm on

Verify lvm flags

(parted) print free
Model: DELL PERC H730P Adp (scsi)
Disk /dev/sda: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 1075MB 1074MB primary xfs boot
2 1075MB 71.4GB 70.3GB primary lvm
3 71.4GB 109GB 37.6GB primary lvm
4 109GB 600GB 491GB extended
5 109GB 136GB 26.8GB logical lvm
6 136GB 137GB 1078MB logical lvm
7 137GB 317GB 180GB logical lvm
317GB 600GB 283GB Free Space

That’s all.

Exit mobile version