分享交流
合作共赢!

Linux扩展lvm管理磁盘空间方法总结

磁盘最好选择逻辑卷格式(lvm),方便后续的磁盘扩容,下面总结下lvm扩容磁盘方法:磁盘需要扩容时,只需要添加磁盘,扩容VG 、扩容LV,lvm结构图:

一、查看磁盘信息

1.在不重启服务器的前提下找到新加的磁盘

--查看主机总线号
ls /sys/class/scsi_host/

--根据查询结果生成刷新磁盘语句

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
。。。
echo "- - -" > /sys/class/scsi_host/host30/scan -- 一定写到上一查询语句查询到的最后的总线号

2.再次查看是否能看到新磁盘(看到新磁盘后进行后面的操作)

fdisk -l

3.  查看磁盘是否是lvm类型:如下图所示,磁盘管理模式为lvm,如不是,需要重新规划为lvm。

Linux 行执行命令: lsblk

二、创建新分区

1.给新磁盘分区

#fdisk /dev/sdb
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.

##输入p查看磁盘当前的分区
Command (m for help): p

Disk /dev/sdl: 5368 MB, 5368709120 bytes, 10485760 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: 0xbd2e29cb

##如下空行表示目前该磁盘未创建分区
Device Boot Start End Blocks Id System

##输入n创建分区
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
##输入p表示创建主分区(需注意一个物理磁盘若都为主分区的话,最多创建四个分区,可在创建第四个分区时指定为扩展分区)
Select (default p): p
##输入分区序号,默认为最小序号
Partition number (1-4, default 1): 
##输入分区的开始扇区,默认为磁盘未使用空间的最小扇区
First sector (2048-10485759, default 2048): 如不知道填什么,就按回车
Using default value 2048
##输入分区的结束扇区,默认为连续空间的最大扇区
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): 如不知道填什么,就按回车
Using default value 10485759
Partition 1 of type Linux and of size 5 GiB is set
##分区完毕后输入w进行分区保存
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

参考:Linux添加新硬盘,分区和设置开机自动挂载之图文教程!

注意:一定不要格式化磁盘

3.验证空间是否加上

df -h

 

温馨提示:

Linux添加新硬盘,分区和设置开机自动挂载之图文教程!

Linux系统磁盘扩容方法总结

linux不用lvm扩展文件系统

赞(0) 打赏
未经允许不得转载:琼杰笔记 » Linux扩展lvm管理磁盘空间方法总结

评论 抢沙发

评论前必须登录!

 

分享交流,合作共赢!

联系我们加入QQ群

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册