VMware Workstation 添加磁盘 挂载目录(centos)
参考文档: Linux命令大全
需求:测试环境虚拟机某个目录下空间不足,准备通过添加一块磁盘,并将该目录挂载到该磁盘
前面几步在测试服务器上操作的,截图困难,所以网上找了几张设置图
- 关闭虚拟机(没测试过不关闭的情况)
- 虚拟机中添加一块新的磁盘
- 选择磁盘类型
- 创建新磁盘
- 设置大小、拆分方式
- 设定文件名(一般默认即可)
- 确定(一定要确定,不然不会保存的)
- 重启虚拟机
- fdisk观察硬盘实体使用情况
[root@node3 ~]# fdisk -l
Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x000bd826
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 1048575999 523238400 8e Linux LVM
//新加的磁盘(100G)
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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 /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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 /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
Disk /dev/mapper/centos-home: 480.0 GB, 479954206720 bytes, 937410560 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
- 选择要进行操作的磁盘
[root@node3 ~]# fdisk /dev/sdb
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x2890866a.
- 输入m列出可以执行的命令:
command (m for help): m
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)
- 输入p列出磁盘目前的分区情况 (如果是新的磁盘 忽略步骤)
Command (m for help): p
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1 8001 8e Linux LVM
/dev/sdb2 2 26 200812+ 83 Linux
- 删除现有分区
Command (m for help): d
Partition number (1-4): 1
Command (m for help): d
Selected partition 2
- 确认分区已经删除
Command (m for help): p
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help):
- 建立新的磁盘分区(两个主磁盘分区)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p //建立主分区
Partition number (1-4): 1 //分区号
First cylinder (1-391, default 1): //分区起始位置
Using default value 1
last cylinder or +size or +sizeM or +sizeK (1-391, default 391): 100 //分区结束位置,单位为扇区(磁盘扇区默认是512Byte)
Command (m for help): n //再建立一个分区
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2 //分区号为2
First cylinder (101-391, default 101):
Using default value 101
Last cylinder or +size or +sizeM or +sizeK (101-391, default 391): +200M //分区结束位置,单位为M
- 建一个扩展分区
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e //选择扩展分区
Partition number (1-4): 3
First cylinder (126-391, default 126):
Using default value 126
Last cylinder or +size or +sizeM or +sizeK (126-391, default 391)://剩下的空间都用做扩展分区
Using default value 391
- 查看扩展分区
Command (m for help): p
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 100 803218+ 83 Linux
/dev/sdb2 101 125 200812+ 83 Linux
/dev/sdb3 126 391 2136645 5 Extended
- 扩展分区上建立逻辑分区
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l //选择逻辑分区
First cylinder (126-391, default 126):
Using default value 126
Last cylinder or +size or +sizeM or +sizeK (126-391, default 391): +400M
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (176-391, default 176):
Using default value 176
Last cylinder or +size or +sizeM or +sizeK (176-391, default 391):
Using default value 391
- 查看当前分区情况
Command (m for help): p
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 100 803218+ 83 Linux
/dev/sdb2 101 125 200812+ 83 Linux
/dev/sdb3 126 391 2136645 5 Extended
/dev/sdb5 126 175 401593+ 83 Linux
/dev/sdb6 176 391 1734988+ 83 Linux
Command (m for help):
从上面的结果我们可以看到,在硬盘sdb我们建立了2个主分区(sdb1,sdb2),1个扩展分区(sdb3),2个逻辑分区(sdb5,sdb6)
注意:主分区和扩展分区的磁盘号位1-4,也就是说最多有4个主分区或者扩展分区,逻辑分区开始的磁盘号为5,因此在这个实验中试没有sdb4的。
- 保存分区操作
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
分区创建方式按照参考文档的操作,但是我并没有创建这么多分区,100G全部创建了主分区即
/dev/sdb1
- fdisk 查看硬盘分区情况
[root@node3 ~]# fdisk -l
Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x000bd826
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 1048575999 523238400 8e Linux LVM
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x2890866a
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209715199 104856576 83 Linux //新的分区(sbd1:100G)
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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 /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
Disk /dev/mapper/centos-home: 480.0 GB, 479954206720 bytes, 937410560 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
- cat /proc/partitions 查看磁盘文件信息
[root@node3 ~]# cat /proc/partitions
major minor #blocks name
8 0 524288000 sda
8 1 1048576 sda1
8 2 523238400 sda2
8 16 104857600 sdb
8 17 104856576 sdb1
11 0 1048575 sr0
253 0 52428800 dm-0
253 1 2097152 dm-1
253 2 468705280 dm-2
- mkfs -t ext3 /dev/sdb1格式化分区
[root@node3 ~]# mkfs -t ext3 /dev/sdb1
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
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
- mount /dev/sdb1 /guazai
#/usr/hdp/ 目录要先存在
[root@node3 ~]# mount /dev/sdb1 /usr/hdp/
- 查看挂载情况
[root@node3 usr]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 50G 20K 100% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 12M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 142M 873M 14% /boot
/dev/mapper/centos-home 447G 1018M 446G 1% /home
tmpfs 781M 0 781M 0% /run/user/0
/dev/sdb1 99G 60M 94G 1% /usr/hdp //挂载成功
- 取消挂载
[root@node3 /]# umount /dev/sdb1
[root@node3 /]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 52403200 52403180 20 100% /
devtmpfs 3983896 0 3983896 0% /dev
tmpfs 3996168 0 3996168 0% /dev/shm
tmpfs 3996168 11992 3984176 1% /run
tmpfs 3996168 0 3996168 0% /sys/fs/cgroup
/dev/sda1 1038336 145260 893076 14% /boot
/dev/mapper/centos-home 468476420 1041428 467434992 1% /home
tmpfs 799236 0 799236 0% /run/user/0
取消挂载成功
还可以用umount /usr/hdp
取消挂载
VMware Workstation 添加磁盘 挂载目录(centos)的更多相关文章
- 【图文教程】Vmware Workstation 12虚拟机中安装CentOS 7详细步骤
文档维护人:牛棚琐思 <viprs@qq.com> ,如有不妥之处,请不吝赐教. 文档目标:帮助新手在Vmware虚拟机软件中安装CentOS 7超详细教程. 目标人群:本篇教程比较简单, ...
- 【Hadoop离线基础总结】Mac版VMware Fusion虚拟机磁盘挂载
步骤概览 1.打开所要挂载磁盘的虚拟机的设置(此时必须关机) 2.打开硬盘设置 3.添加设备 4.选择新硬盘 5.设置如下图 6.将虚拟机开机,输入 df-lh ,查看当前虚拟机磁盘 7.输入 fdi ...
- Linux修改磁盘挂载目录
比如想把已经挂载在home目录上的硬盘挂载到data目录上, 如下操作 #df -h(查看分区情况及数据盘名称) # mkdir /data(如果没有data目录就创建,否则此步跳过) # umoun ...
- Vmware Workstation添加centos 7系统网络问题(无IP情况)
简单配置 命令行输入ip addr 查询不到IP的情况,如下: 解决办法: 1. vi /etc/sysconfig/network-scripts/ifcfg-ens33 2. 最后一行,ONBO ...
- vmware workstation LINUX磁盘扩容
1.edit virtual machine settings -> 选中硬盘->右侧utilities->expand(虚拟机不能存在镜像),输入要扩容到的大小 2.扩容之后进入系 ...
- VMware workstation批量创建虚拟机和自动化安装操作系统(一)
一. 简述 作为从事IT行业运维工作的Linuxer,大多情况下需要在测试环境中部署业务系统并进行测试,在没有足够的计算存储网络条件下,使用虚拟机进行虚拟集群的创建和使用,是一种不错的学习和实践方式. ...
- vmware workstation 上创建的centos 7.2 ,新添加一块网卡。无法找到配置文件。
在vmware workstation 11上,新建一个centos 7.2系统. 初装带有一个块网卡:能够在/etc/sysconfig/network-scripts/目录下找到相应的网卡配置文件 ...
- 不停机为虚拟机添加主机磁盘(以VMware Workstation为例)
VMware Workstation软件上安装的centos7系统,新增磁盘后使用fdisk -l命令查看不到新增的磁盘,有没有办法在不重启的情况下添加上新磁盘? 有办法 具体如下: # 查看主机总线 ...
- CentOS添加磁盘分区
(这里的磁盘在vmware workstation VM中添加) 1.关闭虚拟机,在虚拟机设置中添加一个硬盘,然后开启虚拟机. 2.使用fdisk -l命令查看,这时会发现一个为被使用的设备,有2G的 ...
随机推荐
- 深入浅出 Vue.js 第九章 解析器---学习笔记
本文结合 Vue 源码进行学习 学习时,根据 github 上 Vue 项目的 package.json 文件,可知版本为 2.6.10 解析器 一.解析器的作用 解析器的作用就是将模版解析成 AST ...
- php网络编程实例
php网络编程实例 一.总结 一句话总结: socket_create():创建socket socket_bind():绑定IP和端口 socket_listen():监听客户端信息 <?ph ...
- windows 驱动开发 DDK与WDK WDM的区别
1.首先,先从基础的东西说起,开发WINDOWS下的驱动程序,需要一个专门的开发包,如:开发JAVA程序,我们可能需要一个JDK,开发WINDOWS应用程序,我们需要WINDOWS的SDK,现在开发W ...
- Template within template: why “`>>' should be `> >' within a nested template argument list” 解决方法
如果直接这样写: std::vector<boost::shared_ptr<int>> intvec; gcc编译器会把">>"当成opera ...
- HTML a标签文字颜色
1.css代码: a{color:#00F} a:hover{color:#f00}/* 鼠标经过悬停字体颜色 */ /* css 注释说明:以上代码为设置HTML中超链接统一字体颜色 */ .div ...
- vue组件通信之非父子组件通信
什么顺序不顺序的.. 先来说说非父子组件通信. 首先,我们先来了解下vue中的 1.$emit 触发当前实例上的事件,附加参数都会传给监听器回调. 2.$on 监听当前实例上的自定义事件.事件可以 ...
- 剑指offer——61平衡二叉树
题目描述 输入一棵二叉树,判断该二叉树是否是平衡二叉树. 题解: 方法一:使用深度遍历,判断每个节点是不是平衡二叉树,这种从上至下的方法会导致底层的节点重复判断多次 方法二:使用后序遍历判断,这种 ...
- Django框架(七)—— 模板层:变量、过滤器、标签、自定义标签和过滤器
目录 模板层:变量.过滤器.标签.自定义标签和过滤器 一.模板层变量 1.语法 2.使用 二.模板层之过滤器 1.语法 2.常用过滤器 3.其他过滤器 三.模板值标签 1.for标签 2.if标签 3 ...
- Python 变量作用域 LEGB (下)—— Enclosing function locals
上篇:Python 变量作用域 LEGB (上)—— Local,Global,Builtin https://www.cnblogs.com/yvivid/p/python_LEGB_1.html ...
- vim的基本快捷操作(一)
一.光标移动 ^ 到该行第一个非空格字符处. + 到下一行的第一个非空格字符处 - 到上一行的第一个非空格字符处 `. 到上次修改点 <c-o> 到上次所停留位置, <c-i> ...