Vmware之添加磁盘并挂载
凌雪 2018-09-19 来源 :网络 阅读 2835 评论 0

摘要:本文将带你了解Vmware之添加磁盘并挂载,希望本文对大家学Vmware有所帮助。

本文将带你了解Vmware之添加磁盘并挂载,希望本文对大家学Vmware有所帮助。


添加磁盘并挂载:
    设置虚拟机系统里添加磁盘,重启虚拟机后,虚拟机目录/dev下会增加一个sdb设备。
    使用fdisk /dev/sdb 管理磁盘分区,首先p 查看磁盘分区信息,然后n增加一个主分区,然后在敲入p进行分区操作,再输入1表示命名分区为sdb1,接着会提示输入开始扇区,直接回车跳过,然后在最后扇区那里输入+2G表示该分区大小设置为2G,使用p再次查看分区是否成功创建,显示有新的分区后,敲入w键表示写入磁盘。命令执行完成后,会自动退出fdisk。现在file /dev/sdb1查询分区信息,如果出错,敲入命令partprobe或者直接重启虚拟机即可。
    因为Linux系统无法对没有格式化的磁盘进行读写操作,所以接下来还需要格式化创建好的分区。输入命令mkfs.xfs /dev/sdb1将其格式化为xfs文件系统格式,如果需要换成其他格式可以在敲完mkfs后再使用两次tab键来显示其他文件系统格式。
    那么,现在我们只需要再挂载该分区到系统里就可以了,首先mkdir /newFS 在根目录创建文件夹用来挂载,然后就是mount /dev/sdb1   /newFS。现在就可以正常使用该分区了。但每次重启虚拟机后都需要再挂载一遍,所以我们可以在每次开机时自动挂载该分区,vi /etc/fstab 然后在文件末尾添加 /dev/sdb1 /newFS xfs defaults 0(表示是否开机磁盘自检) 0
下面是我在虚拟机里的操作过程记录
[root@localhost /]# 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 0xf15825cf.
   
    Command (m for help): p
   
    Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xf15825cf
   
       Device Boot      Start         End      Blocks     Id  System
   
    Command (m for help): n
    Partition type:
       p     primary (0 primary, 0 extended, 4 free)
   e     extended
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-41943039, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):   +2G
    Partition 1 of type Linux and of size 2 GiB is set
   
    Command (m for help): p
   
    Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xf15825cf
   
       Device Boot      Start         End      Blocks     Id  System
    /dev/sdb1            2048     4196351     2097152     83  Linux
   
    Command (m for help): w
    The partition table has been altered!
   
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@localhost /]# ls /dev/sdb1
    /dev/sdb1
    [root@localhost /]# mkfs.ext2 /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
    131072 inodes, 524288 blocks
    26214 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=536870912
    16 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
        32768, 98304, 163840, 229376,   294912
   
    Allocating group tables: done                           
    Writing inode tables: done                           
    Writing superblocks and filesystem accounting information: done
   
    [root@localhost /]# mount /dev/sdb1 /bp
    [root@localhost /]# df
    Filesystem     1K-blocks    Used Available Use% Mounted on
    /dev/sda3       18555904 5090696  13465208    28% /
    devtmpfs          485292       0      485292   0% /dev
    tmpfs             499968     144      499824   1% /dev/shm
    tmpfs             499968    7224      492744   2% /run
    tmpfs             499968       0      499968   0% /sys/fs/cgroup
    /dev/sda1         303780  154756      149024  51% /boot
    tmpfs              99996       8       99988   1% /run/user/0
    /dev/sdb1        2064208    3072     1956280   1% /bp
    [root@localhost /]# df -T
    Filesystem     Type     1K-blocks    Used Available Use% Mounted on
    /dev/sda3      xfs       18555904 5090676  13465228    28% /
    devtmpfs       devtmpfs    485292       0      485292   0% /dev
    tmpfs          tmpfs       499968     144      499824   1% /dev/shm
    tmpfs          tmpfs       499968    7224      492744   2% /run
    tmpfs          tmpfs       499968       0      499968   0% /sys/fs/cgroup
    /dev/sda1      xfs         303780  154756      149024  51% /boot
    tmpfs          tmpfs        99996       8       99988   1% /run/user/0
    /dev/sdb1      ext2       2064208    3072     1956280   1% /bp
    [root@localhost /]#    

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标系统运维之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小时内训课程