First, install VirtualBox.
$ brew cask install virtualbox
Next, start VirtualBox and create a new virtual machine from "New". Set the name of the virtual machine to "ubuntu-server-20.04". All you have to do is click the GUI with the default settings.
Click the "Start" icon and select the previously downloaded Ubuntu Server iso file to start the installation.
I thought ... but I got moss here. The error is 「/dev/loop2: Can't open blockdev」 「systemd[1]: Failed unmounting /cdrom.」
e? why?
No matter how many times I try, this screen appears and the virtual machine suddenly crashes. Then, the following error pops up. 「You must specify a machine to start, using the command line....」
It's true that the Mac mini doesn't have a DVD drive, so I wonder if unmounting will give an error ... But I put the iso file in the virtual drive and the installer actually started up from there ... etc. Thinking about it, tweaking the VirtualBox GUI here and there doesn't help.
For the time being, I started the virtual machine from the command line according to the error message.
$ VirtualBoxVM --startvm ubuntu-server-20.04 &
I don't know what it is, but it worked. To be precise, the error of "Can't open block dev" is displayed, but the error of "unmounting" does not appear, the installer runs as it is, and the installation is completed in a blink of an eye. Even after installation, pressing the "Start" button of VirtualBox does not start well, and it starts from the command line. I still don't know why.
It's okay because it starts without problems, but it's unpleasant not to know the reason, so please let me know.
Set up NAT port forwarding (IP masquerade) to connect from the host OS (macOS) to the guest OS (Ubuntu Server) by SSH. Specifically, it is set so that packets that pass through port 2222 of the host OS are diverted to port 22 (SSH port) of the guest OS.
Select "Settings"-> "Network"-> "Advanced"-> "Port Forwarding" in VirtualBox, and set "TCP" as the protocol, "2222" as the host port, and "22" as the guest port (the name is appropriate). Is fine).
Alternatively, you can set it by hitting the following command.
$ VBoxManage modifyvm "ubuntu-server-20.04" --natpf1 "guestssh,tcp,,2222,,22"
Then, specify connection port 2222 and make an SSH connection.
[hajime-f@borneo:~]$ ssh -p 2222 localhost
hajime-f@localhost's password:
...(Omitted)...
Last login: Tue Sep 22 09:49:22 2020
hajime-f@tonga:~$
I was able to land safely from borneo to tonga (Reference: It is interesting to give the host name the name of the southern island).
Maybe instead of configuring a closed network with hosts and guests, you can add an adapter to the guest, assign it a private IP, and resolve it with `/ etc / hosts```, then
`$ ssh I think I can connect with tonga```, but I stopped because it was troublesome.
In the same way, I set up another Ubuntu Server and named it "bali".
Next, I'll play with Docker using these two virtual machines.
Recommended Posts