概要
- Vagrantの仮想環境での共有フォルダ-設定
- 環境はWindows10、Vagrant、VirtualBox、bento/Centos-7.7
- この過程でカーネルのアップデートが必要
Vagrant初期起動
bento/Centos-7.7の前にCentos/7のBoxで共有設定をしたときにvagrant-vbguestパッケージをインストール済みだったので、GuestAdditionsの不整合は解決されている様子。
ただしkernelのバージョン不整合は解決されない。
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 |
C:\vagrant\centos7>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'bento/centos-7.7'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'bento/centos-7.7' version '202005.12.0' is up to date... ..... [default] GuestAdditions versions on your host (6.1.18) and guest (6.1.6) do not match. Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp Resolving Dependencies --> Running transaction check ---> Package centos-release.x86_64 0:7-8.2003.0.el7.centos will be updated ---> Package centos-release.x86_64 0:7-9.2009.1.el7.centos will be an update --> Finished Dependency Resolution Dependencies Resolved ..... Updated: centos-release.x86_64 0:7-9.2009.1.el7.centos Complete! Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp No package kernel-devel-3.10.0-1127.el7.x86_64 available. Error: Nothing to do Unmounting Virtualbox Guest Additions ISO from: /mnt umount: /mnt: not mounted ==> default: Checking for guest additions in VM... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! umount /mnt Stdout from the command: Stderr from the command: umount: /mnt: not mounted |
SSH接続・カーネルアップデート
- VagrantからSSH接続して仮想環境にログイン
- 仮想環境下でyumによってカーネルをアップデート
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 |
[vagrant@localhost ~]$ sudo yum -y update kernel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp Resolving Dependencies --> Running transaction check ---> Package kernel.x86_64 0:3.10.0-1160.15.2.el7 will be installed --> Processing Dependency: linux-firmware >= 20190429-72 for package: kernel-3.10.0-1160.15.2.el7.x86_64 --> Running transaction check ---> Package linux-firmware.noarch 0:20200421-80.git78c0348.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: kernel x86_64 3.10.0-1160.15.2.el7 updates 50 M Installing for dependencies: linux-firmware noarch 20200421-80.git78c0348.el7_9 updates 80 M Transaction Summary ================================================================================ Install 1 Package (+1 Dependent package) Total download size: 131 M Installed size: 458 M Downloading packages: No Presto metadata available for updates (1/2): kernel-3.10.0-1160.15.2.el7.x86_64.rpm | 50 MB 00:07 (2/2): linux-firmware-20200421-80.git78c0348.el7_9.noarch. | 80 MB 00:11 -------------------------------------------------------------------------------- Total 11 MB/s | 131 MB 00:11 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : linux-firmware-20200421-80.git78c0348.el7_9.noarch 1/2 Installing : kernel-3.10.0-1160.15.2.el7.x86_64 2/2 Verifying : linux-firmware-20200421-80.git78c0348.el7_9.noarch 1/2 Verifying : kernel-3.10.0-1160.15.2.el7.x86_64 2/2 Installed: kernel.x86_64 0:3.10.0-1160.15.2.el7 Dependency Installed: linux-firmware.noarch 0:20200421-80.git78c0348.el7_9 Complete! |
Vagrant再起動
- exitで仮想環境から抜けてホスト環境に戻る
- ホスト環境でVagrantを再起動
- ここでかなり時間をかけて環境設定が行われる
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
[vagrant@localhost ~]$ exit logout Connection to 127.0.0.1 closed. C:\vagrant\centos7>vagrant reload ==> default: Attempting graceful shutdown of VM... ==> default: Checking if box 'bento/centos-7.7' version '202005.12.0' is up to date... ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection reset. Retrying... ==> default: Machine booted and ready! [default] No Virtualbox Guest Additions installation found. Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp Package 1:make-3.82-24.el7.x86_64 already installed and latest version Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package binutils.x86_64 0:2.27-43.base.el7 will be updated ---> Package binutils.x86_64 0:2.27-44.base.el7 will be an update ---> Package elfutils-libelf-devel.x86_64 0:0.176-5.el7 will be installed --> Processing Dependency: elfutils-libelf(x86-64) = 0.176-5.el7 for package: elfutils-libelf-devel-0.176-5.el7.x86_64 --> Processing Dependency: pkgconfig(zlib) for package: elfutils-libelf-devel-0.176-5.el7.x86_64 ---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed --> Processing Dependency: libgomp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64 --> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64 --> Processing Dependency: libgcc >= 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64 --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-44.el7.x86_64 ---> Package kernel-devel.x86_64 0:3.10.0-1160.15.2.el7 will be installed ---> Package perl.x86_64 4:5.16.3-295.el7 will be updated ---> Package perl.x86_64 4:5.16.3-299.el7_9 will be an update --> Processing Dependency: perl-libs = 4:5.16.3-299.el7_9 for package: 4:perl-5.16.3-299.el7_9.x86_64 --> Running transaction check ---> Package cpp.x86_64 0:4.8.5-44.el7 will be installed ---> Package elfutils-libelf.x86_64 0:0.176-4.el7 will be updated --> Processing Dependency: elfutils-libelf(x86-64) = 0.176-4.el7 for package: elfutils-libs-0.176-4.el7.x86_64 ---> Package elfutils-libelf.x86_64 0:0.176-5.el7 will be an update ---> Package glibc-devel.x86_64 0:2.17-323.el7_9 will be installed --> Processing Dependency: glibc-headers = 2.17-323.el7_9 for package: glibc-devel-2.17-323.el7_9.x86_64 --> Processing Dependency: glibc = 2.17-323.el7_9 for package: glibc-devel-2.17-323.el7_9.x86_64 --> Processing Dependency: glibc-headers for package: glibc-devel-2.17-323.el7_9.x86_64 ---> Package libgcc.x86_64 0:4.8.5-39.el7 will be updated ---> Package libgcc.x86_64 0:4.8.5-44.el7 will be an update ---> Package libgomp.x86_64 0:4.8.5-39.el7 will be updated ---> Package libgomp.x86_64 0:4.8.5-44.el7 will be an update ---> Package perl-libs.x86_64 4:5.16.3-295.el7 will be updated ---> Package perl-libs.x86_64 4:5.16.3-299.el7_9 will be an update ---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed --> Processing Dependency: zlib = 1.2.7-19.el7_9 for package: zlib-devel-1.2.7-19.el7_9.x86_64 --> Running transaction check ---> Package elfutils-libs.x86_64 0:0.176-4.el7 will be updated ---> Package elfutils-libs.x86_64 0:0.176-5.el7 will be an update ---> Package glibc.x86_64 0:2.17-307.el7.1 will be updated --> Processing Dependency: glibc = 2.17-307.el7.1 for package: glibc-common-2.17-307.el7.1.x86_64 ---> Package glibc.x86_64 0:2.17-323.el7_9 will be an update ---> Package glibc-headers.x86_64 0:2.17-323.el7_9 will be installed --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-323.el7_9.x86_64 --> Processing Dependency: kernel-headers for package: glibc-headers-2.17-323.el7_9.x86_64 ---> Package zlib.x86_64 0:1.2.7-18.el7 will be updated ---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update --> Running transaction check ---> Package glibc-common.x86_64 0:2.17-307.el7.1 will be updated ---> Package glibc-common.x86_64 0:2.17-323.el7_9 will be an update ---> Package kernel-headers.x86_64 0:3.10.0-1160.15.2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: elfutils-libelf-devel x86_64 0.176-5.el7 base 40 k gcc x86_64 4.8.5-44.el7 base 16 M kernel-devel x86_64 3.10.0-1160.15.2.el7 updates 18 M Updating: binutils x86_64 2.27-44.base.el7 base 5.9 M perl x86_64 4:5.16.3-299.el7_9 updates 8.0 M Installing for dependencies: cpp x86_64 4.8.5-44.el7 base 5.9 M glibc-devel x86_64 2.17-323.el7_9 updates 1.1 M glibc-headers x86_64 2.17-323.el7_9 updates 691 k kernel-headers x86_64 3.10.0-1160.15.2.el7 updates 9.0 M zlib-devel x86_64 1.2.7-19.el7_9 updates 50 k Updating for dependencies: elfutils-libelf x86_64 0.176-5.el7 base 195 k elfutils-libs x86_64 0.176-5.el7 base 291 k glibc x86_64 2.17-323.el7_9 updates 3.6 M glibc-common x86_64 2.17-323.el7_9 updates 12 M libgcc x86_64 4.8.5-44.el7 base 103 k libgomp x86_64 4.8.5-44.el7 base 159 k perl-libs x86_64 4:5.16.3-299.el7_9 updates 690 k zlib x86_64 1.2.7-19.el7_9 updates 90 k Transaction Summary ================================================================================ Install 3 Packages (+5 Dependent packages) Upgrade 2 Packages (+8 Dependent packages) Total download size: 81 M Downloading packages: No Presto metadata available for base No Presto metadata available for updates -------------------------------------------------------------------------------- Total 11 MB/s | 81 MB 00:07 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : libgcc-4.8.5-44.el7.x86_64 1/28 Updating : glibc-common-2.17-323.el7_9.x86_64 2/28 Updating : glibc-2.17-323.el7_9.x86_64 3/28 Updating : zlib-1.2.7-19.el7_9.x86_64 4/28 Updating : elfutils-libelf-0.176-5.el7.x86_64 5/28 Updating : 4:perl-libs-5.16.3-299.el7_9.x86_64 6/28 Updating : 4:perl-5.16.3-299.el7_9.x86_64 7/28 Updating : binutils-2.27-44.base.el7.x86_64 8/28 Installing : cpp-4.8.5-44.el7.x86_64 9/28 Installing : zlib-devel-1.2.7-19.el7_9.x86_64 10/28 Updating : libgomp-4.8.5-44.el7.x86_64 11/28 Installing : kernel-headers-3.10.0-1160.15.2.el7.x86_64 12/28 Installing : glibc-headers-2.17-323.el7_9.x86_64 13/28 Installing : glibc-devel-2.17-323.el7_9.x86_64 14/28 Installing : gcc-4.8.5-44.el7.x86_64 15/28 Installing : elfutils-libelf-devel-0.176-5.el7.x86_64 16/28 Installing : kernel-devel-3.10.0-1160.15.2.el7.x86_64 17/28 Updating : elfutils-libs-0.176-5.el7.x86_64 18/28 Cleanup : elfutils-libs-0.176-4.el7.x86_64 19/28 Cleanup : 4:perl-libs-5.16.3-295.el7.x86_64 20/28 Cleanup : 4:perl-5.16.3-295.el7.x86_64 21/28 Cleanup : elfutils-libelf-0.176-4.el7.x86_64 22/28 Cleanup : binutils-2.27-43.base.el7.x86_64 23/28 Cleanup : zlib-1.2.7-18.el7.x86_64 24/28 Cleanup : libgomp-4.8.5-39.el7.x86_64 25/28 Cleanup : glibc-common-2.17-307.el7.1.x86_64 26/28 Cleanup : glibc-2.17-307.el7.1.x86_64 27/28 Cleanup : libgcc-4.8.5-39.el7.x86_64 28/28 Verifying : glibc-headers-2.17-323.el7_9.x86_64 1/28 Verifying : zlib-1.2.7-19.el7_9.x86_64 2/28 Verifying : binutils-2.27-44.base.el7.x86_64 3/28 Verifying : glibc-devel-2.17-323.el7_9.x86_64 4/28 Verifying : kernel-headers-3.10.0-1160.15.2.el7.x86_64 5/28 Verifying : glibc-2.17-323.el7_9.x86_64 6/28 Verifying : cpp-4.8.5-44.el7.x86_64 7/28 Verifying : kernel-devel-3.10.0-1160.15.2.el7.x86_64 8/28 Verifying : glibc-common-2.17-323.el7_9.x86_64 9/28 Verifying : zlib-devel-1.2.7-19.el7_9.x86_64 10/28 Verifying : elfutils-libelf-0.176-5.el7.x86_64 11/28 Verifying : elfutils-libelf-devel-0.176-5.el7.x86_64 12/28 Verifying : gcc-4.8.5-44.el7.x86_64 13/28 Verifying : 4:perl-5.16.3-299.el7_9.x86_64 14/28 Verifying : 4:perl-libs-5.16.3-299.el7_9.x86_64 15/28 Verifying : libgcc-4.8.5-44.el7.x86_64 16/28 Verifying : libgomp-4.8.5-44.el7.x86_64 17/28 Verifying : elfutils-libs-0.176-5.el7.x86_64 18/28 Verifying : 4:perl-libs-5.16.3-295.el7.x86_64 19/28 Verifying : zlib-1.2.7-18.el7.x86_64 20/28 Verifying : glibc-common-2.17-307.el7.1.x86_64 21/28 Verifying : libgcc-4.8.5-39.el7.x86_64 22/28 Verifying : libgomp-4.8.5-39.el7.x86_64 23/28 Verifying : elfutils-libelf-0.176-4.el7.x86_64 24/28 Verifying : glibc-2.17-307.el7.1.x86_64 25/28 Verifying : binutils-2.27-43.base.el7.x86_64 26/28 Verifying : elfutils-libs-0.176-4.el7.x86_64 27/28 Verifying : 4:perl-5.16.3-295.el7.x86_64 28/28 Installed: elfutils-libelf-devel.x86_64 0:0.176-5.el7 gcc.x86_64 0:4.8.5-44.el7 kernel-devel.x86_64 0:3.10.0-1160.15.2.el7 Dependency Installed: cpp.x86_64 0:4.8.5-44.el7 glibc-devel.x86_64 0:2.17-323.el7_9 glibc-headers.x86_64 0:2.17-323.el7_9 kernel-headers.x86_64 0:3.10.0-1160.15.2.el7 zlib-devel.x86_64 0:1.2.7-19.el7_9 Updated: binutils.x86_64 0:2.27-44.base.el7 perl.x86_64 4:5.16.3-299.el7_9 Dependency Updated: elfutils-libelf.x86_64 0:0.176-5.el7 elfutils-libs.x86_64 0:0.176-5.el7 glibc.x86_64 0:2.17-323.el7_9 glibc-common.x86_64 0:2.17-323.el7_9 libgcc.x86_64 0:4.8.5-44.el7 libgomp.x86_64 0:4.8.5-44.el7 perl-libs.x86_64 4:5.16.3-299.el7_9 zlib.x86_64 0:1.2.7-19.el7_9 Complete! Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso Mounting Virtualbox Guest Additions ISO to: /mnt mount: /dev/loop0 is write-protected, mounting read-only Installing Virtualbox Guest Additions 6.1.18 - guest version is unknown Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.18 Guest Additions for Linux........ VirtualBox Guest Additions installer Removing installed version 6.1.6 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 3.10.0-1160.15.2.el7.x86_64. Redirecting to /bin/systemctl start vboxadd.service Redirecting to /bin/systemctl start vboxadd-service.service Unmounting Virtualbox Guest Additions ISO from: /mnt ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => C:/vagrant/centos7 ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run. |
共有設定・再起動
- 共有設定の最終段階
- ホスト側の共有フォルダ-を作成
- vagrantfileに1行追加
- vagrant reloadでVagrantを再起動
- 仮想環境下にもフォルダーが作成され、同期される
vagrantfile設定
config.vm.synced_folder "ホスト側パス", "ゲスト側パス"
- 第1引数はホスト側パスで、vagrantfileからの相対パスで指定
- ホスト側で共有ディレクトリーを作成しておく必要がある
- 第2引数はゲストパスで、絶対パスで指定
- ゲスト側の共有ディレクトリーはVagrantが作成してくれる
1 2 3 4 5 6 7 |
Vagrant.configure("2") do |config| ..... config.vm.box = "bento/centos-7.7" ..... config.vm.synced_folder "./share", "/home/vagrant/share" ..... end |
Vagrant再起動
Vagrantを再起動すると、共有フォルダ-が作成される。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
C:\vagrant\centos7>vagrant reload ==> default: Attempting graceful shutdown of VM... ==> default: Checking if box 'bento/centos-7.7' version '202005.12.0' is up to date... ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection reset. Retrying... default: Warning: Connection aborted. Retrying... ==> default: Machine booted and ready! [default] GuestAdditions 6.1.18 running --- OK. ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => C:/vagrant/centos7 default: /home/vagrant/share => C:/vagrant/centos7/share ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run. |
フォルダー配置
- ホスト側:C\vagrant\centos7\share
- ゲスト側:/home/vagrant/share