大网数据广告活动
服务器运维问答

Trying to increase centos-root partition size to consume full SSD capacity

· 52CE 我爱测

I have cent-os 7 installed on an ssd with capacity 160GB. The Cent-os partitions only consume 20GB in total, such that when I run fdisk -l this is my output: Disk /dev/sda: 171.8 GB, 171798691840 bytes, 335544320 sectors Units = …

问题原文

原帖链接 · ugotchi · CC BY-SA 3.0

I have cent-os 7 installed on an ssd with capacity 160GB. The Cent-os partitions only consume 20GB in total, such that when I run fdisk -l this is my output:

Disk /dev/sda: 171.8 GB, 171798691840 bytes, 335544320 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: 0x000a2b1e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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-root: 18.8 GB, 18798870528 bytes, 36716544 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

When I try to run pvs I get the following:

  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  19.51g    0

What steps do I need to take in order to get CentOS to recognise the full 160GB physical volume, and then be able to either extend centos-root directly or first create another logical partition (of size 140GB), remove it and then allow centos-root to expand into the that space?

Apologies if my terminology is incorrect, I'm not a Linux expert.

社区高分解答

原帖链接 · Vikelidis Kostas · CC BY-SA 3.0

Your physical volume is 19.51g with no free space (pvs results). So you first have to resize the physical volume.

pvresize /dev/sda2

Then you need to resize the logical volume centos-root to fill all the free space.

lvresize -l +100%FREE /dev/mapper/centos-root

Now its time for the filesystem. Its not obvious what filesystem you are using but i bet that its either ext4 or xfs.

In the first case:

resize2fs /dev/mapper/centos-root

In the second case:

xfs_growfs /

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-09-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。