此扩展方法要求支持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. opencv —— HoughLines、HoughLinesP 霍夫线变换原理(标准霍夫线变换、多尺度霍夫线变换、累积概率霍夫线变换)及直线检测

    霍夫线变换的原理 一条直线在图像二维空间可由两个变量表示,有以下两种情况: ① 在笛卡尔坐标系中:可由参数斜率和截距(k,b)表示. ② 在极坐标系中:可由参数极经和极角(r,θ)表示. 对于霍夫线变 ...

  2. 没有正确配置扫描包,提示spring的bean不存在

    如下提示的解决方案: <!-- 扫描org.infor包下面的java文件,有Spring的相关注解的类,则把这些类注册为Spring的bean -->  <context:comp ...

  3. Notability

    Notability 上课记笔记.听网课→Notability 有录音功能, 在原来笔记中新添加空白行(选中之后下移) Notability常用的功能总结 1.纸张有颜色2.荧光笔会盖住文字3.套索工 ...

  4. Java Web 笔记(1)

    JavaWeb 学习笔记,狂神说java,链接:https://www.bilibili.com/video/av68833391 Java Web 1.基本概念 1.1.前言 web开发: web, ...

  5. cisco 添加静态路由

    静态路由:由人,手动写出的路由条目就叫静态路由,永久有效,优先级最高,效率最高. 路由器是干啥的? 连接不同地址段的网络.屏蔽不同地址段的网络广播. 路由器有多个接口,至少得有2个吧,一边一个局域网. ...

  6. Radmin Server v3.5.1 汉化破解绿色版 第四版

    下载:https://pan.baidu.com/s/1skOXffJ 使用方法:1.运行“安装.bat”,安装过程静默,安装后无托盘图标,不创建任何快捷方式.2.运行“设置.bat”,进入 radm ...

  7. ffmpeg基本功能使用

    任务描述:由给定图像序列合成 24fps 视频 方案一 直接对图像进行操作,适用于图像名比较规范且默认即为所需顺序 ffmpeg -f image2 -i ./images_crop_%d.png - ...

  8. matlab逐行读取text文件,编写函数提取需要的文字

    在数学建模中遇到的数据比较难处理,而且给的是text格式,自己想了好长时间才编出来,现在分享一下,可以交流学习 目标的text文件是 只提取里面的数据 需要自编函数 clc,clear path='D ...

  9. maven发布java-分支构建

    1.安装parameter插件 2. 新建maven项目 3.配置maven项目 4.配置maven项目2 5.配置maven项目3 6. 模拟开发给提交打tag标签 7.版本发布 8.tag获取并构 ...

  10. 安装Bind到CentOS(YUM)

    运行环境 系统版本:CentOS Linux release 7.3.1611 (Core) 软件版本:Bind-x 硬件要求:无 安装过程 1.配置YUM源 [root@localhost ~]# ...