LVM stuff I found...

SamTzu

Renowned Member
Mar 27, 2009
527
17
83
Helsinki, Finland
sami.mattila.eu
#!/bin/bash
# Parted HowTo (you can easily turn this in to automated script.)
# This HowTo describes how to prepare HP server with SAS drives to use LVM.
# Asume that disk 1 has Proxmox (no mirroring) and that disk 2 will hold first VM storage.
# cciss - HP Smart Array
# Compaq Command Interface for SCSI-3 Support

# Use this command to install Parted & LVM
apt-get install parted lvm2 -y

# Use these commands to list available storage devices
# lsblk
# parted -l
# pvs
# vgs
# lvs
# cat /proc/partitions
# lsscsi

# Incase you need to remove the first partition on disk2...
# parted /dev/cciss/c0d1 rm 1
parted -s /dev/cciss/c0d1 mklabel gpt
parted -s /dev/cciss/c0d1 unit mib mkpart primary 1 100%
pvs
# Incase you need to remove the first physical volume on disk2...
# pvremove /dev/cciss/c0d1p1

# Create first physical volume
pvcreate /dev/cciss/c0d1p1
# Additional info on storage device
file -Ls /dev/cciss/c0d1p1
pvs
parted -s /dev/cciss/c0d1 set 1 lvm on
# Incase you need to remove the first volume group on disk2...
# vgremove vg_c0d1p1
vgcreate vg_c0d1p1 /dev/cciss/c0d1p1
vgs
# Incase you need to remove the first logical volume on disk2...
# lvremove -f vg_c0d1p1
lvcreate -l 90%FREE -n disk2 vg_c0d1p1
lvs
mkfs -t ext4 /dev/vg_c0d1p1/disk2
mkdir /media/disk2
mount /dev/vg_c0d1p1/disk2 /media/disk2
parted -l
lsblk

# At the fstab command prompt make sure that this line mounts the new disk2 at boot time
# /dev/vg_c0d1p1/disk2 /media/disk2 ext4 defaults 0 1
sed -i '/dev/vg_c0d1p1/disk2 /media/disk2 ext4 defaults 0 1' /etc/fstab
 
Last edited:
Wiki's is 2 general.
This is so specific that it can actually be converted to script by just changing the (RAID controller- and) drive names.
Parted is also a light year ahead of other disk managers because it can be scripted easily.