CentOS使用fdisk扩展磁盘空间
使用情况:
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扩展磁盘空间的更多相关文章
- VirtualBox下Linux(centos)扩展磁盘空间
最近在Linux里做文件合并,做分词,磁盘空间不够,把扩展磁盘空间方法记录一下. 1.在VirtualBox安装路径下(例如C:\Program Files\Oracle\VirtualBox> ...
- VMwave下Ubuntu扩展磁盘空间
VMwave下Ubuntu扩展磁盘空间 Ubuntu原预装磁盘空间20G,随着系统安装软件越来越多,空间慢慢不够用. 打算安装DB2,许扩展磁盘空间. 环境: No LSB modules are a ...
- Centos7在虚拟机中扩展磁盘空间
说明 情况:已经在VirtualBox虚拟机创建了一个磁盘并已经装好了系统,发现磁盘空间太小,需要再添加一个磁盘的大小.或者说Centos7系统需要扩展磁盘空间. 步骤 1.VirtualBox新建磁 ...
- kvm虚拟机扩展磁盘空间
kvm虚拟机磁盘空间扩展与xen虚拟机磁盘空间扩展思路一致.原因在于xen/kvm默认的虚拟机磁盘格式为raw,所以方式可以通用. raw磁盘格式扩展思路如下 (1) 新添加一块raw格式的磁盘加入到 ...
- virtualBox下Centos系统扩展磁盘空间
(1)查看空间容量: 打开windows命令终端.然后打开virtualbox安装目录,找到VBoxManage.exe,拖动到终端里面.输入命令:list hdds,回车. 我安装的位置是 : C: ...
- centos虚拟机扩展磁盘空间(经历无数坑,血一样总结,史上最全)
第一步 在vmware中将虚拟机关机后,鼠标右键设置,直接点击扩展加自己想要扩展的数量就可以了,这个比较简单不多说. 2 第二步 设置后进系统查看空间大小变化,实际并没有什么变化,我用的命令是df - ...
- 虚拟机vmware centos7 扩展磁盘空间
0.思路 创建一个新的逻辑分区,将新的逻辑分区格式化ext3(或其他类型)的文件系统,mount到磁盘空间不够的文件系统,就跟原来的分区/文件系统一样的使用 1.准备 1.1 注意使用VMware自带 ...
- Centos7扩展磁盘空间(LVM管理)
vmware或hyperv,扩容磁盘,本例中使用的是vmware,关闭系统,在vmware—>设置—>硬盘—>扩展—>输入数字大于当前系统内存—>点击扩展,如图: 1. ...
- 给VMware下的Linux扩展磁盘空间(以CentOS6.5为例)
#查看挂载点:df -h#显示: 文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/vg_dc01-lv_root47G 12G 34G 25% /tmpfs 504M 88K 50 ...
随机推荐
- git提交代码
安装 Windows 下载安装地址 Linux 1 yum install git / apt-get install git 安装后执行,正常显示则安装正常 1 git --version 使用 生 ...
- 导出excel设置样式(Aspose.Cells)
Aspose.Cells.Style style = xlBook.Styles[xlBook.Styles.Add()];style1.Pattern = Aspose.Cells.Backgrou ...
- 数据库SQL(1)
EG1:db.LpOutputGroups.GroupBy(q => q.CalcGroupDesc).ToList().OrderByDescending(m => m.First(). ...
- golang笔记
----------- golang打包和部署到centos7. 参考:https://blog.csdn.net/qq_33230584/article/details/81536572
- leetcode有意思的题目总结
231. 2的幂 2^3=8 得 8是2的幂 判断一个整数是不是2的幂,可根据二进制来分析.2的幂如2,4,8,等有一个特点: 二进制数首位为1,其他位为0,如2为10,4为100 2&(2 ...
- [JAVA]流控及超流控后的延迟处理
流控检查(每半秒累计,因此最小留空阀值只能做到每秒2条): import java.text.SimpleDateFormat; import java.util.Date; import java. ...
- springboot 上传图片与回显
在网上找了很多例子,不能完全契合自己的需求,自行整理了下.需求是这样的:项目小,所以不需要单独的图片服务器,图片保存在服务器中任意的地方,并且可以通过访问服务器来获取图片.话不多说上代码: 1.依赖 ...
- LR自我总结的问题
1.Controller中添加负载测试时,最后运行完提示the following graph s were not created.导致最后没有数据报表生成. 解决方法:在result中将auto ...
- 阿里云CentOS环境下tomcat启动超级慢的解决方案
1 为什么会出现这个问题 Tomcat在本地服务器跑,一切都正常,但部署到阿里云上,发现启动巨慢. 经过在网上搜索,找到了原因: Tomcat 7/8都使用org.apache.catalina.ut ...
- 【javascript】jq之display:none与visible:hidden
今天学习到jquery的hide()部分时,突然有一个想法,jquery中的隐藏/显示部分的实现是给目标元素附加一个"display: none"属性,那么如果在类似于下面的布局中 ...