此扩展方法要求支持LVM

1、更改虚拟机配置

虚拟机->设置->硬盘->扩展磁盘容量

fdisk -l 查看,发现硬盘空间变大了

[root@thj Desktop]# fdisk -l

Disk /dev/sda: 42.9 GB,  bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x000812b5 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 8e Linux LVM Disk /dev/mapper/vg_thj-lv_root: 18.9 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x00000000 Disk /dev/mapper/vg_thj-lv_swap: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x00000000

2、创建分区

[root@thj Desktop]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u'). Command (m for help): p #查看分区表信息 Disk /dev/sda: 42.9 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x000812b5 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 8e Linux LVM Command (m for help): n #创建新的分区
Command action
e extended
p primary partition (-)
p #创建为主分区
Partition number (-):
First cylinder (-, default ):
Using default value #默认就好
Last cylinder, +cylinders or +size{K,M,G} (-, default ):
Using default value #默认就好 Command (m for help): p #查看分区表 Disk /dev/sda: 42.9 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x000812b5 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 8e Linux LVM
/dev/sda3 + 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 : 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() or kpartx()
Syncing disks.

设置完后,reboot重启系统

3、格式化分区

[root@thj Desktop]# mkfs.ext3 /dev/sda3
mke2fs 1.41. (-May-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
Stride= blocks, Stripe width= blocks
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , , , , , , , Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.

4、加入LVM,并挂载到根目录下

  • vgs 查看卷组情况
[root@thj Desktop]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_thj wz--n- .51g //有一个vg_thj卷组(此处系统不同会有所不同)
  • 创建物理卷(LVM分区),并将物理卷加入vg_thj组里
[root@thj Desktop]# lvm
lvm> pvcreate /dev/sda3 //创建一个LVM硬分区
Physical volume "/dev/sda3" successfully created
lvm> vgextend vg_thj /dev/sda3 //加入与根目录同一个LVM组
Volume group "vg_thj" successfully extended
  • 查看 lv path
[root@thj Desktop]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_thj/lv_root //root对应的lv path
LV Name lv_root
VG Name vg_thj
LV UUID FMlzw9-r8dt-2Oa1-mS0W-brnn-YsDm-g3ld5S
LV Write Access read/write
LV Creation host, time thj.localthj, -- :: +
LV Status available
# open
LV Size 17.57 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/vg_thj/lv_swap
LV Name lv_swap
VG Name vg_thj
LV UUID lLgahm-QUMF-XHiN-jZJc-F5ve-YycI-FmEVdr
LV Write Access read/write
LV Creation host, time thj.localthj, -- :: +
LV Status available
# open
LV Size 1.94 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device :
  • 扩展 lv path
[root@thj Desktop]# lvextend -L +.99G /dev/vg_thj/lv_root
Rounding size to boundary between physical extents: 19.99 GiB.
Size of logical volume vg_thj/lv_root changed from 17.57 GiB ( extents) to 37.56 GiB ( extents).
Logical volume lv_root successfully resized.
  • 重置主分区大小
[root@thj Desktop]# resize2fs /dev/vg_thj/lv_root
resize2fs 1.41. (-May-)
Filesystem at /dev/vg_thj/lv_root is mounted on /; on-line resizing required
old desc_blocks = , new_desc_blocks =
Performing an on-line resize of /dev/vg_thj/lv_root to (4k) blocks.
The filesystem on /dev/vg_thj/lv_root is now blocks long.

有时报错:

[root@thj Desktop]# lvextend -L +19G /dev/vg_thj/lv_root
Couldn't find device with uuid N0xspW-ZOct-v7pH-GHRN-G1Ck-0CnJ-ghqEKZ.
Cannot change VG vg_thj while PVs are missing.
Consider vgreduce --removemissing.
Cannot process volume group vg_thj

参考  https://blog.51cto.com/yl497103815/1180426

  • 查看扩展后的文件系统
[root@thj Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_thj-lv_root
37G 12G 24G % /
tmpfs 491M 228K 491M % /dev/shm
/dev/sda1 477M 36M 417M % /boot

虚拟机中CentOS 6.5 添加扩展分区的更多相关文章

  1. 【liunx】使用xshell连接虚拟机上的CentOS 7,使用xhell连接本地虚拟机上的Ubuntu, 获取本地虚拟机中CentOS 7的IP地址,获取本地虚拟机中Ubuntu 的IP地址,Ubuntu开启22端口

    注意,如果想用xshell去连接本地虚拟机中的linux系统,需要本地虚拟机中的系统是启动的才能连接!!!!! ============================================ ...

  2. 虚拟机中给linux 系统添加硬盘以后,进行分区挂载

    当自己虚拟机中的linux 系统硬盘不够用的时候需要添加硬盘给系统使用,所以可以通过以下的步骤实现 1.关闭自己的客户机,然后执行以下步骤 2. 上面的步骤完成以后,重点来了,下面打开客户机,执行以下 ...

  3. 虚拟机中CentOS 7下PHP环境配置

    为了简单起见,虚拟机网卡设置为桥接模式 1.yum install  httpd php 2.yum install mariadb 3.启动mariadb systemctl start maria ...

  4. 虚拟机中CentOS 7 x64图形化界面的安装

    VMware的初始设置如下: 图1 待虚拟机读取完iso,出现此界面 图2 我们主要是安装图形化界面的系统,所以在软件选择栏下如图选择: 图3 设置root密码,创建用户,等候安装完成: 图4 安装完 ...

  5. centos下使用fdisk扩展分区容量大小

    硬盘空间为20G,VMware增加磁盘大小,需要再增加10G空间 扩展完后,重启系统,再次使用fdisk -l查看,会发现硬盘空间变大了: 重新创建分区,调整分区信息 本次实验主要对/dev/sda4 ...

  6. VMware虚拟机中CentOS 7的硬盘空间扩容

    查看centos7系统挂载点信息 扩展VMWare-centos7硬盘空间 对新增加的硬盘进行分区.格式化 添加新LVM到已有的LVM组,实现扩容 1.查看centos7系统挂载点信息 df -h查看 ...

  7. VMware虚拟机中CentOS/redhat设置固定IP

    你的笔记本中的VMware中redhat或centOS系统,如果想在上面建站,而又如果你需要在家里和公司都能访问该站(至少希望你自己的笔记本能访问),那么就需要将虚拟机IP设置为固定IP了.以下介绍两 ...

  8. VM虚拟机安装CentOS 7.0添加jdk环境

    虚拟机注册码 5A02H-AU243-TZJ49-GTC7K-3C61N 安装centos系统,网络类型选择桥接网络安装完成后vi /etc/sysconfig/network-scripts/ifc ...

  9. 解决VMware虚拟机中centos 7无法上网的问题

    在WMware中安装centos 7后发现无法安装软件,开始以为是镜像服务器的问题,后来通过ping之后发现根本没办法连接到网络.由于很多设置都是默认的,并且虚拟机也是NAT模式,和电脑主机共享网络, ...

随机推荐

  1. 清北学堂—2020.1提高储备营—Day 4 morning(数论)

    qbxt Day 4 morning --2020.1.20 济南 主讲:李奥 目录一览 1.一些符号与基本知识 2.拓展欧几里得,逆元与欧拉定理 3.线性筛法与积性函数(非重点) 总知识点:数论 一 ...

  2. VM虚拟机扩展Ubuntu磁盘空间

    VM虚拟机扩展Ubuntu磁盘空间 1 环境 VMware版本号:15.0.2 build-10952284 系统:Ubuntu18.04 Ubuntu只挂载一个硬盘,无分区 /dev/sda1 2 ...

  3. 使用scrapy框架爬取图片网全站图片(二十多万张),并打包成exe可执行文件

    目标网站:https://www.mn52.com/ 本文代码已上传至git和百度网盘,链接分享在文末 网站概览 目标,使用scrapy框架抓取全部图片并分类保存到本地. 1.创建scrapy项目 s ...

  4. 【58】目标检测之YOLO 算法

    YOLO 算法(Putting it together: YOLO algorithm) 你们已经学到对象检测算法的大部分组件了,在这个笔记里,我们会把所有组件组装在一起构成YOLO对象检测算法.   ...

  5. PyCharm2019 永久激活(测试通过)

    2019.1.1 专业版 永久期限,需要下载补丁,以及配置文件 补丁地址:https://pan.baidu.com/s/16ALpz_BCXjsRkpS_PtD23A 1,下载安装pycharm程序 ...

  6. html+layui

    添加html+layui项目 先引用一个js文件 <form class="layui-form" action=""> <link href ...

  7. ZViZbsPBdS

    第一步:请在下方输入框中输入你要搬家的博客个人主页地址,需要注意格式: SegmentFault:https://segmentfault.com/u/xxxx 掘金:https://juejin.i ...

  8. 使用栅格系统和flex布局开发响应式页面源码

    响应式布局的原理xsmall <576pxsmall >=576pxmedium >=768pxlarge >=992pxxlarge >=1200px 接下来是效果图 ...

  9. webkit 技术内幕 笔记 二

    浏览器历史 80年代末-90年代初:worldwideweb(nexus) -- Berners-Lee 1993: Mosaic浏览器,后来叫网景(Netscape)--Marc Andreesse ...

  10. HDU6537

    题意 英文 做法 将\(a_i>1\)的限制去掉,定义\(g(n,k)\) 显然有\[ans=\sum\limits_{i=0}^{k}(-1)^i \binom{k}{i}g(n,k-i)\] ...