VagrantBox重新安装vboxsf驱动

端午假期重新安装了Oracle Vagrant Project中的21c数据库,数据库可以用,但在启动过程中最末部分有一个小警告:

C:\WORKSPACE\vagrant-projects\OracleDatabase\21.3.0>vagrant up
Bringing machine 'oracle-21c-vagrant' up with 'virtualbox' provider...
==> oracle-21c-vagrant: Checking if box 'oraclelinux/8' version '8.5.285' is up to date...
==> oracle-21c-vagrant: A newer version of the box 'oraclelinux/8' for provider 'virtualbox' is
==> oracle-21c-vagrant: available! You currently have version '8.5.285'. The latest is version
==> oracle-21c-vagrant: '8.6.331'. Run `vagrant box update` to update.
==> oracle-21c-vagrant: Clearing any previously set forwarded ports...
==> oracle-21c-vagrant: Clearing any previously set network interfaces...
==> oracle-21c-vagrant: Preparing network interfaces based on configuration...
    oracle-21c-vagrant: Adapter 1: nat
==> oracle-21c-vagrant: Forwarding ports...
    oracle-21c-vagrant: 1521 (guest) => 1521 (host) (adapter 1)
    oracle-21c-vagrant: 5500 (guest) => 5500 (host) (adapter 1)
    oracle-21c-vagrant: 22 (guest) => 2222 (host) (adapter 1)
==> oracle-21c-vagrant: Running 'pre-boot' VM customizations...
==> oracle-21c-vagrant: Booting VM...
==> oracle-21c-vagrant: Waiting for machine to boot. This may take a few minutes...
    oracle-21c-vagrant: SSH address: 127.0.0.1:2222
    oracle-21c-vagrant: SSH username: vagrant
    oracle-21c-vagrant: SSH auth method: private key
==> oracle-21c-vagrant: Machine booted and ready!
==> oracle-21c-vagrant: Checking for guest additions in VM...
    oracle-21c-vagrant: No guest additions were detected on the base box for this VM! Guest
    oracle-21c-vagrant: additions are required for forwarded ports, shared folders, host only
    oracle-21c-vagrant: networking, and more. If SSH fails on this machine, please install
    oracle-21c-vagrant: the guest additions and repackage the box to continue.
    oracle-21c-vagrant:
    oracle-21c-vagrant: This is not an error message; everything may continue to work properly,
    oracle-21c-vagrant: in which case you may ignore this message.
==> oracle-21c-vagrant: Setting hostname...
==> oracle-21c-vagrant: Mounting shared folders...
    oracle-21c-vagrant: /vagrant => C:/WORKSPACE/vagrant-projects/OracleDatabase/21.3.0
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

: No such device

登入操作系统,果然没看到/vagrant文件系统,执行提示中的命令也报错:

$ df
Filesystem                  1K-blocks     Used Available Use% Mounted on
devtmpfs                      1846368        0   1846368   0% /dev
tmpfs                         1865028        0   1865028   0% /dev/shm
tmpfs                         1865028    16752   1848276   1% /run
tmpfs                         1865028        0   1865028   0% /sys/fs/cgroup
/dev/mapper/vg_main-lv_root  34070268 15150992  18919276  45% /
/dev/sda1                      506528   154708    351820  31% /boot
tmpfs                          373004        0    373004   0% /run/user/1000

$ ls -lh /sbin/mount.vboxsf
lrwxrwxrwx. 1 root root 49 Jun  4 06:58 /sbin/mount.vboxsf -> /opt/VBoxGuestAdditions-6.1.26/other/mount.vboxsf

$ sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
/sbin/mount.vboxsf: mounting failed with the error: No such device

参照这篇文章:Vagrant was unable to mount VirtualBox shared folders,重新安装驱动:

VBVER=6.1.34
sudo wget -c http://download.virtualbox.org/virtualbox/${VBVER}/VBoxGuestAdditions_${VBVER}.iso -O VBoxGuestAdditions_${VBVER}.iso
sudo mount VBoxGuestAdditions_${VBVER}.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run

假设6.1.34为VIrtualBox当前最新的版本。此ISO文件约60MB

最后一步运行时间较长,约2分半:

$ time sudo sh /mnt/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.34 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.1.26 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel
5.4.17-2136.307.3.5.el8uek.x86_64.

real    2m32.873s
user    2m18.718s
sys     0m24.616s

然后以下命令正常:

$ sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
$ df
Filesystem                  1K-blocks      Used Available Use% Mounted on
devtmpfs                      1846368         0   1846368   0% /dev
tmpfs                         1865028         0   1865028   0% /dev/shm
tmpfs                         1865028     16776   1848252   1% /run
tmpfs                         1865028         0   1865028   0% /sys/fs/cgroup
/dev/mapper/vg_main-lv_root  34070268  15211740  18858528  45% /
/dev/sda1                      506528    154384    352144  31% /boot
tmpfs                          373004         0    373004   0% /run/user/1000
/dev/loop0                      60096     60096         0 100% /mnt
vagrant                     242218284 205162368  37055916  85% /vagrant

此时vagrant box启动时就没有警告了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值