1.关闭你的虚拟机系统

找到如下内容:选择"Edit Virtual mache settings”
点击"Expand“
扩大虚拟机的空间为"60G"(根据个人需要填写空间大小)。但是linux下面并不可见。

2.使用linux下的fdisk工具进行分区

用root用户登录到你的linux系统,查看你系统的分区

# fdisk -l
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x00008d26Device 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 LVMDisk /dev/mapper/VolGroup-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 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: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 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
根据提示信息可以判断出此系统的磁盘接口为SCSI,对应“sda”如果上面的红色字体是“hda”,那么此系统的磁盘接口为IDE对应“hda”所以我做一下操作:
# fdisk /dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): m //列出fdisk的帮助
Command actiona   toggle a bootable flagb   edit bsd disklabelc   toggle the dos compatibility flagd   delete a partitionl   list known partition typesm   print this menun   add a new partitiono   create a new empty DOS partition tablep   print the partition tableq   quit without saving changess   create a new empty Sun disklabelt   change a partition's system idu   change display/entry unitsv   verify the partition tablew   write table to disk and exitx   extra functionality (experts only)
Command (m for help): n    //命令n用于添加新分区
Command actione   extendedp   primary partition (1-4)
p  //选择创建主分区"此时
Partition number (1-4): 3  //fdisk会让你选择主分区的编号,如果已经有了主分区sda1,sda2,那么编号就选3,即要创建的该分区为sda3
First cylinder (2611-7832, default 2611): //此时,fdisk又会让你选择该分区的开始值这个就是分区的Start 值(start cylinder);这里最好直接按回车
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832): //此时,fdisk又会让你选择该分区的开始值这个就是分区的End 值这里最好直接按回车
Using default value 7832Command (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.

3.我们的新建分区/dev/sda3,却不是LVM的。所以,接下来使用fdisk将其改成LVM的

# fdisk /dev/sda
Command (m for help): m
Command (m for help): t //改变分区系统id
Partition number (1-4): 3 //指定分区号
Hex code (type L to list codes): 8e //指定要改成的id号,8e代表LVM
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w

4.重启系统后,登陆系统。(一定要重启系统,否则无法扩充新分区)

5.格式化该新添加的分区

# fdisk -l
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x00008d26Device 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
/dev/sda3            2611        7832    41939020   8e  Linux LVMDisk /dev/mapper/VolGroup-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 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: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 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
你会发现多了一块分区
# mkfs -t ext3 /dev/sda3 //在硬盘分区“/dev/sda3”上创建“ext3”文件系统
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10484755 blocks
524237 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

此时我们就可以使用该新增分区啦:

6.扩充新分区

# lvsLV      VG       Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convertlv_root VolGroup -wi-ao---- 17.57glv_swap VolGroup -wi-ao----  1.94g
# pvcreate /dev/sda3Physical volume "/dev/sda3" successfully created
# pvcreate /dev/sda3 //pvcreate指令用于将物理硬盘分区初始化为物理卷,以便被LVM使用。要创建物理卷必须首先对硬盘进行分区,并且将硬盘分区的类型设置为“8e”后,才能使用pvcreat指令将分区初始化为物理卷Physical volume "/dev/sda3" successfully created
# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   18G  1.7G   15G  10% /
tmpfs                         1.9G     0  1.9G   0% /dev/shm
/dev/sda1                     485M   32M  428M   7% /boot
# vgextend /dev/mapper/VolGroup-lv_root /dev/sda3    //其中是当前需要扩充的lvm组名,可以通过df -h查看,例如我的是: /dev/mapper/VolGroup-lv_root) //vgextend指令用于动态的扩展卷组,它通过向卷组中添加物理卷来增加卷组的容量Volume group name VolGroup/lv_root has invalid characters
# vgextend /dev/mapper/VolGroup /dev/sda3    //原来这个组名,是-之前的字符串——这要是没有文章看着对比分析,谁知道啊?Volume group "VolGroup" successfully extended
#vgdisplay    //用于显示LNM卷组的元数据信息--- Volume group ---VG Name               VolGroupSystem IDFormat                lvm2Metadata Areas        2Metadata Sequence No  4VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                2Open LV               2Max PV                0Cur PV                2Act PV                2VG Size               59.50 GiBPE Size               4.00 MiBTotal PE              15232Alloc PE / Size       4994 / 19.51 GiBFree  PE / Size       10238 / 39.99 GiBVG UUID               Ecv3ml-86eg-LTsH-mALD-mLxW-v3Ao-GEqiFc

(主要查看Free PE / Size 10238 / 39.99 GiB,说明我们最多可以有39.99GB的扩充空间。我一般选择小于等于39.99GB)

# lvextend -L +39.99G /dev/VolGroup/lv_root /dev/sda3Rounding size to boundary between physical extents: 39.99 GiBExtending logical volume lv_root to 57.56 GiBLogical volume lv_root successfully resized# e2fsck -f /dev/VolGroup/lv_root
e2fsck 1.41.12 (17-May-2010)
/dev/VolGroup/lv_root is mounted.
e2fsck: Cannot continue, aborting.
# resize2fs  /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/VolGroup/lv_root to 15089664 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 15089664 blocks long.
# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   57G  1.7G   53G   3% /
tmpfs                         1.9G     0  1.9G   0% /dev/shm
/dev/sda1                     485M   32M  428M   7% /boot

可以看到,这个逻辑卷已经成功的扩容,根目录又可以装更多东西了!

CentOS虚拟机根分区磁盘扩容操作相关推荐

  1. CentOS虚拟机根分区磁盘扩容纪实

    作者:fbysss QQ:溜酒酒吧酒吧吾散 blog:blog.csdn.net/fbysss 声明:本文由fbysss原创,转载请注明出处 ============================= ...

  2. cwntos新建目录挂载磁盘_详解Linux磁盘挂载、分区、扩容操作的实现方法

    概述 今天主要分享下关于Linux磁盘挂载.分区.扩容操作的实现方法,先介绍下基本概念 1.磁盘 在Linux系统中所有的设备都会以文件的形式存储.设备一般保存在/dev目录下面,以sda.sda1. ...

  3. 详解:Hyper-V虚拟主机数据磁盘扩容

    一直以来对Hyper-V Linux虚拟主机的磁盘扩容困扰,今天将介绍如何利用 fdisk 和 resize2fs 进行数据磁盘扩容. 情况说明: 宿主机系统:Windwos Server 2012 ...

  4. linux(虚拟机) ext4系统磁盘扩容操作(磁盘多个分区,扩张分区大小扩张物理卷大小来扩容逻辑卷)

    目录 ext4文件系统磁盘扩容 目标 途径 操作步骤 改变前的现状 操作和改变后的状态 ext4文件系统磁盘扩容 一个磁盘有多个分区,分别创建了物理卷.卷组.逻辑卷.通过虚拟机软件对虚拟机的磁盘/de ...

  5. linux(虚拟机) ext4系统磁盘扩容操作(磁盘多个分区,新增分区新增物理卷来扩容逻辑卷)

    目录 ext4文件系统磁盘扩容 目标 途径 操作步骤 改变前的现状 操作和改变后的状态 ext4文件系统磁盘扩容 一个磁盘有多个分区.分别创建了物理卷.卷组.逻辑卷.通过虚拟机软件对虚拟机的磁盘/de ...

  6. 银河麒麟服务器操作系统虚拟机根分区扩容

    一.在vmware上为麒麟系统虚拟机扩展存储 二.在麒麟系统上扩充 1.打开终端,执行命令: df -hT 查看磁盘情况,发现新扩展的空间并没有加载上. 2.输入 fdisk -l 查看系统当前磁盘分 ...

  7. 在阿里云进行磁盘扩容操作后,ECS实际使用磁盘并没有扩容?阿里云ECS磁盘扩容操作

    阿里云ECS磁盘扩容 在阿里云对ECS进行磁盘扩容. 在线磁盘扩容 查看实例的云盘情况 fdisk -lu 确认已有分区的文件系统类型 df -Th 检查到我的系统盘在 /dev/vda1 安装工具 ...

  8. LINUX分区空间扩容操作

    前言:前期搭建了一个linux服务器用于业务测试,硬盘空间划分的比较小,随着测试系统功能的逐步壮大,硬盘空间显得捉襟见肘,这就需要进行扩容.在扩容过程中需要停机重启服务器,建议保存备份重要数据文件. ...

  9. resize2fs对未分区磁盘的扩容

    当服务器数据太多的时候,硬盘不足的时候就得考虑扩容,为了不影响业务的正常运行,一般云服务器的本地磁盘都是不支持分区的,因为业务数据通常是不能中断和移动的,无论是增加硬盘或在原有磁盘增加分区的方式扩容, ...

最新文章

  1. 存储过程能用if not exist_C++核心准则T.48:如果不能用概念,用enable_if
  2. dapr微服务.net sdk入门
  3. python判断密码强度_python – 检查密码的强度(如何检查条件)
  4. 76岁“爷爷考生”第5次备战研究生考试
  5. BGP基本配置(GNS3)
  6. utf—8在苹果手机上乱码_Xcode下的中文乱码问题
  7. SQLPro Studio for Mac(数据库管理器)2022.14
  8. redis 加载mysql_Mysql Redis PostgreSQL数据库查看客户端连接
  9. python ipaddr库_python访问纯真IP数据库的代码
  10. 阿里巴巴大数据将帮助法院办案
  11. android 转音频格式,android_Lame转换音频格式
  12. hadoop+Spark实战基于大数据技术之电视收视率企业项目实战
  13. 山一程,水一程,身向榆关那畔行,夜深千帐灯。
  14. sklearn.datasets.make_blobs 生成符合高斯分布的点
  15. 小米手机安装推特后频繁闪退
  16. 复读机java群管脚本_JS让浏览器实现复读机的功能_js
  17. 逐渐告别尴尬“测速期”,英特尔展示 5G 多领域应用
  18. e3mall商城的归纳总结1之项目的架构
  19. [深入理解Android卷一全文-第七章]深入理解Audio系统
  20. Excel VBA编写excel数据汇总宏命令

热门文章

  1. nodex 解决跨哉请求的解决方案express
  2. LP框架| 三分钟快速构建分布式微服务系统(一)
  3. 计算机网络—数据交换方式
  4. Android N混合编译与对热补丁影响解析
  5. 3208点阵时钟c语言程序,点阵万年历(带时间、年月日星期调整及闹钟功能)C程序...
  6. Slwave运行仿真时被终止,没有出现提示错误。
  7. 开启CSDN消息免打扰
  8. 网络流量一对多镜像配置
  9. 3000字告诉你如何渡过程序员菜鸟时期
  10. 2024年上海美博会-上海浦东美博会(上海CBE)