[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.

Recommended Posts

[Linux] Volume configuration command
Linux command # 4
Linux command # 3
Linux command # 5
Linux command list
linux at command
[Linux] Search command
Linux command <Basic 2>
Linux [directory command]
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
[Basic] linux command
Linux [shell command]
[Linux] Command / Knowledge
My linux command
Linux command <Basic 1>
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
RedHat configuration confirmation command
Linux command cheat sheet
Linux command (sequential update)
Linux basic command memorandum
Linux command [File operation]
[Linux] Basic command summary
Linux command for self-collection
linux command error collection 1
Linux command line shortcut
manjaro linux configuration memorandum
NTP configuration memo on Linux
linux sar command CPU usage
[Linux] tar.gz compression / decompression command
What is Linux? [Command list]
Easy df command on Linux
Linux tar xz command memo
Linux Command Dictionary (for myself)
linux: create original Terminal command
[Note] Useful linux command collection
Linux command memorandum [for beginners]
Linux PC spec check command
[Linux] User / group command summary
[Infrastructure] Linux command, shell script collection
[Linux convenient command] Try inserting exa
Command to create Linux Live USB
[Linux] OS recovery with restore command
Completion of docker command on Linux
[Linux convenient command] Try inserting csview
Permission and ownership change command [Linux]
LINUX command [wc edition] Usage example
Linux command [ldconfig] LPIC learning memo
[linux] kill command to kill the process
Linux
[Linux convenient command] Try inserting bat
Linux command 16 procedure manual folder (completed)
Linux command (basic in basic) personal memo
[Linux command summary] Command list [Must-see for beginners]
[linux] Command notes that you often forget