Установка alpine linux virtualbox

Установка alpine linux virtualbox

My current use for this VM is to run ansible. I use SSH to access the VM (both for running commands and transferring files), so don’t bother running a GUI on it, or shared folders.

This document was tested with VirtualBox v5.0.20 r106931, running under Windows 7, and installing AlpineLinux v3.3.3 x64. It is assumed that VirtualBox is already installed.

Obtain installer ISO

Go to the downloads section of https://alpinelinux.org/ and download the 64-bit «Standard ISO» — I got alpine-3.3.3-x86_64.iso — save it somewhere you can find it again.

Setup VM

  • Start VirtualBox, and click [New] to create a new VM.
  • Set the name as suits you, set Type=»Linux», Version=»Linux 2.6 / 3.x / 4.x (64bit)», click [Next].
  • Set Memory size to 256MB, click [Next].
  • Select «Create a new virtual hard disk» and click [Create].
  • Select «VDI» and click [Next].
  • Select «Dynamically allocated» and click [Next].
  • Set size to 2GB and click [Create].

The blank machine should now be created, and will be listed in the VirtualBox window, on the left. Right-click on the machine and choose «Settings». Configure as follows:

  • System > Motherboard
    • Base Memory = 256MB
    • Boot Order = Optical, Hard Disk (untick Floppy)
    • Pointing Device = PS/2 Mouse
    • Hardware clock in UTC Time
    • Video Memory = 1MB
      • NOTE: VirtualBox will complain about this, but I’m planning to connect via ssh, so will not be using any appreciable amount of video ram.
      • in the Storage Tree, select the CD just under «Controller IDE»
      • in the Attributes section, click on the CD icon at the far right.
      • Choose Virtual Optical Disk File and select your ISO (alpine-3.3.3-x86_64.iso)
      • disable
      • Adapter1 attached to: NAT
      • Click the blue triangle to expand «Advanced» settings, then click [Port Forwarding]
      • In the top-right corner, click the green symbol with the «+» on it
        • Name = «SSH»
        • Protocol = «TCP»
        • Host Port = «22022» (or whatever suits you)
        • Guest Port = «22»
        • click [OK]
        • disable
        • disable

        Basic Alpine Linux Install

        Run «setup-alpine», and configure as follows:

        • keyboard layout = «us»
        • keyboard variant = «us»
        • system hostname = whatever suits you
        • initialise interface: «eth0»
        • «dhcp»
        • no manual setup
        • enter root password, as desired.
        • timezone: «Pacific/Auckland» (or whatever suits you)
        • HTTP/FTP proxy URL: [none]
        • Detect and add fastest mirror (f)
        • SSH server: «openssh»
        • NTP client: «chrony»
        • install to disk: «sda»
        • install type: «sys»
        • erase & continue? Y

        Now run «poweroff» to shutdown the VM — this is necessary in order to reboot into the installed system, so we can install things there.

        Remove CD

        In the main VirtualBox window, right-click on the machine and choose «Settings». Reconfigure as follows:

        • Storage
          • in the Storage Tree, select the CD just under «Controller IDE».
          • in the Attributes section, click on the CD icon at the far right.
          • Choose «Remove disk from virtual drive», and click OK.

          Update Packages

          Start the VM. When it has finished booting, the login prompt should show the hostname you selected (instead of «localhost»). Login as «root», using the password you setup.

          Use vi to edit the repositories — uncomment all the URL lines to enable them all.

          It should look something like this (but probably different URLs, depending on which ones were detected as being fastest for you):

          #/media/cdrom/apks http://dl-6.alpinelinux.org/alpine/v3.3/main http://dl-6.alpinelinux.org/alpine/v3.3/community http://dl-6.alpinelinux.org/alpine/edge/main http://dl-6.alpinelinux.org/alpine/edge/community http://dl-6.alpinelinux.org/alpine/edge/testing 

          Update the package list and upgrade what has already been installed:

          The base install at this stage will have used about 25MB of the boot partition (nominally about 100MB, but 92.8MB reported), 512MB as swap, and 270MB of the root partition — if the base disk was 2GB, about 1GB is free on the root drive.

          Setup User and Sudo

          Create the sudo group, create a non-root user (use whatever username you like, instead of «otheruser»), and add the new user to the sudo group:

          addgroup sudo adduser otheruser adduser otheruser sudo 

          Run «visudo» and remove the «#» comment character from the 2nd line in this group so it looks like:

          ## Uncomment to allow members of group sudo to execute any command %sudo ALL=(ALL) ALL 

          Setup VirtualBox Drivers

          The VirtualBox drivers improve performance of a VM running under VirtualBox.

          apk add virtualbox-guest-modules-grsec virtualbox-additions-grsec 

          Reboot the VM by typing «reboot».

          Test

          You should now be able to login as the non-root user you created (using the non-root password you provided).

          Once logged in, you should be able to execute commands as root by using sudo (and the non-root user password), eg. «sudo apk update» — if sudo is not working correctly, it will give an error, eg. if you weren’t using sudo at all:

          testvm:~$ apk update ERROR: Unable to lock database: Permission denied ERROR: Failed to open apk database: Permission denied 

          If sudo is working correctly, the command will execute, eg.:

          testvm:~$ sudo apk update fetch http://dl-6.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz fetch http://dl-6.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz fetch http://dl-6.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz fetch http://dl-6.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz fetch http://dl-6.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz v3.3.3-46-ge9c0256 [http://dl-6.alpinelinux.org/alpine/v3.3/main] v3.3.3-47-g150c9b2 [http://dl-6.alpinelinux.org/alpine/v3.3/community] v160223-1826-g4681e7d [http://dl-6.alpinelinux.org/alpine/edge/main] v160223-1826-g4681e7d [http://dl-6.alpinelinux.org/alpine/edge/community] v160223-1826-g4681e7d [http://dl-6.alpinelinux.org/alpine/edge/testing] OK: 15131 distinct packages available 

          SSH

          It should also be possible to SSH from the host machine to the VM at address «localhost» (or «127.0.0.1»), and port «22022»

          References

          Источник

          Alpine Install: from a disc to a virtualbox machine single only

          Overall description: Installing Alpine from an official disc image to a VirtualBox machine.

          This document guides you through installing Alpine on a VirtualBox VM — this is ideal if you only want to try out Alpine.

          Terminology

          • Host machine: the machine you’re running VirtualBox on. It will «host» the target virtual machine.
          • Guest machine: your target machine where Alpine will be installed, executed by the VirtualBox software on the host machine.
          • Reserved RAM: the amount of host machine RAM that will be needed for exclusive use by the guest machine. The host machine cannot use this RAM while the guest machine is running.
          • Virtual disc: the emulated storage medium attached to the guest machine. Usually it is a file (or several files) which VirtualBox presents as a disk to the guest OS (Alpine).

          Requirements

          • VirtualBox
          • At least 1GB of RAM, 2GB or more is recommended
          • Some means to download the install image (wget, curl, web browser)

          Preparing the medium to install

          Download the source medium to install and put into your home; there’s more hardware medium sources to download, like the s390x and ppc64le, but because VirtualBox handles only x86 and x64 hardware, we will list those here

          The name of the source medium to install will be in the following format: http://dl-cdn.alpinelinux.org/alpine/v/releases//alpine-standard-.0-.iso where ARCH and VERSION can be one of the following, for VirtualBox virtual machines:

Оцените статью
Adblock
detector