扩展Vmware的虚拟Linux系统磁盘

          

                虚拟机Vmware装上一个Linux系统之后,刚开始比较吝啬,分配的磁盘空间太小,没过多久磁盘空间告急,这时怎么解决磁盘空间不足的问题?最简单的做法是重新安装一个虚拟机系统,可问题是重新配置好至自己习惯的状态,要安装接近无数的软件,不是不可能,太繁琐,最可行的做法是手工动态扩展磁盘分区。

           首先要做的事情是在虚拟机关机的状态下,先设定好扩展后的总的文件大小:

         


       1,单击“编辑虚拟机设置”,如图:


      2,选择相应虚拟硬盘;如图:


   3,

展开“实用工具”;

单击“扩展”;


4,

输入最大磁盘大小

单击“扩展”;



5,

磁盘成功扩展,

单击“确定”;




6,虚拟硬盘已变成扩展后的大小。

           其次,使用linux下的fdisk工具进行分区。

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




根据提示信息可以判断出此系统的磁盘接口为SCSI,

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):m //“ 列出fdisk的帮助”
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help):n //” 命令n用于添加新分区"
Command action
e extended
p primary partition (1-4)
p //" 选择创建主分区"此时,

Partition number (1-4):3 //fdisk会让你选择主分区的编号,如果已经有了主分区sda1,sda2,那么编号就选3,即要创建的该分区为sda3.
First cylinder (2611-3916, default 2611): //此时,fdisk又会让你选择该分区的开始值这个就是分区的Start 值(start cylinder);这里最好直接按回车,
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916): //此时,fdisk又会让你选择该分区的开始值这个就是分区的End 值这里最好直接按回车,
Using default value 3916

Command (m for help): w //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. 
三、我们的新建分区/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。
Command (m for help): w


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

格式化该新添加的分区:


你会发现多了一块分区/dev/sda4.


再确定下现在系统的文件系统类型:

那么就需要把新加的磁盘分区创建ext4文件系统:

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

扩充新分区:


接下来,pvcreate指令用于将物理硬盘分区初始化为物理卷,以便被LVM使用。要创建物理卷必须首先对硬盘进行分区,并且将硬盘分区的类型设置为“8e”后,才能使用pvcreat指令将分区初始化为物理卷。


#pvcreate /dev/sda4

Physical volume "/dev/sda4" successfully created


其中是当前需要扩充的lvm组名,可以通过df -h查看,例如我的是: /dev/mapper/VolGroup00-LogVol00) //vgextend指令用于动态的扩展卷组,它通过向卷组中添加物理卷来增加卷组的容量。

,#vgdisplay //用于显示LNM卷组的元数据信息。

主要查看Free PE / Size 35838/ 139.99GB,说明我们最多可以有139.99GB的扩充空间.


把空闲磁盘空间添加到对应的逻辑分区上去:

resize2fs指令被用来增大或者收缩未加载的“ext2/ext3/ext4”文件系统的大小。


#df -h //查看一下你的系统磁盘空间"/"目录变成了可用磁盘空间增加了139GB


一切大功告成!!!





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值