Format And Mount local2
Format Disk
Do these commands as root:
- fdisk -l
- Find disks/RAID disks to format
- parted
- mklabel gpt
- mkpart logical 0GB 9995GB. (based on what we read in result of print above)
- print. (to confirm)
- quit
Mount storage disks using LVM
Reference guide: https://www.thegeekdiary.com/redhat-centos-a-beginners-guide-to-lvm-logical-volume-manager/
1. Scan devices to be used as physical volumes (PV)
lvmdiskscan
2. Initialize the block devices
pvcreate <drive1> <drive2> <...> ... example: pvcreate /dev/sdb /dev/sdc /dev/sdd
3. To double check PV
pvdisplay pvscan pvs
4. After PV, create a Volume Group (VG)
vgcreate <name of volume> <drive1> <drive2> <...> ... example: vgcreate soft2 /dev/sdb /dev/sdc /dev/sdd
5. To double check VG
vgs <VG name> vgdisplay <VG name>
6. After VG, create a Logical Volume (LV)
lvcreate <options> <name of LV> <VG Name> example: lvcreate -l 100%FREE -n soft_lv soft2 "-l" is for storage space in percent, 100%FREE means use all space in VG "-n" is for name of LV
7. Double Check LV
lvs /dev/<VG NAME>/<LV NAME> lvdisplay /dev/<VG NAME>/<LV NAME> lvscan
8. Create a File System
mkfs.ext4 <options> /dev/<VG NAME>/<LV NAME> example: mkfs.ext4 /dev/soft2/soft_lv
9. Make the directory:
mkdir <somewhere> example: mkdir /export/soft2
10. Mount permanently:
vim /etc/fstab /dev/<VG NAME>/<LV NAME> <somewhere> <type of file system> <mount options> <dump> <fsck> example: /dev/soft2/soft_lv /export/soft2 ext4 defaults 1 2
11. Lastly, mount all
mount -a
RAID1 with LVM on fresh drives
1. Check which disk will act as the mirror
fdisk -l
2. Create physical volumes of the drives
pvcreate <disk> <disk> <disk> example: pvcreate /dev/sdz /dev/sdaa
3. Create a volume group for these drives
vgcreate <name> <disk1> <disk2> example: vgcreate local2 /dev/sdz /dev/sdaa
4. Create a logical volume with "-m1" flag to say mirror/raid1
lvcreate -l <how much of disk to use in percent> -m1 -n <name> <volume_group> example: lvcreate -l 100%FREE -m1 -n local2_lv local2
5. Mount permanently:
vim /etc/fstab /dev/<VG NAME>/<LV NAME> <somewhere> <type of file system> <mount options> <dump> <fsck> example: /dev/local2/local2_lv /local2 ext4 defaults 1 2
6. Lastly, mount all
mount -a
RAID1 with LVM on an existing used logical volume
Before starting, make sure that the disk that will mirror data is the same size or bigger than the drive being mirrored.
1. Check if the volume has free space for lvm logs. Mirror will fail if no free space available.
pvscan example output: PV /dev/sda2 VG centos lvm2 [<222.57 GiB / 0 free] PV /dev/sdb1 VG centos lvm2 [<223.57 GiB / 0 free] PV /dev/sdd1 VG local2 lvm2 [<7.28 TiB / <5.03 GiB free]
If PV /dev/sdd1 VG local2 lvm2 [<7.28 TiB / 0 free] then do
lvreduce -l -1 --resizefs /dev/<volume_group>/<logical_volume> example : lvreduce -l -1 --resizefs /dev/local2/zinc_lv
2. Check which disk will act as the mirror
fdisk -l
3. Extend the disk to volume group
vgextend <volume_group> /dev/<disk> example: vgextend local2 /dev/sdc
To remove extension:
vgreduce <volume_group> /dev/<disk> example: vgreduce local2 /dev/sdc
4. Convert current working logical volume to RAID1 and assign mirror
lvconvert -m1 /dev/<volume_group>/<logical_volume> /dev/<disk> example: lvconvert -m1 /dev/local2/zinc_lv /dev/sdc
5. It should say it was successful, to check syncing progress
lvs -a -o +devices