Nice to meet you. It is called "Snorlax". I usually work as a data scientist at a financial institution who doesn't try to understand the business. I would like to keep a record of my struggle as the first article of Qiita.
When studying Docker on Udemy, I needed to set up a shared folder for VirtualBox (host OS ⇔ guest OS), and I fell in love with it. Although there are articles by the pioneers, none of them can be solved as they are, and after learning the ensemble of various information, the settings have been made, so I will write them here including a memorandum. I hope it helps those who are referred to.
(Host OS) Windows10 pro (Guest OS:virtual)CentOS7.7 (1908) CLI (Virtualization)VirtualBox 6.1.8-137981 Trial time: 2020/05/28
It omits from CentOS installation to startup.
In VirtualBox, there are setting items that seem to be very kind, such as [Settings]> [Shared Folder], and I wondered if I could do it by specifying the folder of the host OS here. Before setting up shared folders in VirtualBox You have to set up something called "Guest Additions".
The flow is explained below.
After moving to root privileges with su
Update the packages and install the required packages.
yum -y update
yum -y install kernel-devel kernel-headers gcc gcc-c++
yum -y install bzip2
If you start with kernel-devel
and kernel-headers
, it will be inconsistent with existing kernels that have not been updated, so update the kernel (included in yum -y update
) first. It makes sense to do it.
We recommend that you install bzip2
here as you will need it later.
Once the above steps are complete, use reboot
to *** reboot ***!
(After restarting, use the su
command to transfer to root privileges.)
GuestAdditions are installed in the iso image format, but they are included as standard in VirtualBox without any special acquisition.
Select [Device]> [Insert Guest Additions CD Image ...] in VirtualBox and connect.
Mount the connected disk image in the media
folder in CentOS.
mount -r /dev/cdrom /media
Go to the media
folder and
After the mount is complete, run the installation from the mount image.
The bzip2
package is required for VBoxLinuxAdditions.run
to be done here.
cd /media
sh ./VBoxLinuxAdditions.run
After the installation is complete, unmount the image and reboot ***.
cd
umount /media
reboot
Unmounting can also be done from the GUI.
After returning from the restart, from [Device]> [Shared Folder]> [Shared Folder Settings] Set the folder you want to share in the host OS (Windows this time).
Select [Shared Folder Settings] to move to the window below.
Select "Shared Folder" and press the Add New button on the right.
Select any folder. (This time, the folder name is docker_file
)
Also,
-[x] Auto mount (A) -[x] Persist (M)
Check the box and press [OK] to close.
Now, in the guest OS (CentOS), it will be shared as / media / sf_ {shared folder name}
in this case, / media / sf_docker_file
.
If you want to mount other than / media / sf_ {shared folder name}
above,
su
cd media/
mount -t vboxsf sf_{Shared folder name} {Mount destination directory name}
reboot
With, you can make another folder a shared folder in the guest OS.
With the above steps, the shared folder will be available to the root user, but if you want to give other general users access to the shared folder, add the user with the following command.
su
gpasswd --add {User name} vboxsf
I have referred to each article very much, and some parts have been quoted. If you find it annoying, I would appreciate it if you could point it out.
--Install Guest Additions on Linux on VirtualBox and set shared folders
-How to create a shared folder between the host OS and guest OS (Ubuntu) in VirtualBox
-How to create a shared folder with Guest Additions on CentOS, the guest OS with VirtualBox
Recommended Posts