虚拟机相关问题
VMware设置共享文件夹
有时可能会有需要主机传文件给虚拟机的需求,这里参考了 https://blog.csdn.net/twilight1999/article/details/123867565
在虚拟机设置的选项界面中选择 共享文件夹:总是启用
在主机中创建共享文件夹并添加路径
进入虚拟机
进入
/mnt
目录1
cd /mnt
创建共享文件夹
share_files
(可自定义)1
mkdir share_files
挂载
1
mount -t fuse.vmhgfs- fuse .host:/ /mnt/share_files/ -o allow_other
永久挂载设置
执行
vim /etc/fstab
添加内容:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda3 during installation
UUID=490e9afd-48f7-4732-b429-f76a64f20a6c / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda2 during installation
UUID=1D8B-E5FD /boot/efi vfat umask=0077 0 1
/swapfile none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
# 添加以下内容
.host:/ /mnt/share fuse.vmhgfs- fuse allow_other 0 0
另外介绍上面使用的挂载指令:
挂载命令的指令详情:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67mount -h
Usage:
mount [-lhV]
mount -a [options]
mount [options] [--source] <source> | [--target] <directory>
mount [options] <source> <directory>
mount <operation> <mountpoint> [<target>]
Mount a filesystem.
Options:
-a, --all mount all filesystems mentioned in fstab
-c, --no-canonicalize don't canonicalize paths
-f, --fake dry run; skip the mount(2) syscall
-F, --fork fork off for each device (use with -a)
-T, --fstab <path> alternative file to /etc/fstab
-i, --internal-only don't call the mount.<type> helpers
-l, --show-labels show also filesystem labels
-n, --no-mtab don't write to /etc/mtab
--options-mode <mode>
what to do with options loaded from fstab
--options-source <source>
mount options source
--options-source-force
force use of options from fstab/mtab
-o, --options <list> comma-separated list of mount options
-O, --test-opts <list> limit the set of filesystems (use with -a)
-r, --read-only mount the filesystem read-only (same as -o ro)
-t, --types <list> limit the set of filesystem types
--source <src> explicitly specifies source (path, label, uuid)
--target <target> explicitly specifies mountpoint
--target-prefix <path>
specifies path used for all mountpoints
-v, --verbose say what is being done
-w, --rw, --read-write mount the filesystem read-write (default)
-N, --namespace <ns> perform mount in another namespace
-h, --help display this help
-V, --version display version
Source:
-L, --label <label> synonym for LABEL=<label>
-U, --uuid <uuid> synonym for UUID=<uuid>
LABEL=<label> specifies device by filesystem label
UUID=<uuid> specifies device by filesystem UUID
PARTLABEL=<label> specifies device by partition label
PARTUUID=<uuid> specifies device by partition UUID
ID=<id> specifies device by udev hardware ID
<device> specifies device by path
<directory> mountpoint for bind mounts (see --bind/rbind)
<file> regular file for loopdev setup
Operations:
-B, --bind mount a subtree somewhere else (same as -o bind)
-M, --move move a subtree to some other place
-R, --rbind mount a subtree and all submounts somewhere else
--make-shared mark a subtree as shared
--make-slave mark a subtree as slave
--make-private mark a subtree as private
--make-unbindable mark a subtree as unbindable
--make-rshared recursively mark a whole subtree as shared
--make-rslave recursively mark a whole subtree as slave
--make-rprivate recursively mark a whole subtree as private
--make-runbindable recursively mark a whole subtree as unbindable
For more details see mount(8).mount
命令用来挂载Linux系统外的文件,上面使用的mount -t fuse.vmhgfs- fuse .host:/ /mnt/share_files/ -o allow_other
命令用来挂载vmhgfs
文件系统类型的虚拟机共享文件系统。-t
指定了文件系统的类型,这里是fuse.vmhgfs
,fuse
会在下面解释-o allow_other
指定挂载选项,允许其他用户访问挂载点上的文件。.host:/
指定虚拟机宿主机上共享文件系统的路径/mnt/share_files
是将要挂载共享文件系统的目标目录,执行命令后共享文件系统的内容会在此目录下显示(注:/mnt
就是Linux系统提供给用户来临时挂载其他文件系统的,如光驱)
fuse
(FUSE: Filesystem in Userspace,用户空间文件系统)NAME:
fuse - format and options for the fuse file systems
DESCRIPTION
FUSE(Filesystem in Userspace) is a simple interface for userspace programs to export a virtual filesystem to the Linux kernel. FUSE also aims to provide a secure method for non privileged users to create and mount their own filesystem implementations.
CONFIGURATION
Some options regarding mount policy can be set in the file
/etc/fuse.conf
.Currently these options are:
mount_max = NNN
:- Set the maximum number of FUSE mounts allowed to non-root users. The default is 1000.
user_allow_other
:- Allow non-root users to specify the allow_other or allow_root mount options (see below).
- FUSE是一个简单的接口,用于让用户控件程序向Linux内核导出一个虚拟文件系统
- 用户空间的程序可以通过FUSE创建和管理文件系统,而无需了解内核(作为接口就是干这个的)
- 关于挂载策略的选项在
/etc/fuse.conf
文件中配置
allow_other
allow_other
This option overrides the security measure restricting file access to the user mounting the filesystem. So all users (including root) can access the files. This option is by default only allowed to root, but this restriction can be removed with a configuration option described in the previous section.
此选项用于允许所有用户都可以访问挂载点上的文件,而不仅仅是挂载此文件系统的用户
2024/2/10出了点问题
[5.561807] piix4_smbus 0000:00:07.3: SMBuS Host Controller not enabled!
/dev/sda3: clean, 241297/1277952 files, 3773959/5110784 blocks
[FAILED] Failed to mount /mnt/share.
[DEPEND] Dependency failed for Local File systems
[FAILED] Failed to start Set Up Additional Binary Formats .
You are in emergency mode. After logging in, type “journalctl -xb” to view
system logs,”systemctl reboot” to reboot, “systemctl default” or “exit”
to boot into default mode.
Press Enter for maintenance
(or press Control-D to continue):
VMware配置主机代理
简单来说就是虚拟机翻墙。参考 https://blog.csdn.net/weixin_44427114/article/details/109249990
在虚拟机系统的网络设置(Right click -> Display Settings -> Network -> Network Proxy -> Manual)中配置所用协议(HTTP、HTTPS、FTP、Socks Host)的代理ip地址和端口(我没找到自己的cfw用的是哪个,就全写上了)
ip地址可以再主机系统的cmd窗口输入 ipconfig
查询,找到 以太网适配器 VMware Network Adapter VMnet8: 下的IPv4地址就是主机所用的ip地址。
端口号:在所使用的代理软件中可以查询到。
如果不行还可以改一下虚拟机的网络适配器设置为NAT