CentOS 7 根目录分区扩容
- 查看现有磁盘信息,可以看出根分区有96G
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 96G 2.0G 94G 3% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.5M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 1014M 163M 852M 17% /boot
tmpfs 396M 0 396M 0% /run/user/0
- 查看新增加的磁盘信息
- fdisk
[root@localhost ~]# fdisk -l
Disk /dev/sda: 500.4 GB, 500363689984 bytes, 977272832 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: 0x0009051f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 209715199 103808000 8e Linux LVM
Disk /dev/mapper/centos-root: 102.1 GB, 102131302400 bytes, 199475200 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 /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 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
- parted
[root@localhost ~]# parted -l
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1075MB 1074MB primary xfs boot
2 1075MB 107GB 106GB primary lvm
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 4161MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 4161MB 4161MB linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 102GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 102GB 102GB xfs
- 根据以上信息,对新增加的磁盘进行分区
[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): m
Command action
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)
Command (m for help): p
Disk /dev/sda: 500.4 GB, 500363689984 bytes, 977272832 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: 0x0009051f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 209715199 103808000 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):
First sector (209715200-977272831, default 209715200):
Using default value 209715200
Last sector, +sectors or +size{K,M,G} (209715200-977272831, default 977272831):
Using default value 977272831
Partition 3 of type Linux and of size 366 GiB is set
Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sda: 500.4 GB, 500363689984 bytes, 977272832 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: 0x0009051f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 209715199 103808000 8e Linux LVM
/dev/sda3 209715200 977272831 383778816 8e 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.
重启系统后,登陆系统。(一定要重启系统,否则可能无法继续下面的操作扩充新分区)
同时在进行下一步之前,说明一下pv、vg、lv的关系。
一个硬盘f分区组成一个pv(物理卷)
一个或者多个pv组成一个vg(卷组)
一个vg可以划分出多个lv(逻辑卷)
- 查看物理卷
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <95.12g
swap centos -wi-ao---- <3.88g
- 创建物理卷
- 格式化分区(非必需,先格式化后面创建物理卷还是会擦除)
# 查看系统的文件类型
[root@localhost ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root xfs 99688900 2028996 97659904 3% /
devtmpfs devtmpfs 2010736 0 2010736 0% /dev
tmpfs tmpfs 2022628 0 2022628 0% /dev/shm
tmpfs tmpfs 2022628 8676 2013952 1% /run
tmpfs tmpfs 2022628 0 2022628 0% /sys/fs/cgroup
/dev/sda1 xfs 1038336 166632 871704 17% /boot
tmpfs tmpfs 404528 0 404528 0% /run/user/0
# 格式化为xfs
[root@localhost ~]# mkfs.xfs /dev/sda3
meta-data=/dev/sda3 isize=512 agcount=4, agsize=23986176 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=95944704, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=46848, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
- 创建物理卷
[root@localhost ~]# pvcreate /dev/sda3
WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created.
- 查看物理卷信息
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <99.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25343
Free PE 1
Allocated PE 25342
PV UUID 00mdqs-YJl2-Oq3k-OlGb-7mbi-iTtz-HJl7cw
"/dev/sda3" is a new physical volume of "366.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 366.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 6PYry3-VIRi-7DUc-5erS-yCEo-Laxu-ZkoYPo
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <99.00 GiB
PE Size 4.00 MiB
Total PE 25343
Alloc PE / Size 25342 / 98.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID yde5y3-OOS3-UmyT-iHwv-zwJ5-yE63-9ZHI9O
- 将新增加的分区 /dev/sda3 加入到根目录分区中,也就是上面的VG Name: centos
[root@localhost ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
- 重新查看卷组信息
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 464.99 GiB
PE Size 4.00 MiB
Total PE 119038
Alloc PE / Size 25342 / 98.99 GiB
Free PE / Size 93696 / 366.00 GiB
VG UUID yde5y3-OOS3-UmyT-iHwv-zwJ5-yE63-9ZHI9O
- 进行卷扩容
- 扩容前
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 96G 2.0G 94G 3% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.5M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 1014M 163M 852M 17% /boot
tmpfs 396M 0 396M 0% /run/user/0
- 进行卷扩容
[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from <95.12 GiB (24350 extents) to <461.12 GiB (118046 extents).
Logical volume centos/root successfully resized.
- 调整卷分区大小
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=6233600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=24934400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=12175, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 24934400 to 120879104
- 最后,查看磁盘信息可以看出根目录分区大小已成功扩容。
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 462G 2.0G 460G 1% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.5M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 1014M 163M 852M 17% /boot
tmpfs 396M 0 396M 0% /run/user/0
CentOS 7 根目录分区扩容的更多相关文章
- CentOS 7系统根目录分区扩容
说明:系统版本为 Linux version 3.10.0-327.el7.x86_64 1. 查看现有磁盘信息,可以看出根分区有45G [root@DEV-CMDB-DB02 ~]# df -h F ...
- CentOS7.x系统根目录分区扩容
说明:系统版本为 Linux version 3.10.0-327.el7.x86_64 step1. 查看现有磁盘信息,可以看出根分区有45G [root@DEV-CMDB-DB02 ~]# df ...
- centOS 6.8下使用Gparted进行分区扩容
centOS 6.8下使用Gparted进行分区扩容 机器环境:windows上运行的VMware虚拟机,系统为centOS 6.8. 由于前期分区分配空间过小,无法满足后续的数据存储预期,所 ...
- Ubuntu 18.04 磁盘根目录在线扩容 & 修改分区 inode 数量
Ubuntu 18.04 磁盘根目录在线扩容 & 修改分区 inode 数量 Ubuntu 作为服务器系统使用的时候,系统盘的空间可能并不是很充裕,apt apt 着,根目录就满了.诚然, ...
- Linux 分区扩容(根分区扩容,SWAP 分区扩容,挂载新分区为目录)
请访问原文链接:https://sysin.org/blog/linux-partition-expansion/,查看最新版.原创作品,转载请保留出处. 作者:gc(at)sysin.org,主页: ...
- 从yum提示空间不足到根分区扩容
记录一次安装软件的报错 --1261065212@qq.com 1.系统版本(VMware 虚拟机) [root@ansible-admin ~]# cat /etc/redhat-r ...
- Centos 下硬盘分区的最佳方案
Centos7从零开始]Centos 下硬盘分区的最佳方案 2016年12月25日 10:09:02 浮華的滄桑 阅读数 41971 在对硬盘进行分区前,应该先弄清楚计算机担负的工作及硬盘的容量有 ...
- 双系统Ubuntu分区扩容过程记录
本人电脑上安装了Win10 + Ubuntu 12.04双系统.前段时间因为在Ubuntu上做项目要安装一个比较大的软件,导致Ubuntu根分区的空间不够了.于是,从硬盘又分出来一部分空间,分给Ubu ...
- linux根分区扩容
Linux 根分区扩容 1.fdisk –l (红线部分为新添加的硬盘) 2.磁盘格式化 3. mkfs.ext3 -T largefile /dev/sde(格式化上面的分区) 4. vgdisp ...
随机推荐
- 【Leetcode_easy】819. Most Common Word
problem 819. Most Common Word solution: class Solution { public: string mostCommonWord(string paragr ...
- sklearn.svc 参数
sklearn.svc 参数 sklearn中的SVC函数是基于libsvm实现的,所以在参数设置上有很多相似的地方.(PS: libsvm中的二次规划问题的解决算法是SMO). 对于SVC函数的参数 ...
- .Net中委托的协变和逆变详解
关于协变和逆变要从面向对象继承说起.继承关系是指子类和父类之间的关系:子类从父类继承所以子类的实例也就是父类的实例.比如说Animal是父类,Dog是从Animal继承的子类:如果一个对象的类型是Do ...
- Redis List集合 使用
列表类型(list)用于存储一个有序的字符串列表,常用的操作是向队列两端添加元素或者获得列表的某一片段.列表内部使用的是双向链表(double linked list)实现的,所以向列表两端添加元素的 ...
- Shiro加盐加密
接本人的上篇文章<Shiro认证.角色.权限>,这篇文章我们来学习shiro的加盐加密实现 自定义Realm: package com.czhappy.realm; import org. ...
- Information Cartography
作者:Dafna Shahaf 会议:ACM 2015. 研究大背景:自动化地从很大数据集中提取结构化的知识变得越来越难.在本篇文章中,我们将探索我们在文献中(25,26,27)中创立的方法来自 ...
- for i in range()
for i in range()就是python中的循环语句 有以下三种常见用法: 1.range(3) [0,3)即0,1,2 2.range(1,3) [1,3)即1,2 3.range(1,5, ...
- PostgreSql-psql命令的使用
安装好postgresql后,将路径:安装路径\bin,添加到环境变量path中,这样才有了使用psql命令的前提. 使用psql命令时,不需要进入postgresql数据库,直接在命令行使用即可,若 ...
- WUSTOJ 1283: Hamster(Java)
1283: Hamster 参考博客 wust_tanyao的博客 题目 第0个月有1对仓鼠.仓鼠的寿命是M个月,仓鼠成年后每个月生一对仓鼠(一雌一雄),问N个月后有仓鼠多少对.更多内容点此链接 ...
- Qt中容器类应该如何存储对象(最好使用对象指针类型,如:QList<TestObj*>,而不要使用 QList<TestObj> 这样的定义,建议采用 智能指针QSharedPointer)
Qt提供了丰富的容器类型,如:QList.QVector.QMap等等.详细的使用方法可以参考官方文档,网上也有很多示例文章,不过大部分文章的举例都是使用基础类型:如int.QString等.如果我们 ...