摘自《VM虚拟机中Linux扩展根分区空间》,百度文库链接,如有侵权,请联系告知。

必须是基于“卷管理”的才能够扩展分区。

[root@SQL2 ~]# lvdisplay

如果能看到“物理卷”和“逻辑卷”,说明OK。

1.VMware扩展
在关机状态下,点击“硬盘->扩展”,然后输入大小(从50GB改到80GB),点击确定。

2.开启虚拟机

[root@SQL2 ~]# df -h

发现没有改变

3.用命令查看sda已经扩展

[root@SQL2 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).   Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.    Command (m for help): p   Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors

4.查看lvm状态

[root@SQL2 ~]# pvsPV         VG     Fmt  Attr PSize  PFree/dev/sda2  centos lvm2 a--  49.51g 44.00m
[root@SQL2 ~]# vgsVG     #PV #LV #SN Attr   VSize  VFree centos   1   2   0 wz--n- 49.51g 44.00m
[root@SQL2 ~]# lvsLV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert  root centos -wi-ao---- 45.59gswap centos -wi-ao----  3.88g

5.生成分区/dev/sda3

[root@SQL2 ~]# fdisk /dev/sdaWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them. Be careful before using the write command.    Command (m for help): p   Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos  Disk identifier: 0x0006069d      Device Boot      Start         End      Blocks   Id  System /dev/sda1   *        2048     1026047      512000   83  Linux  /dev/sda2         1026048   104857599    51915776   8e  Linux LVM   Command (m for help): n Partition type:  p   primary (2 primary, 0 extended, 2 free) e   extended  Select (default p): p    Partition number (3,4, default 3): 3  First sector (104857600-167772159, default 104857600): #回车 Using default value 104857600  Last sector, +sectors or +size{K,M,G} (104857600-167772159, default 167772159): #回车 Using default value 167772159  Partition 3 of type Linux and of size 30 GiB is set   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 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.

6.重读磁盘分区

[root@SQL2 ~]# partprobe

如果不行就重启reboot

7.格式化/dev/sda3

[root@SQL2 ~]# mkfs.ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1966080 inodes, 7864320 blocks
393216 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2155872256
240 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

8.lvm 扩容

[root@SQL2 ~]#  pvcreate  /dev/sda3
WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created
[root@SQL2 ~]# pvs
PV         VG     Fmt  Attr PSize  PFree
/dev/sda2  centos lvm2 a--  49.51g 44.00m  #标红为组名,下步会用到
/dev/sda3         lvm2 ---  30.00g 30.00g
[root@SQL2 ~]# vgextend centos /dev/sda3  #(注意组名)
Volume group "centos" successfully extended
#此处+29.9表示大约扩展30G空间,若是此处设置为80G 也是可行,表示扩展后总容量
[root@SQL2 ~]# lvextend -L +29.9G /dev/mapper/centos-root  /dev/sda3
Rounding size to boundary between physical extents: 29.90 GiB
Size of logical volume centos/root changed from 45.59 GiB (11671 extents) to 75.49 GiB (19326 extents).
Logical volume root successfully resized.
#若此处报错,可以不管,执行下个resize2fs命令,若正确,可忽略resize2fs命令
[root@SQL2 ~]#  resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock.   [root@SQL2 ~]#  resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock. 
[root@SQL2 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=2987776 blks=                       sectsz=512   attr=2, projid32bit=1
data     =                       bsize=4096   blocks=11951104, imaxpct=25          =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=5835, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 11951104 to 19789824
[root@SQL2 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   76G   12G   65G  15% /
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G   84K  1.9G   1% /dev/shm
tmpfs                    1.9G  9.0M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1                497M  159M  339M  32% /boot
tmpfs                    379M   16K  379M   1% /run/user/42
tmpfs                    379M     0  379M   0% /run/user/0

已经成功。

VMware虚拟机中CentOS根分区的扩展相关推荐

  1. VMware虚拟机中CentOS网络设置

    在VMware虚拟机中安装了一个CentOS系统,试着学习了一下该系统下的网络设置,记录如下: VMware虚拟机中比较方便的联网方式是NAT方式,这里采用该方式. CentOS默认使用ipv6协议联 ...

  2. linux 6新扩分区识别,虚拟机中CentOS 6.5 添加扩展分区

    1.更改虚拟机配置 虚拟机->设置->硬盘->扩展磁盘容量 fdisk -l 查看,发现硬盘空间变大了 [[email protected] Desktop]# fdisk -l D ...

  3. 【转】VMware虚拟机中CentOS设置固定IP

    因为需要配置固定IP,在网上找了很久终于找到一个可行的例子,自己配置成功了. 1.首先获取你的GATEWAY 方便后面在cento系统配置里使用选取菜单栏:Edit->Virtual Netwo ...

  4. 虚拟机中火狐连不上服务器,VMware虚拟机中Ubuntu18.04无法连接网络的解决办法

    VMware虚拟机中Ubuntu18.04无法连接网络的解决办法 虚拟机中Ubuntu18.04无法连接网络的解决办法,具体内容如下 对VMware虚拟机进行恢复默认网络设置 恢复虚拟网络默认设置(在 ...

  5. 为VMware虚拟机中的Linux系统设置固定IP的方法

    这篇文章主要介绍了为VMware虚拟机中的Linux系统设置固定IP的方法,包括以nat方式固定ip上网的方法,需要的朋友可以参考下 1.配置DNS: 修改 /etc/resolv.conf 文件,添 ...

  6. VMware虚拟机中安装Linux系统

    文章目录 VMware虚拟机中安装Linux系统 一.系统镜像 二.安装系统 VMware虚拟机中安装Linux系统 一.系统镜像 阿里镜像地址: https://developer.aliyun.c ...

  7. 【错误记录】VMware 虚拟机报错 ( 向 VMWare 虚拟机中的 Ubuntu 系统拷贝文件时磁盘空间不足 ② | 删除交换空间 )

    文章目录 一.报错信息 二.解决方案 一.报错信息 在 [错误记录]VMware 虚拟机报错 ( 向 VMWare 虚拟机中的 Ubuntu 系统拷贝文件时磁盘空间不足 ) 博客中 , 给出了解决方案 ...

  8. 在VMware虚拟机中进行Ghost网刻不成功的几点提示

    在VMware虚拟机中进行Ghost网刻不成功的几点提示: 1,确认真实主机的IP在DHCP的IP地址池范围内: 2,确认新建虚拟机时选的IDE硬盘,而不是SCSI硬盘,否则会造成每次启动 时蓝屏,因 ...

  9. VMware虚拟机中ubuntu的磁盘怎么扩容

    VMware虚拟机中ubuntu的磁盘怎么扩容 之前在vm中安装ubuntu18.04的时候,觉得30GB已经挺大了,结果在linux里安装了hadoop一圈的软件,然后又安装了idea,eclips ...

最新文章

  1. nginx+tomcat+memcache实现负载均衡、session共享
  2. 使用装饰者模式做有趣的事情
  3. 抖音数据统计_“彭十六elf”单条视频获赞200W+,荣登抖音TOP20丨红人榜
  4. android gradle build process
  5. lotus php,LotusPhp笔记之:Cookie组件的使用详解
  6. JSP动态网站环境搭建应用中的详细步骤(Tomcat和Apache/IIS的整合)
  7. 树莓派教程 - 1.1 树莓派GPIO库wiringPi 硬件PWM可调频率
  8. Webform(分页、组合查询)
  9. 自动类型转化的鲜为人知的陷阱
  10. Image zImage vmlinuz
  11. 控制台 钢铁雄心2_钢铁雄心4控制台 (2)
  12. 删除了项目下的\WEB-INF\classes文件夹,在eclipse的tomcat部署启动时报错。
  13. PHP UTF-8转GBK
  14. ios 关于itunes安装ipa包的方法,一步解决
  15. window-批量创建文件夹
  16. 乐刻运动年陈文化中的那六个成语解析:日拱一卒,功不唐捐|筚路蓝缕 玉汝于成|有梦可依,未来可期
  17. pdfmark生成pdf文件并下载
  18. MongoDB学习总结四(详细记录使用MongoTemplate操作MongoDB数据库)
  19. Unity获取麦克风实现吹气球效果
  20. 把kali linux 装进 U盘并实现数据可存储

热门文章

  1. Windows纸牌×××式计分法
  2. yum安装zlib出错
  3. flask更改用户头像
  4. 【MySQL】MySQL开发注意事项与SQL性能优化步骤
  5. python3基本数据类型
  6. SSH Secure Shell Client无法连接utbuntu的报错
  7. 2016 版 Laravel 系列入门教程(一)
  8. 顺序表循环队列:创建初始化、入队、出队、获取队列头数据、计算队列有效数据长度...
  9. 一篇来自网络的关于“enqueue”events的简短参考(转)
  10. IOS中获取各个文件的目录路径的方法和NSFileManager类