mark:
https://www.cnblogs.com/Sungeek/p/9084510.html
fdisk
分区:
[root@localhost]# fdisk /dev/sda
p 查看已分区数量(我看到有两个 /dev/sda1 /dev/sda2)
n 新增加一个分区
p 分区类型我们选择为主分区
分区号输入3(因为1,2已经用过了,sda1是分区1,sda2是分区2,sda3分区3)
回车 默认(起始扇区)
回车 默认(结束扇区)
t 修改分区类型
选分区3
8e 修改为LVM(8e就是LVM)
w 写分区表
q 完成,退出fdisk命令
root@localhost:~# fdisk /dev/sda 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): p Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x0000e4bc Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 25593855 12591104 8e Linux LVM 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): 3 First sector (25593856-62914559, default 25593856): Using default value 25593856 Last sector, +sectors or +size{K,M,G} (25593856-62914559, default 62914559): Using default value 62914559 Partition 3 of type Linux and of size 17.8 GiB is set Command (m for help): t Partition number (1-3, default 3): 3 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.
添加新LVM到已有的LVM组,实现扩容
lvm 进入lvm管理
lvm>pvcreate /dev/sda3 这是初始化刚才的分区3
lvm>vgextend centos /dev/sda3 将初始化过的分区加入到虚拟卷组centos (卷和卷组的命令可以通过 vgdisplay )
lvm>vgdisplay -v或者vgdisplay查看free PE /Site
lvm>lvextend -l+6143 /dev/mapper/centos-root 扩展已有卷的容量(6143 是通过vgdisplay查看free PE /Site的大小)
lvm>pvdisplay 查看卷容量,这时你会看到一个很大的卷了
lvm>quit 退出
上面只是卷扩容了,下面是文件系统的真正扩容,输入以下命令:
CentOS7下面由于使用的是XFS命令:
/dev/mapper/centos-root是df -h查看到根目录的挂载点
xfs_growfs /dev/mapper/centos-root
CentOS6使用命令:
resize2fs /dev/mapper/centos-root
查看新的磁盘空间:
df -h