0

I have been tasked with configuring newly attached disks with a specific configuration. I am given a 500G physical disk at /dev/abc. The disk is not formatted and has no paritions. The following is an example of the desired configuration, with the desired partition, volume group (VG), and logical volumes (LVMs). The LVMs also need to be ready to mount using /etc/fstab, so I believe they need to be formatted using either makefs or a similar command.

What is the series of commands to create the desired configuration, which should be executed on a Cent OS 7.9 server?

Desired Configuration

root@server1# pvs 
  PV          VG                Fmt  Attr PSize    PFree
  /dev/abc1   testvg            lvm2 a--  <500.00g 55.00g

root@server1# vgs
  VG                #PV #LV #SN Attr   VSize    VFree
  testvg              1   4   0 wz--n- <500.00g 55.00g

root@server1# lsblk -f --output NAME,KNAME,FSTYPE,MOUNTPOINT,LABEL,UUID,PARTLABEL,PARTUUID,SIZE,ALIGNMENT,MIN-IO,OPT-IO,TYPE,WWN,TRAN,VENDOR /dev/abc
NAME                        KNAME  FSTYPE      MOUNTPOINT      LABEL UUID                                   PARTLABEL PARTUUID  SIZE ALIGNMENT MIN-IO OPT-IO TYPE WWN TRAN VENDOR
abc                         abc                                                                                                 500G         0    512      0 disk
└─abc1                      abc1   LVM2_member                       vxAeBC-QNSY-ProJ-csGC-YPT0-weMg-YCDy2Y                     500G         0    512      0 part
  ├─testvg-test_home        dm-275 xfs         /test/home            495f1d16-a4de-42bf-b26d-4d3152daacb5                       350G         0    512      0 lvm
  ├─testvg-test_kourier     dm-276 xfs         /test/apps            e055ecb9-2248-4aec-bdd1-5fa096aebf7e                        50G         0    512      0 lvm
  ├─testvg-test_debuglogs   dm-277 xfs         /test/debuglog        b95779d3-95b1-4b14-80f8-5b84071a6021                        25G         0    512      0 lvm
  └─testvg-test_usr2        dm-278 xfs         /test/usr2            994bc5e6-5d4a-4690-a0e9-72cd227b5e83                        20G         0    512      0 lvm

Based on what I have read in the man pages, I believe the following are some of the first commands, which should be executed. But, I would appreciate any feedback or correction. And I believe the command lvcreate should be executed next, but I am not entirely sure.

root@server1# parted /dev/abc   mklabel msdos
root@server1# parted /dev/abc   mkpart primary ext4 32.3K 537G
root@server1# pvcreate /dev/abc
MikeyE
  • 127
  • 1
  • 10

1 Answers1

2

You need to create a volume group (vgcreate ...) first, and then you carve logical volumes (LVs) out of the volume group (VG) using lvcreate.

But first: there's no reason to create a partition table on this disk if you're consuming the entire disk for LVM. Just make a physical volume (PV) out of the entire disk:

pvcreate /dev/abc

(You can of course go ahead and create a partition and use /dev/abc1 instead in the pvcreate command (and the following vgcreate command), but you don't need to.)

Next, create a volume group (VG) that includes that PV:

vgcreate testvg /dev/abc

And then start carving out your logical volumes (LVs):

lvcreate -n test_home -L350G testvg
lvcreate -n test_kourier -L50G testvg
lvcreate -n test_debuglogs -L25G testvg
lvcreate -n test_usr2 -L20G testvg

DigitalOcean has some documentation that might help out.

At this point, you've created the block devices. You'll need to format them using mkfs.xfs, and arrange to mount them in the appropriate locations by editing /etc/fstab.

larsks
  • 43,623
  • 14
  • 121
  • 180