加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

重新调整磁盘分区linux / vm的大小

发布时间:2020-12-14 03:04:45 所属栏目:Linux 来源:网络整理
导读:我运行 Linux客户端的VM Player,我想知道如何扩展磁盘?在VM播放器中,我提供了更多的磁盘空间,但我不确定如何将新的磁盘空间安装/扩展/连接到系统. 我的旧磁盘空间是14GB [root@localhost ~]# df -h /Filesystem Size Used Avail Use% Mounted on/dev/mapper
我运行 Linux客户端的VM Player,我想知道如何扩展磁盘?在VM播放器中,我提供了更多的磁盘空间,但我不确定如何将新的磁盘空间安装/扩展/连接到系统.

我的旧磁盘空间是14GB

[root@localhost ~]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       14G  4.5G  8.2G  36% /

然后我扩展了它,现在我看到sda2是新的空间?

[root@localhost ~]# fdisk -l

Disk /dev/sda: 128.8 GB,128849018880 bytes
255 heads,63 sectors/track,15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd44d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 14.5 GB,14537457664 bytes
255 heads,1767 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 6408 MB,6408896512 bytes
255 heads,779 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

我需要先安装新空间吗?

resize2fs -p /dev/mapper/VolGroup-lv_root 108849018880
resize2fs 1.41.12 (17-May-2010)
The containing partition (or device) is only 3549184 (4k) blocks.
You requested a new size of 1474836480 blocks.

 resize2fs -p /dev/mapper/VolGroup-lv_root 128849018880
resize2fs 1.41.12 (17-May-2010)
resize2fs: Invalid new size: 128849018880

[root@localhost ~]# lvextend -L+90GB /dev/mapper/VolGroup-lv_root
  Extending logical volume lv_root to 103.54 GiB
  Insufficient free space: 23040 extents needed,but only 0 available

[root@localhost ~]# lvextend -L90GB /dev/mapper/VolGroup-lv_root
  Extending logical volume lv_root to 90.00 GiB
  Insufficient free space: 19574 extents needed,but only 0 available

编辑:
所以在尝试pvcreate / vgextend后到目前为止还没有任何工作.我猜测从VM Player添加的新磁盘空间没有出现?

pvscan
  PV /dev/sda2   VG VolGroup   lvm2 [19.51 GiB / 0    free]
  Total: 1 [19.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 0 [0   ]

解决方法

如前所述,您首先要调整包含逻辑卷的分区的大小,而不是继续调整LVM大小.跟着这些步骤:

>使用fdisk -l -u / dev / sda记下当前分区设置(尤其是起始扇区)
>删除分区sda2并重新创建它.使用相同的起始扇区,否则您将丢失数据!显然,最终扇区应该高于之前(fdisk默认会建议使用最后一个可用扇区,所以你可以在这里按ENTER键)
>现在运行partprobe / dev / sda或重启系统.这将通知内核分区大小已更改
>运行pvresize / dev / sda2.这将调整物理卷结构的大小
>执行pvs和vgs以检查LVM是否正确识别了新大小
>您现在可以使用lvresize -l 100%FREE / dev / mapper / VolGroup-lv_root调整LVM卷的大小
>最后,使用resize2fs / dev / mapper / VolGroup-lv_root调整文件系统本身的大小

这些指令对增加磁盘空间(扩展卷)有效

缩小卷在概念上是相似的,但您必须从文件系统收缩开始向后执行步骤.另外,如果您使用XFS或其他无法收缩的文件系统,则无法在没有备份/还原过程的情况下调整LVM卷的大小.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读