[Linux] Volume configuration command
For when you want to create / delete FS quickly
Configuration procedure
・ Disc check
fdisk -l
### -Partition creation
```
fdisk /dev/xxxxx
```
Cut out a new partition with n
Type change with t
Reflected by w
Delete partition with d
Show current partition with p
A partition with a disk name numbered from 1 is created.
・ PV creation / confirmation
pvcreate /dev/xxxx1
pvdisplay
If not, install lvm2
・ VG creation / confirmation
vgcreate vg_xxxx /dev/xxxx1
vgdisplay
vgcreate vg_xxxx /dev/xvdc1 /dev/xvde1 /dev/xvdf1
By doing so, one VG can be created from multiple PVs.
・ LV creation / confirmation
lvcreate -n lv_xxxx -l 100%FREE vg_xxxx
or
lvcreate -n lv_xxxx -L 10G vg_xxxx
lvdisplay
Whether to allocate or specify all partition sizes.
・ FS creation / confirmation
mkfs.xfs /dev/vg_xxxx/lv_xxxx
FS type is usually xfs or ext4
·Verification
lsblk
·mount
mount /dev/mapper/vg_xxxx-lv_xxxx /mountpoint
・ Mount confirmation
df -h
・ Automatic start setting
vi /etc/fstab
# Undo procedure
### ・ Overall confirmation
```
lsblk
```
### ・ Automatic start deletion
```
vi /etc/fstab
```
### ・ Unmount
```
umount /mountpoint
```
### ・ Mount confirmation
```
df -h
```
### ・ LV deletion (FS is also deleted)
```
lvremove /dev/vg_xxxx/lv_xxxx
```
### ・ Delete VG
```
vgremove vg_backup
```
* Supplement
It cannot be deleted if there are two or more PVs assigned.
If it is composed of multiple PVs
vgreduce vg_xxxx /dev/xvde1 /dev/xvdf1
Let's remove the PV and then delete it.
・ PV deletion
pvremove /dev/xxxx1
Multiple specifications are possible
pvremove /dev/xxxx1 /dev/xxxx2 /dev/xxxx3
### -Delete partition
```
fdisk /dev/xxxxx
```
Delete partition with d
Show current partition with p
Reflected by w
·Verification
df -h
lsblk
pvdisplay
vgdisplay
lvdisplay
fdisk -l
that's all.