首页 技术 正文
技术 2022年11月20日
0 收藏 932 点赞 3,247 浏览 2231 个字

操作之前需要重点查看:

由于扩容磁盘的操作非同小可,一旦哪一步出现问题,就会导致分区损坏,数据丢失等一系列严重的问题,因此建议:在进行虚拟机分区扩容之前,一定要备份重要数据文件,并且先在测试机上验证以下步骤,再应用于您的生产机器。如果虚拟机的磁盘不够用了,建议附加新磁盘进行使用,不到万不得已一般不要扩容磁盘分区。

操作环境:

[root@hlmcen73n1 sdc1]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

1.关闭虚拟机

备注:扩容磁盘需要关闭虚拟机,否则无法调整磁盘的大小

2.调整磁盘的大小(示例中将原来的1023G调整为了2047G)

3.启动虚拟机,查看到整块磁盘已经变为2047G,但/dev/sdc1分区还是1023G

4.使用命令:fdisk /dev/sdc,重新划分分区/dev/sdc1

[root@hlmcen73n1 sdc1]# fdisk /dev/sdc

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): p         ##查看目前的分区信息

Disk /dev/sdc: 2197.9 GB, 2197949513728 bytes, 4292870144 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: 0x1b9a454e

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1            2048  2145386495  1072692224   83  Linux

Command (m for help): d         ##将原来的/dev/sdc1分区删除

Selected partition 1

Partition 1 is deleted

Command (m for help): n               ##重新创建分区

Partition type:

p   primary (0 primary, 0 extended, 4 free)

e   extended

Select (default p): p

Partition number (1-4, default 1):

First sector (2048-4292870143, default 2048): 2048  ##该值需要与上述标黄的start值相同

Last sector, +sectors or +size{K,M,G} (2048-4292870143, default 4292870143):

Using default value 4292870143

Partition 1 of type Linux and of size 2 TiB is set

Command (m for help): p

Disk /dev/sdc: 2197.9 GB, 2197949513728 bytes, 4292870144 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: 0x1b9a454e

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1            2048  4292870143  2146434048   83  Linux

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.

5.使用fdisk –l查看/dev/sdc1已经变为了2047G,但使用df –h查看/dev/sdc1还是1023G

6.此时拉伸文件系统的话,会提示如下。需要重启电脑以便重读分区表后,才能成功拉伸文件系统

7.重启电脑后,重新使用命令:resize2fs拉伸文件系统,可以看到可以成功拉伸文件系统

8.重新挂载使用,已发现/dev/sdc1成功拉伸为了2047G(2T),并且之前的数据文件仍然正常存在。

[root@hlmcen73n1 ~]# mount /dev/sdc1 /mnt/sdc1/

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898