今天公司计划给服务器增加磁盘,磁盘的管理采用lvm格式
简单记录自己的操作笔记
lvm基本操作
1、fdisk -l /dev/sdb
磁盘如果还没有分区先使用fdisk分区
fdisk /dev/sdb
输入m查看帮助
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
这里我们只分一个区
输入n
Command (m for help): n
Command action
e extended
p primary partition (1-4)
输入p主分区(这里只分一个区)
一直回车即可;
partprobe 读取分区表到内核,避免开机启动消失
mkfs -t ext4 /dev/sdb1 格式化磁盘
2、lvm创建
pvcreate /dev/sdb1
pvdisplay
vgcreate VolGroup /dev/sdb1
lvcreate -L 10G /dev/VolGroup/LogVol01 +10G表示增加10G,10G创建10G
mount /dev/VolGroup/LogVol01 /u01 挂载,写入到/etc/fastab开机启动
3、lvm扩容
增加磁盘和格式化磁盘参考步骤1
pvcreate /dev/sdc1
vgextend VolGroup /dev/sdc1
vgdisplay
lvcextend -L +10G /dev/VolGroup/LogVol01
resize2fs /dev/VolGroup/LogVol01 ---重设大小,最好先umount在resize
查看打下df -ha