查看磁盘使用
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 18M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 48G 4.8G 44G 10% /
/dev/vda1 1014M 212M 803M 21% /boot
/dev/mapper/centos-home 24G 37M 24G 1% /home
tmpfs 799M 12K 799M 1% /run/user/42
tmpfs 799M 0 799M 0% /run/user/1001
查看可用磁盘
# fdisk -l
Disk /dev/vda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000dc289
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 167772159 82836480 8e Linux LVM
Disk /dev/mapper/centos-root: 51.3 GB, 51308920832 bytes, 100212736 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 25.1 GB, 25052577792 bytes, 48930816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
创建分区
# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (167772160-419430399, default 167772160):
Using default value 167772160
Last sector, +sectors or +size{K,M,G} (167772160-419430399, default 419430399):
Using default value 419430399
Partition 3 of type Linux and of size 120 GiB is set
Command (m for help):
修改分区
Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
重启主机
# reboot
VG
查看 VG
# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <79.00 GiB
PE Size 4.00 MiB
Total PE 20223
Alloc PE / Size 20222 / 78.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID bdtChH-hul3-Jxdj-9Fnv-LFB3-h9vK-CuuPcF
扩展 VG
# vgextend centos /dev/vda3
Physical volume "/dev/vda3" successfully created.
Volume group "centos" successfully extended
确认 VG
# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 198.99 GiB
PE Size 4.00 MiB
Total PE 50942
Alloc PE / Size 20222 / 78.99 GiB
Free PE / Size 30720 / 120.00 GiB
VG UUID bdtChH-hul3-Jxdj-9Fnv-LFB3-h9vK-CuuPcF
PV
查看 PV
# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name centos
PV Size <79.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 20223
Free PE 1
Allocated PE 20222
PV UUID AyTSDi-pW22-0FLO-5GcH-7zQP-65Fn-qX09y6
--- Physical volume ---
PV Name /dev/vda3
VG Name centos
PV Size 120.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 30719
Free PE 30719
Allocated PE 0
PV UUID 8ziWLx-jUZb-pGUn-PJX9-tStg-CyKY-WRJC6i
LV
查看 LV
# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 1xMGhi-MFKx-PRpc-iGXB-1AyU-iGIW-0X0fho
LV Write Access read/write
LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
LV Status available
# open 2
LV Size <7.88 GiB
Current LE 2016
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID inLLZg-h6au-5yKr-NbOP-yDr3-VBpe-BX3v30
LV Write Access read/write
LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
LV Status available
# open 1
LV Size 23.33 GiB
Current LE 5973
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID s09z9e-n1gA-N6wS-Nwaj-bd0s-KVD3-FRqwCf
LV Write Access read/write
LV Creation host, time localhost, 2022-10-09 20:39:29 +0800
LV Status available
# open 1
LV Size <47.79 GiB
Current LE 12233
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
创建 LV
# lvcreate -l 100%Free -n /dev/centos/data
or
# lvcreate -l 120G -n /dev/centos/data
Logical volume "data" created.
确认 LV
# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 1xMGhi-MFKx-PRpc-iGXB-1AyU-iGIW-0X0fho
LV Write Access read/write
LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
LV Status available
# open 2
LV Size <7.88 GiB
Current LE 2016
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID inLLZg-h6au-5yKr-NbOP-yDr3-VBpe-BX3v30
LV Write Access read/write
LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
LV Status available
# open 1
LV Size 23.33 GiB
Current LE 5973
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID s09z9e-n1gA-N6wS-Nwaj-bd0s-KVD3-FRqwCf
LV Write Access read/write
LV Creation host, time localhost, 2022-10-09 20:39:29 +0800
LV Status available
# open 1
LV Size <47.79 GiB
Current LE 12233
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/data
LV Name data
VG Name centos
LV UUID JXHfb5-hWzs-UP94-3F1G-xvI0-2yAY-lDv78a
LV Write Access read/write
LV Creation host, time uat-digitalreg-oss, 2023-09-21 13:34:15 +0800
LV Status available
# open 0
LV Size 120.00 GiB
Current LE 30720
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:3
格式化分区
# mkfs.xfs /dev/centos/data
meta-data=/dev/centos/data isize=512 agcount=4, agsize=7864320 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=31457280, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=15360, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
创建挂载点
# mkdir /data
查看分区UID
# blkid
/dev/vda1: UUID="817a90fc-6e73-4734-a0e5-234acbe5b5a1" TYPE="xfs"
/dev/vda2: UUID="AyTSDi-pW22-0FLO-5GcH-7zQP-65Fn-qX09y6" TYPE="LVM2_member"
/dev/mapper/centos-root: UUID="981cf489-bc87-4784-9472-bdd1330d5a1b" TYPE="xfs"
/dev/mapper/centos-swap: UUID="547a4bfd-557f-4f64-98b1-e1e4ce931923" TYPE="swap"
/dev/mapper/centos-home: UUID="f83f85b3-7b4e-42b8-a4a9-69806e455414" TYPE="xfs"
/dev/vda3: UUID="8ziWLx-jUZb-pGUn-PJX9-tStg-CyKY-WRJC6i" TYPE="LVM2_member"
/dev/mapper/centos-data: UUID="84b53504-7eaa-4e48-96e2-7dfe4bedb854" TYPE="xfs"
开机自动挂载
# echo `blkid |grep /dev/mapper/centos-data | awk '{print $2}'` /data xfs defaults 0 0 >> /etc/fstab
挂载分区
# mount -a
查看挂载
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 9.3M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 48G 4.6G 44G 10% /
/dev/vda1 1014M 212M 803M 21% /boot
/dev/mapper/centos-home 24G 37M 24G 1% /home
tmpfs 799M 12K 799M 1% /run/user/42
tmpfs 799M 0 799M 0% /run/user/1001
/dev/mapper/centos-data 120G 33M 120G 1% /data
标签:centos,VG,创建,bytes,dev,LV,lvm,512 From: https://www.cnblogs.com/wangguishe/p/17719758.html