LVM新磁盘处理
linux新增了一块硬盘,首先通过fdisk -l查看:
然后fdisk /dev/vdb创建分区
以此输入n p
first sector和last sector默认,直接回车,输入t L
输入8e,采用LVM分区
按w保存。
然后pvcreate /dev/vdb1,vgcreate vg_vdb /dev/vdb1
lvcreate -L 1000G -n lv_u01 vg_vdb,mkfs.xfs /dev/vg_vdb/lv_u01
新建/u01目录,挂载分区mount /dev/vg_vdb/lv_u01 /u01
在/etc/fstab中添加/dev/mapper/vg_vdb-lv_u01 /u01 xfs defaults 0 0,即可。
Linux LVM分区扩容方法,可以参见https://www.eumz.com/2018-04/1461.html
二、非LVM根分区扩容步骤:
1.查看现有的分区大小
2.关机增加磁盘大小为30G
3.查看磁盘扩容后状态
lsblk
dh -TH
- 1
- 2
4.进行分区扩展磁盘,记住根分区起始位置和结束位置
5.删除根分区,切记不要保存
6.创建分区,箭头位置为分区起始位置
7.保存退出并刷新分区
partprobe /dev/sda
- 1
8.查看分区状态
9.刷新根分区并查看状态
# 这里先看自己的文件系统是xfs,还是ext4...
xfs_growfs /dev/sda3
- 1
- 2
使用 resize2fs或xfs_growfs 对挂载目录在线扩容 :
- resize2fs 针对文件系统ext2 ext3 ext4 (我在本地用ubuntu18是ext4,我用的是resize2fs /dev/sda3)
- xfs_growfs 针对文件系统xfs
部分转载地址为:https://blog.csdn.net/MANX98/article/details/129681956
parted 创建分区
parted /dev/sdb
(parted) mklabel
New disk label type? gpt
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 2879GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 2879GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart
Partition name? []? 1
File system type? [ext2]? xfs
Start? 0
End? 2662G
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 2879GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 197kB 2662GB 2662GB 1
(parted) toggle 1 lvm #给分区打lvm标签
(parted) p
Model: AVAGO MR9361-8i (scsi)
Disk /dev/sdb: 2879GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 197kB 2662GB 2662GB 1 lvm
(parted) quit
扩容LVM根分区
pvcreate /dev/sdb1
vgextend centos /dev/sdb1
lvextend -l +100%FREE /dev/centos/root
xfs_growfs /dev/centos/root