热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

VMware下的Linux扩展磁盘空间

VMware下的Linux扩展磁盘空间业务场景业务场景操作流程一、VMware加内存二、linux操作业务场景业务场景本文以VMwareWorkstation15Pro-15

VMware下的Linux扩展磁盘空间

  • 业务场景
    • 业务场景
  • 操作流程
    • 一、VMware 加内存
    • 二 、linux操作


业务场景


业务场景

本文以 VMware® Workstation 15 Pro -15.5.6 build-16341506+ CentOS Linux release 7.5.1804 (Core)为测试机。


操作流程


一、VMware 加内存

如下图所示,此时可以看到虚拟机硬盘目前为25G,点击编辑虚拟机设置,进入虚拟机设置界面。
虚拟机
分别按下图步骤点击硬盘扩展→扩展内存→扩展确定
在这里插入图片描述
硬盘扩展成功后,须要在客户机(即Linux虚拟机)上进行分区硬盘和扩展文件系统。


二 、linux操作

启动Linux虚拟机。以root用户登录,由于后面的操作须要root用户的权限。
打开终端窗体,输入df -h,查看文件系统。例如以下图所看到的,能够看到在我的虚拟机中/的大小为17G。可用容量为8.8G,/dev/sda3为之前挂载的硬盘。

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 8.3G 8.8G 49% /
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4G 0 1.4G 0% /dev/shm
tmpfs 1.4G 11M 1.4G 1% /run
tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup
/dev/sda1 1014M 171M 844M 17% /boot
tmpfs 283M 8.0K 283M 1% /run/user/42
tmpfs 283M 0 283M 0% /run/user/0
/dev/sda3 4.8G 20M 4.6G 1% /mount_001
[root@localhost ~]# pwd
/root

运行fdisk –l命令。查看硬盘分区情况,能够发现硬盘空间确实已经扩展了到了30G(我也不知道他为什么显示的是32.2G,暂时还没有去研究,欢迎补充知识点)。

[root@localhost ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c591bDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
/dev/sda3 41943040 52428799 5242880 8e Linux LVMDisk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

然后下面进行格式化增加内存分区的步骤,执行fdisk /dev/sda,按下图步骤操作。

[root@localhost ~]# 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
## p :显示磁盘当前的分区表
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c591bDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
/dev/sda3 41943040 52428799 5242880 8e Linux LVMCommand (m for help): n
##输入n创建分区
Partition type:p primary (3 primary, 0 extended, 1 free)e extended
Select (default e): p
## 询问我们是要创建主分区还是扩展分区,主分区最多只能创建4个,如果创建了扩展分区那么扩展分区需要占用一个主分区。这里我们创建分区,输入p
Selected partition 4
First sector (52428800-62914559, default 52428800): 4
Value out of range.
First sector (52428800-62914559, default 52428800): 52428800
Last sector, +sectors or +size{K,M,G} (52428800-62914559, default 62914559): 62914559
Partition 4 of type Linux and of size 5 GiB is setCommand (m for help): t
Partition number (1-4, default 4): 4
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
## 分区选择默认4
Command (m for help): w
The partition table has been altered!
## w 保存
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.

在此执行fdisk -l查看,此时 /dev/sda4 硬盘已经存在

[root@localhost ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c591bDevice Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
/dev/sda3 41943040 52428799 5242880 8e Linux LVM
/dev/sda4 52428800 62914559 5242880 8e Linux LVMDisk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

执行mkfs -t ext3 /dev/sda4格式化逻辑分区

[root@localhost ~]# mkfs -t ext3 /dev/sda4
mke2fs 1.42.9 (28-Dec-2013)
Could not stat /dev/sda4 --- No such file or directoryThe device apparently does not exist; did you specify it correctly?

分区正常,格式化错误。
原因是分区信息尚未到分区表里,
执行命令partprobe
再次执行 mkfs -t ext3 /dev/sda4格式化逻辑分区

[root@localhost ~]# partprobe
[root@localhost ~]# mkfs -t ext3 /dev/sda4
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
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 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, 884736Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done [root@localhost ~]#

创建挂载目录mkdir /mount_002
执行mount /dev/sda4 /mount_002挂载
在此执行df -h检查硬盘

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 8.3G 8.8G 49% /
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4G 0 1.4G 0% /dev/shm
tmpfs 1.4G 11M 1.4G 1% /run
tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup
/dev/sda1 1014M 171M 844M 17% /boot
tmpfs 283M 12K 283M 1% /run/user/42
tmpfs 283M 0 283M 0% /run/user/0
/dev/sda3 4.8G 20M 4.6G 1% /mount_001
/dev/sda4 4.8G 11M 4.6G 1% /mount_002

此时dev/sda4已经挂载导了mount_002


推荐阅读
  • MQ的使用
    安装环境:linuxredhatactivemq版本:5.8.01.从http:activemq.apache.orgdownload.html地址下载 ... [详细]
  • TLB 缓存延迟刷新漏洞 CVE201818281 解析 ... [详细]
  • flash代码_正点原子【STM32F407探索者】第三十九章 FLASH 模拟 EEPROM 实验
    1)资料下载:点击资料即可下载2)对正点原子Linux感兴趣的同学可以加群讨论:9354467413)关注正点原子公众号,获取最新资料更新 ... [详细]
  • Linux文件目录和权限
    Linux文件目录和权限前言:Linux一般将文件可存取的身份分为三个类别,分别是ownergroupothers,根据权限划分,每个目录都可以拥有相对身份的-rwx[可读可写可执 ... [详细]
  • 13Linux基本命令和配置服务器来电后自动开机
    本节所讲内容:Linux终端介绍Shell提示符BashShell基本语法基本命令的使用:ls、pwd、cd查看系统和BIOS硬件时间Linux如何获得 ... [详细]
  • hadoop完全分布式搭建
    原文链接:hadoop完全分布式搭建主机分配以及地址要求:角色主机名IP地址Namenodemaster192.168.222.201Datanodeslave ... [详细]
  • Mysql MySqlBulkLoader在.NET平台下的批量插入
    批量导入publicboolTranBatchImpo ... [详细]
  • (一)javax.mail.Session:Session类代表JavaMail中的一次邮件会话.每个基于JavaMail的应用程序至少有一次会话,也可以产生多次会话.发送邮件之前 ... [详细]
  • 在这一期的SendMessage函数应用中,我将向大家介绍如何利用消息函数来扩展树型列表(TreeView)控件的功能相信对于树型列表控件大家十分的熟悉, ... [详细]
  • 2022年Python面试题一.Python基础二.企业面试题结束语🥇🥇🥇✅作者简介:大家好我是编程IDὌ ... [详细]
  • 互联网世界 9 种基本的商业模式
    互联网世界9种基本的商业模式一个商业模式是运行一个公司的方法;通过该模式的运作,一个公司能维持自己的生存,就是说,能有收益。商业模式意味着一个公司是如何通过在价值链中定位自己,从而获 ... [详细]
  • c语言自定义BOOL函数C语言没有BOOL类型变量boolean类型是C++所独有的由于使用BOOL类型可以使代码更具有可读性,很多编程者都在C中自己定义了类似的应用,一般方法有两 ... [详细]
  • UDP协议开发
    UDP是用户数据报协议(UserDatagramProtocol,UDP)的简称,其主要作用是将网络数据流量压缩成数据报形式,提供面向事务的简单信息传送服务。与TCP协议不同,UD ... [详细]
  • 文章目录问题原因解决list.remove方法在删除元素的时候往往会出现漏删或者索引越界的情况。问题给定了一个日期列表(我这边用于判定文件夹是否存在)。dateList[202 ... [详细]
  • 【Modbus 】Modbus 协议
    Modbus协议简介Modbus协议是一项应用层报文传输协议,包括ASCII、RTU、TCP三种报文类型。标准的Modbus协议物理层接口有RS232、RS422 ... [详细]
author-avatar
做条温顺的鱼_169
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有