使用情况:

1. 虚拟机配置150G硬盘,初始化为/dev/sdb1,后因为磁盘空间不够使用,动态扩容至300G,扩容完成后,想要动态扩容/dev/sdb1分区。

2. 磁盘空间300G,之前分区只划分150G的/data分区,现在/data不够使用,想要把剩余150G容量动态增加到之前/data分区,并且保证/data数据不损坏

操作(以/data为例):

1.  关闭/data分区使用的服务

2. 卸载磁盘

使用umount命令卸载正在使用的/data磁盘

umount -l /data
若遇到磁盘繁忙,可以使用fuser查看正在使用磁盘的程序。
fuser -mv /data
手工退出或关闭占用文件的用户或程序。或者采用如下交互式命令强制kill掉使用/data进程
fuser -mvik /data
fuser命令参数含义:

-m     name specifies a file on a mounted file system or a block device that is mounted. All processes accessing files  on  that  file system  are  listed.  If a directory file is specified, it is automatically changed to name/. to use any file system that might be mounted on that directory.
-c Same as -m option, used for POSIX compatibility.
-V Display version information.
-k Kill processes accessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never kills itself, but may kill other fuser processes. The effective user ID of the process executing fuser is set to its real user ID before attempting to kill.
-i Ask the user for confirmation before killing a process. This option is silently ignored if -k is not present too.

3. 磁盘分区

使用fdisk命令重新调整磁盘分区大小。删除之前的分区,然后建立新分区。开始的磁柱号要和原来一致(否则会导致数据丢失),结束的磁柱号默认使用全部空间。

fdisk -cu /dev/sdb

p            #查看磁柱号 ,记住,后面要用到
d #删除之前的分区
n #建立新分区
p #主分区
#第一个主分区
wq #保存退出

4. 调整分区文件系统

e2fsck -f /dev/sdb1                  #检查分区信息
resize2fs /dev/sdb1 #调整分区文件系统 命令含义:
e2fsck - check a Linux ext2/ext3/ext4 file system
e2fsck is used to check the ext2/ext3/ext4 family of file systems. For ext3 and ext4 filesystems that use a journal, if the system
has been shut down uncleanly without any errors, normally, after replaying the committed transactions in the journal, the file system
should be marked as clean. Hence, for filesystems that use journalling, e2fsck will normally replay the journal and exit, unless its
superblock indicates that further checking is required.
resize2fs -   ext2/ext3/ext4 file system resizer
The resize2fs program will resize ext2, ext3, or ext4 file systems. It can be used to enlarge or shrink an unmounted file system
located on device. If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel
supports on-line resizing. (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 and
ext4.). 如果采用虚拟机动态增加磁盘方式,需要重新通知内核分区表变化或者重启设备
partprobe /dev/sdb partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system
re-read the partition table.

5. 重新挂载文件系统

手工挂载/data目录
mount /dev/sdb1 /data 如果想要重启后自动挂载目录,需要在/etc/fstab增加下边的配置
/dev/sdb1 /data ext4 defaults

CentOS使用fdisk扩展磁盘空间的更多相关文章

  1. VirtualBox下Linux(centos)扩展磁盘空间

    最近在Linux里做文件合并,做分词,磁盘空间不够,把扩展磁盘空间方法记录一下. 1.在VirtualBox安装路径下(例如C:\Program Files\Oracle\VirtualBox> ...

  2. VMwave下Ubuntu扩展磁盘空间

    VMwave下Ubuntu扩展磁盘空间 Ubuntu原预装磁盘空间20G,随着系统安装软件越来越多,空间慢慢不够用. 打算安装DB2,许扩展磁盘空间. 环境: No LSB modules are a ...

  3. Centos7在虚拟机中扩展磁盘空间

    说明 情况:已经在VirtualBox虚拟机创建了一个磁盘并已经装好了系统,发现磁盘空间太小,需要再添加一个磁盘的大小.或者说Centos7系统需要扩展磁盘空间. 步骤 1.VirtualBox新建磁 ...

  4. kvm虚拟机扩展磁盘空间

    kvm虚拟机磁盘空间扩展与xen虚拟机磁盘空间扩展思路一致.原因在于xen/kvm默认的虚拟机磁盘格式为raw,所以方式可以通用. raw磁盘格式扩展思路如下 (1) 新添加一块raw格式的磁盘加入到 ...

  5. virtualBox下Centos系统扩展磁盘空间

    (1)查看空间容量: 打开windows命令终端.然后打开virtualbox安装目录,找到VBoxManage.exe,拖动到终端里面.输入命令:list hdds,回车. 我安装的位置是 : C: ...

  6. centos虚拟机扩展磁盘空间(经历无数坑,血一样总结,史上最全)

    第一步 在vmware中将虚拟机关机后,鼠标右键设置,直接点击扩展加自己想要扩展的数量就可以了,这个比较简单不多说. 2 第二步 设置后进系统查看空间大小变化,实际并没有什么变化,我用的命令是df - ...

  7. 虚拟机vmware centos7 扩展磁盘空间

    0.思路 创建一个新的逻辑分区,将新的逻辑分区格式化ext3(或其他类型)的文件系统,mount到磁盘空间不够的文件系统,就跟原来的分区/文件系统一样的使用 1.准备 1.1 注意使用VMware自带 ...

  8. Centos7扩展磁盘空间(LVM管理)

    vmware或hyperv,扩容磁盘,本例中使用的是vmware,关闭系统,在vmware—>设置—>硬盘—>扩展—>输入数字大于当前系统内存—>点击扩展,如图: 1.  ...

  9. 给VMware下的Linux扩展磁盘空间(以CentOS6.5为例)

    #查看挂载点:df -h#显示: 文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/vg_dc01-lv_root47G 12G 34G 25% /tmpfs 504M 88K 50 ...

随机推荐

  1. NavigatorIOS

    使用 NavigatorIOS,我们需要给他指定一个路由,这样它才能知道显示哪个页面 实例化 Navigator 需要2个必要的属性 —— initialRoute 和 renderSence,它们的 ...

  2. Navigator导航器

    import React, { Component } from 'react';import { Platform, StyleSheet, Text, View, Navigator, Touch ...

  3. 基础篇:6.2)形位公差-符号 Symbol

    本章目的:了解定义形位公差的符号. 1.公差特征项目的符号(GM新标准) //形位公差共:5类14个,4,2,3,3,2. 2.附加符号(GM新标准) //①基本尺寸(理论尺寸)没有公差,无需检验(不 ...

  4. HDFS 删除大量文件

    hdfs dfs -find <path> | xargs -n 1000 hdfs dfs -rm -skipTrash

  5. oracle闪回(flashback)的部分实用操作(彻底删除的除外)

    一.数据delete并且commit提交之后的闪回 (一):根据时间来恢复:1.查询数据库当前时间(目的是为了检查数据库时间是否与你电脑时间相近,避免时间不同而将数据恢复到错误时间点)select  ...

  6. Java 抽象类的简单使用

    自己做的一点笔记... 抽象类:使用关键词 abstract 进行修饰,抽象类不能生成对象(实例化),且含有抽象方法(使用 abstract 进行声明,并且没有方法体). 特点: 1️⃣  抽象类不一 ...

  7. sencha touch dataview 中添加 button 等复杂布局并添加监听事件

    config 中的属性默认都会自动生成   getter   setter  applier  updater 四个方法. applier 在调用  setter 时被调用, updater 在属性值 ...

  8. windows下安装node环境,以及grunt试水笔记

    grunt,当下前端界知名度最高的工作流处理工具. 在一线的互联网公司,它早已经被用烂了,而我真正接触,是在去年年底... 期间还因为内心太杂分心玩乐而荒废学途,以致到最近才重拾学业,在这里BS一下自 ...

  9. Java Service Wrapper 发布Java程序或者jar包为Windows服务

    下载Windows版本:http://nchc.dl.sourceforge.net/sourceforge/wrapper/wrapper-windows-x86-32-3.2.3.zip 现在目前 ...

  10. Python基础(8) - 模块

    Python 模块的物理形式就是文件:一个文件对应一个模块.文件名就是模块名+.py 模块定义了自己独有的命名空间.在其定义的属性,函数,类都隶属于该空间. 通过import关键字我们可以导入模块: ...