教你如何在VMWarelinux虚拟机扩容
白羽 2018-05-25 来源 :网络 阅读 1686 评论 0

摘要:本文将教你如何在VMWarelinux虚拟机扩容,希望本文对大家学Vmware有所帮助。


首先通过VMWare修改虚拟机参数,增加虚拟机磁盘空间(请参考相关资料),其次在虚拟机中加入扩容的磁盘空间。

1、使用parted查看可分配的空间

[root@stest ~]# parted
GNU Parted 1.8.1
使用 /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free 

Model: VMware Virtual disk (scsi)
Disk /dev/sda: 38.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system 标志
1 32.3kB 107MB 107MB 主分区 ext3 启动
2 107MB 17.2GB 17.1GB 主分区 lvm 
17.2GB 38.7GB 21.5GB Free Space 
可以看到有新增加的21.5GB的空间尚未被分配。

2、使用fdisk -l查看磁盘分区

[root@stest ~]# fdisk -l

Disk /dev/sda: 38.6 GB, 38654705664 bytes
255 heads, 63 sectors/track, 4699 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2088 16667437+ 8e Linux LVM

3、查看磁盘分区,先输入fdisk /dev/sda,接着输入p,显示磁盘空间分配情况,可见已分配2088个柱面,共有4699个柱面。

[root@stest ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 4699.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 38.6 GB, 38654705664 bytes
255 heads, 63 sectors/track, 4699 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2088 16667437+ 8e Linux LVM

4、创建新的磁盘分区,将新的磁盘分区设置为扩展分区,这里分区数为3,起始柱面使用缺省值2089,结束柱面使用缺省值4699,最后输入w,保存修改。

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 3
First cylinder (2089-4699, default 2089): 
Using default value 2089
Last cylinder or +size or +sizeM or +sizeK (2089-4699, default 4699): 
Using default value 4699

Command (m for help): w
The partition table has been altered!

保存完成后重启服务器。

5、在扩展分区上创建逻辑分区,输入n,选l创建逻辑分区,起始柱面、结束柱面号直接敲回车,使用缺省值,只建一个逻辑分区,最后输入w保存修改。

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (2089-4699, default 2089): 
Using default value 2089
Last cylinder or +size or +sizeM or +sizeK (2089-4699, default 4699): 
Using default value 4699

Command (m for help): w
The partition table has been altered!

6、格式化文件系统,使用mkfs命令对新建磁盘分区进行格式化

[root@stest ~]# mkfs -t ext3 /dev/sda5
mke2fs 1.39 (29-May-2006)
warning: 326 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2626560 inodes, 5242880 blocks
262160 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16416 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000

Writing inode tables: done 
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

使用mount命令挂载磁盘:

[root@stest ~]# mount -t ext3 /dev/sda5 /home/weblogic

7、mount磁盘分区到文件系统,这里先创建/home/weblogic目录,然后使用vi命令在/etc/fstab文件中加入:

/dev/sda4 /home/weblogic ext3 defaults 0 0

保存修改,重启系统,这样以后使用便会自动挂载新的磁盘分区。

 

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标系统运维之Vmware频道!

本文由 @白羽 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程