一:Linux虚拟机如何和本机通信?
一、设置虚拟机
在VMware的计算机列表里,右键点击要设置的虚拟机,点击设置>>网络适配器,网络链接选择NAT模式
虚拟机IP:192.168.91.128
本机IP:ping -c 3 本机ip能ping通成功
二:扩大虚拟机内存
1:扩展VMWare-centos7硬盘空间
关闭Vmware的centos7系统,才能在VMWare菜单中设置需要增加到的磁盘大小。
原大小:
点击“扩展”改成40GB
更改后大小:
2:对新增加的硬盘进行分区、格式化
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 --查看分区
Disk /dev/sda: 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 label type: dos
Disk identifier: 0x000d43df
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris
/dev/sda3 4810752 104857599 50023424 83 Linux
Command (m for help): d --删除
Partition number (1-3, default 3): 3
Partition 3 is deleted
Command (m for help): n --新加
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (4810752-104857599, default 4810752):
Using default value 4810752
Last sector, +sectors or +size{K,M,G} (4810752-104857599, default 104857599):
Using default value 104857599
Partition 3 of type Linux and of size 47.7 GiB is set
Command (m for help): w --写入保存
[root@localhost ~]# 重启电脑 shutdown -r now
--此时/dev/sda3 大小还没变,需要卸载重新,卸载 不掉用后面xfs_growfs命令
[root@localhost ~]umount /dev/sda3 --卸载
[root@localhost ~]mount /dev/sda3 / --重新挂载
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 16G 2.0G 89% /
devtmpfs 474M 0 474M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 7.0M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 297M 141M 156M 48% /boot
tmpfs 98M 8.0K 98M 1% /run/user/42
tmpfs 98M 20K 98M 1% /run/user/0
[root@localhost ~]# xfs_growfs /dev/sda3 --增加 XFS 文件系统的大小
meta-data=/dev/sda3 isize=512 agcount=4, agsize=1160384 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4641536, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 4641536 to 12505856
[root@localhost ~]# df -h --扩容成功
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 48G 16G 32G 33% /
devtmpfs 474M 0 474M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 7.0M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 297M 141M 156M 48% /boot
tmpfs 98M 4.0K 98M 1% /run/user/42
tmpfs 98M 20K 98M 1% /run/user/0
[root@localhost ~]#