操作过程-CentOS7下添加新硬盘扩充已经存在的逻辑卷分区的存储空间
Linux添加硬盘扩充已有分区存储空间方式
总体步骤
磁盘初始化分区
创建物理卷
扩展卷组
扩展逻辑卷
通知文件系统生效
磁盘初始化分区
[root@oracledb ~]# fdisk -l
磁盘 /dev/sda:214.7 GB, 214748364800 字节,419430400 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0000373a
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 419430399 208665600 8e Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
磁盘 /dev/sdb:1099.5 GB, 1099511627776 字节,2147483648 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: 0416CD57-7203-48B1-8D1C-6604E73EAFE5
# Start End Size Type Name
1 2048 2147483614 1024G Linux filesyste
磁盘 /dev/mapper/centos-root:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-home:151.5 GB, 151523426304 字节,295944192 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
已有磁盘200G,添加一块1T的磁盘
[root@oracledb ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:1099.5 GB, 1099511627776 字节,2147483648 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x55c66695
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 2147483647 1073740800 83 Linux
命令(输入 m 获取帮助):m
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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)
命令(输入 m 获取帮助):g
Building a new GPT disklabel (GUID: 0416CD57-7203-48B1-8D1C-6604E73EAFE5)
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:1099.5 GB, 1099511627776 字节,2147483648 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: 0416CD57-7203-48B1-8D1C-6604E73EAFE5
# Start End Size Type Name
命令(输入 m 获取帮助):n
分区号 (1-128,默认 1):
第一个扇区 (2048-2147483614,默认 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483614,默认 2147483614):
已创建分区 1
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:1099.5 GB, 1099511627776 字节,2147483648 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: 0416CD57-7203-48B1-8D1C-6604E73EAFE5
# Start End Size Type Name
1 2048 2147483614 1024G Linux filesyste
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@oracledb ~]#
执行结果
[root@oracledb ~]# fdisk -l
磁盘 /dev/sda:214.7 GB, 214748364800 字节,419430400 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0000373a
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 419430399 208665600 8e Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
磁盘 /dev/sdb:1099.5 GB, 1099511627776 字节,2147483648 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: 0416CD57-7203-48B1-8D1C-6604E73EAFE5
# Start End Size Type Name
1 2048 2147483614 1024G Linux filesyste
磁盘 /dev/mapper/centos-root:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-home:151.5 GB, 151523426304 字节,295944192 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
第二块磁盘分区已经创建,分配空间1T(全部空间)
创建物理卷
现有物理卷如下:
[root@oracledb ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <199.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 50943
Free PE 1
Allocated PE 50942
PV UUID mBYtSA-2Hzk-QXQd-cDxv-P4Mu-6tX4-UVsrUd
创建物理卷
[root@oracledb dev]# pvcreate /dev/sdb1
WARNING: ext3 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext3 signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
[root@oracledb dev]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <199.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 50943
Free PE 1
Allocated PE 50942
PV UUID mBYtSA-2Hzk-QXQd-cDxv-P4Mu-6tX4-UVsrUd
"/dev/sdb1" is a new physical volume of "<1024.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size <1024.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 1aGhki-as5k-8Eqh-Hraf-HS9x-SgZT-mij9Hz
扩展卷组
现有卷组
[root@oracledb dev]# 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 <199.00 GiB
PE Size 4.00 MiB
Total PE 50943
Alloc PE / Size 50942 / 198.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID 5BZGt4-mAIC-EAS1-o2T8-hyAD-1gXU-sG7Pwt
执行扩展
[root@oracledb dev]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
[root@oracledb dev]# 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 1.19 TiB
PE Size 4.00 MiB
Total PE 313086
Alloc PE / Size 50942 / 198.99 GiB
Free PE / Size 262144 / 1.00 TiB
VG UUID 5BZGt4-mAIC-EAS1-o2T8-hyAD-1gXU-sG7Pwt
扩展逻辑卷
现有逻辑卷
[root@oracledb dev]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID VnspUh-5yWi-xLcu-LWeK-d3Bx-YfqO-i5opYp
LV Write Access read/write
LV Creation host, time localhost, 2017-10-17 19:44:08 +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 0vTVTH-bxb8-02kQ-QWvd-yLdY-olDQ-dXacRh
LV Write Access read/write
LV Creation host, time localhost, 2017-10-17 19:44:09 +0800
LV Status available
# open 1
LV Size <141.12 GiB
Current LE 36126
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 HzVl83-V4BV-V6OA-32IE-fnPR-NPwF-4KPvk5
LV Write Access read/write
LV Creation host, time localhost, 2017-10-17 19:44:11 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
扩展/dev/centos/home卷(/home分区)
[root@oracledb dev]# lvextend -l +100%FREE /dev/centos/home
Size of logical volume centos/home changed from <141.12 GiB (36126 extents) to <1.14 TiB (298270 extents).
Logical volume centos/home successfully resized.
[root@oracledb dev]#
[root@oracledb dev]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID VnspUh-5yWi-xLcu-LWeK-d3Bx-YfqO-i5opYp
LV Write Access read/write
LV Creation host, time localhost, 2017-10-17 19:44:08 +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 0vTVTH-bxb8-02kQ-QWvd-yLdY-olDQ-dXacRh
LV Write Access read/write
LV Creation host, time localhost, 2017-10-17 19:44:09 +0800
LV Status available
# open 1
LV Size <1.14 TiB
Current LE 298270
Segments 3
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 HzVl83-V4BV-V6OA-32IE-fnPR-NPwF-4KPvk5
LV Write Access read/write
LV Creation host, time localhost, 2017-10-17 19:44:11 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
通知文件系统生效
检查文件系统类型
[root@oracledb dev]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Oct 17 19:44:14 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=d3ec0225-abeb-47ef-a209-9c1ba481bb02 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
注意,xfs文件系统使用 xfs_growfs,ext文件系统使用 resize2fs;xfs文件系统只支持增大不支持缩小
[root@oracledb dev]# xfs_growfs /dev/centos/home
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=9248256 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=36993024, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=18063, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 36993024 to 305428480
[root@oracledb dev]#
调整成功
[root@oracledb dev]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 7.8G 43G 16% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 4.0K 7.8G 1% /dev/shm
tmpfs 7.8G 9.1M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/sda1 1014M 234M 781M 24% /boot
/dev/mapper/centos-home 1.2T 2.3G 1.2T 1% /home
tmpfs 1.6G 0 1.6G 0% /run/user/1001
tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0
tmpfs 1.6G 0 1.6G 0% /run/user/1000
操作过程-CentOS7下添加新硬盘扩充已经存在的逻辑卷分区的存储空间的更多相关文章
- linux系统下添加新硬盘的方法详解
对于linux新手来说,在linux上添加新硬盘,是很有挑战性的一项工作. 在Linux服务器上把硬盘接好,启动linux,以root登陆. fdisk -l ## 这里是查看目前系统上有几块硬盘 D ...
- CentOS下添加新硬盘
1.查看新硬盘 #fdisk –l 新添加的硬盘的编号为/dev/sdb 2.硬盘分区 1)进入fdisk模式 #/sbin/fdisk /dev/sdb 2)输入n进行分 ...
- Linux下添加新硬盘,分区及挂载(转)
挂载好新硬盘后输入fdisk -l命令看当前磁盘信息,卸载硬盘分区 umount /dev/sdb 可以看到除了当前的第一块硬盘外还有一块sdb的第二块硬盘,然后用fdisk /dev/sdb 进行分 ...
- Linux下添加新硬盘,分区及挂载
挂载好新硬盘后输入fdisk -l命令看当前磁盘信息 可以看到除了当前的第一块硬盘外还有一块sdb的第二块硬盘,然后用fdisk /dev/sdb 进行分区 进入fdisk命令,输入h可以看到该命令的 ...
- 【转】Linux下添加新硬盘,分区及挂载
原文:http://blog.chinaunix.net/uid-25829053-id-3067619.html ------------------------------------------ ...
- CentOS7中添加新硬盘
cp /etc/fstab /etc/fstab.bak echo /dev/vdb1 /mnt/disk1 ext4 defaults 0 0 >> /etc/fstab mkdir ...
- CentOS系统在不重启的情况下为虚拟机添加新硬盘
一.概述 用过虚拟机的都知道,如果在系统运行的时候去给虚拟机添加一块新设备,比如说硬盘,系统是读取不到这个新硬盘的,因为系统在启动的时候会去检测硬件设备.但是我们也可能会遇到这样的情况,比如正在运行比 ...
- Android下添加新的自定义键值和按键处理流程
Android下添加新的自定义键值和按键处理流程 说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我 ...
- linux 添加新硬盘的方法
在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help) ...
随机推荐
- Maven - 实例-3-自动创建Maven目录骨架
archetype插件用于创建符合maven规定的目录骨架 方式一:根据提示设置相关参数 guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/Eclips ...
- Origin的使用问题集锦
在空间上看见同学转的一篇关于学术研究的文章,由于不常常上空间,更别说在上面看一些好的文章,所以特意将那篇文章整理到自己的博客中,方便以后做科研的时候能够用到,原文出处:http://user.qzon ...
- IOS 数据存储之 Core Data详解
Core Date是ios3.0后引入的数据持久化解决方案,它是是苹果官方推荐使用的,不需要借助第三方框架.Core Date实际上是对SQLite的封装,提供了更高级的持久化方式.在对数据库操作时, ...
- HDU 5113--Black And White(搜索+剪枝)
题目链接 Problem Description In mathematics, the four color theorem, or the four color map theorem, stat ...
- Python内置类型(4)--数值
Python有以下三种的数值类型: 整型(integers), 浮点型(floating point numbers), 以及 复数(complex numbers).此外,布尔是整数的子类型. 数值 ...
- SQL Server性能优化(10)非聚集索引的存储结构
一,新建测试表 CREATE TABLE [dbo].[Users]( ,) NOT NULL, ) NOT NULL, [CreatTime] [datetime] NOT NULL ) ON [P ...
- 使用 Portainer UI 管理 Docker 主机
Docker 使用命令行的方式来管理有时候并没有那么直观,可以使用 Portainer 的 UI 来管理 Docker 主机和 Docker Swarm 集群. 安装 Portainer 环境:cen ...
- CentOS 6.5静态IP的设置(NAT和桥接联网方式都适用)
不多说,直接上干货! 为了方便,用Xshell来.并将IP设置为静态的.因为,在CentOS里,若不对其IP进行静态设置的话,则每次开机,其IP都是动态变化的,这样会给后续工作带来麻烦.为此,我们需将 ...
- Java 动态生成 PDF 文件
每片文章前来首小诗: 今日夕阳伴薄雾,印着雪墙笑开颜.我心仿佛出窗前,浮在半腰望西天. --泥沙砖瓦浆木匠 需求: 项目里面有需要java动态生成 PDF 文件,提供下载.今天我找了下有关了,系 ...
- CentOS7用阿里云Docker Yum源在线安装Docker
一.参考文档 官方Docker安装文档:https://docs.docker.com/install/linux/docker-ce/centos 阿里云Docker安装文档:https://yq. ...