Difference between revisions of "Install Alpine on VirtualBox"

From Alpine Linux
Jump to: navigation, search
(Development Environment: initial slash not used in lbu add)
(Install drivers for Virtual Box)
 
(14 intermediate revisions by 6 users not shown)
Line 1: Line 1:
=How To Install Alpine on VirtualBox=
+
This guide describes a standard install of Alpine within a virtual computer created by Virtual Box.
  
[http://virtualbox.org VirtualBox] is a Sun/Oracle  virtualization product for x86 architecture.
+
Oracle VM [http://virtualbox.org VirtualBox] runs one or more virtual x86 or AMD64/Intel64 computer (guest) within another computer (host). This allows you to install and test Alpine on your main computer almost as you would any other program.
This document describes one way to install alpine to that platform.
 
  
=Before You Start=
+
=Preparation=
  
First [{{#latestalp:alpine|url}} download latest Alpine CD image].
+
==Install Virtual Box on host==
  
=Create the Virtual Machine=
+
First of all, you need to download and install Virtual Box on your host computer, either from the official homepage (for Windows, OS X or Solaris) or from your distribution’s repository (for Linux).
  
Start by creating new VM and setting it to run linux with 2.6 series kernel.<br>
+
Virtual Box consists of two components:  
[[File:alpine-vbox-1.png]]<br>
 
<br>
 
Set amount of memory. Since alpine runs in memory the recommended 256 MB might be too little for your needs.<br>
 
[[File:alpine-vbox-2.png]]<br>
 
<br>
 
Create a disk. I wanted to emulate a Compact Flash system, so the setting is 2GB. This could be much higher if you like.<br>
 
[[File:alpine-vbox-3.png]]<br>
 
[[File:alpine-vbox-4.png]]<br>
 
[[File:alpine-vbox-5.png]]<br>
 
  
=Start the Virtual Machine=
+
* VirtualBox platform package
After '''Start'''ing the virtual machine, the first run wizard will ask for a cd image.
+
* Oracle VM VirtualBox Extension Pack
Mount your downloaded alpine.iso image here.
 
<br>
 
[[File:alpine-vbox-1strun-1.png]]
 
<br>
 
<br>
 
  
=Install Alpine=
+
Install both and start VirtualBox, to see whether it works. If it does not, consult the VirtualBox user manual or one of the support sites for Virtual Box.
After Alpine boots type ''root'' to login.
 
<br>
 
Find out the virtual harddisk ID.
 
{{Cmd|dmesg <nowiki>|</nowiki> grep disk}}
 
With default settings in the VirtualBox this will be '''sda'''.
 
  
I made the actual installation using
+
==Download Alpine==
[[Installing Alpine on Compact Flash|CF installation instructions]], but
 
[[Installing Alpine on HDD overwriting everything|basic HD installation]] should work too.
 
  
{{Note|With CF install remember to edit <code>/media/sda1/syslinux.cfg</code> to boot from the HD (<nowiki>alpine_dev=sda1:vfat</nowiki>)
+
Download the [https://www.alpinelinux.org/downloads/ Virtual Alpine ISO], which is optimized for virtual systems, from the Alpine Download section. Save it in a folder where you can find it easily.  
{{Cmd|vi /media/sda1/syslinux.cfg}}
 
}}
 
  
=Configure Installation=
+
=Setting up virtual PC=
Stop Alpine:
 
{{Cmd|halt}}
 
After Alpine has been stopped, unmount the CD image in VirtualBox (Devices menu).<br>
 
Start the virtual machine again and it should now boot from the virtual disk.<br>
 
<br>
 
Setup Alpine:
 
{{Cmd|setup-alpine}}
 
<br>
 
Configure [[Alpine local backup]] to use the virtual disk:<br>
 
Edit <code>/etc/lbu/lbu.conf</code> to have line: <code>LBU_MEDIA=sda1</code><br>
 
Commit your setup:
 
{{Cmd|lbu commit}}
 
<br>
 
'''Optional:''' to debug any problems in startup, activate the rc-system logging:
 
{{Cmd|<nowiki>echo 'rc_logger="YES"' >> /etc/rc.conf</nowiki>}}
 
Results will be in <code>/var/log/rc.log</code>
 
<br>
 
<br>
 
Setup [[Alpine package management]] to cache any downloaded packages in the HD:
 
{{Cmd|mkdir /media/sda1/cache}}
 
{{Cmd|ln -s /media/sda1/cache /etc/apk/cache}}
 
{{Cmd|lbu commit}}
 
<br>
 
[[Upgrading_Alpine_-_v1.9.x#Upgrading_an_Alpine_Linux_Hard-disk_installation|Setup APK to use a network source]] and update your system:
 
{{Cmd|apk update}}
 
{{Cmd|apk upgrade}}
 
{{Cmd|lbu commit}}
 
  
 +
Start Virtual Box. You will see a mostly empty window with a couple symbols in the upper left corner. The leftmost icon is a multi jagged star, if you hold your mouse over it, the tooltip will say “New”.
  
=Development Environment=
+
Press the multi-jagged star to create a new machine. A window will pop up, asking you some questions about the virtual (guest) computer you want to run.
I use VirtualBox to compile and test programs for a actual Alpine box.
 
To setup a compilation environment:
 
{{Cmd|apk add alpine-sdk}}
 
{{Cmd|lbu commit}}
 
<br>
 
I also like to save any local files to survive next boot:
 
{{Cmd|lbu add usr/local}}
 
{{Cmd|lbu commit}}
 
  
{{Tip|Remember to <code>lbu commit</code> often :-)}}
+
# Name: Choose any you like, for example “Alpine”.
 +
# Type: Linux
 +
# Version: Other Linux, either 64 bit or 32 bit. Choose 64 bit if you downloaded the x86_64 Alpine-ISO, or 32 bit if you downloaded the x86 Alpine-ISO.
 +
# Use the default values for the other questions, simply click “next” or “create” till the dialogue finishes.
 +
 
 +
You will see a new entry in Virtual Box, called Alpine (or whatever name you chose during step 1 in the dialogue above). Click on it to see further information on your guest.
 +
 
 +
One of the entries should read Mass storage, and offer an IDE controller with a primary master (the virtual hard disc) and a secondary master (the virtual optical drive).
 +
 
 +
Click on the secondary master, a context menu will pop up. Choose the entry “choose image” and open the Alpine ISO you downloaded earlier.
 +
 
 +
Once that is done, click on the green start arrow on the menu bar.
 +
 
 +
=Install Alpine on the virtual computer=
 +
 
 +
Follow the steps described in the [[Installation#Installation_Handbook|Installation Handbook]], just as if you installed Alpine on a real PC.
 +
 
 +
{{Tip|Do not reboot your virtual box after the installation. Rather, shut the virtual machine down, remove the Alpine ISO from the virtual optical drive, and then restart the virtual machine.}}
 +
 
 +
=Install drivers for Virtual Box=
 +
 
 +
Once you successfully rebooted into the installed Alpine, there are two steps left:
 +
 
 +
# Enable the [[Enable_Community_Repository|Community Respository]]
 +
# Enable [[VirtualBox_shared_folders|VirtualBox shared folders]]
 +
 
 +
These two steps install all drivers that other programs might request, and also activate several comfort functions.
 +
 
 +
{{Note|The Virtualbox webcam driver is not present in the kernel provided with the Virtual Alpine ISO. To use the webcam whilst keeping the installation footprint small, install the <code>linux-firmware-none</code> package using <b>apk</b>, and then install the <code>linux-vanilla</code> package to download a kernel with the appropriate drivers, without pulling in 100s of MB of firmware files too. Uninstall the <code>linux-virt</code> package and reboot to use the new kernel.}}
 +
 
 +
[[Category:Virtualization]]

Latest revision as of 08:51, 12 June 2019

This guide describes a standard install of Alpine within a virtual computer created by Virtual Box.

Oracle VM VirtualBox runs one or more virtual x86 or AMD64/Intel64 computer (guest) within another computer (host). This allows you to install and test Alpine on your main computer almost as you would any other program.

Preparation

Install Virtual Box on host

First of all, you need to download and install Virtual Box on your host computer, either from the official homepage (for Windows, OS X or Solaris) or from your distribution’s repository (for Linux).

Virtual Box consists of two components:

  • VirtualBox platform package
  • Oracle VM VirtualBox Extension Pack

Install both and start VirtualBox, to see whether it works. If it does not, consult the VirtualBox user manual or one of the support sites for Virtual Box.

Download Alpine

Download the Virtual Alpine ISO, which is optimized for virtual systems, from the Alpine Download section. Save it in a folder where you can find it easily.

Setting up virtual PC

Start Virtual Box. You will see a mostly empty window with a couple symbols in the upper left corner. The leftmost icon is a multi jagged star, if you hold your mouse over it, the tooltip will say “New”.

Press the multi-jagged star to create a new machine. A window will pop up, asking you some questions about the virtual (guest) computer you want to run.

  1. Name: Choose any you like, for example “Alpine”.
  2. Type: Linux
  3. Version: Other Linux, either 64 bit or 32 bit. Choose 64 bit if you downloaded the x86_64 Alpine-ISO, or 32 bit if you downloaded the x86 Alpine-ISO.
  4. Use the default values for the other questions, simply click “next” or “create” till the dialogue finishes.

You will see a new entry in Virtual Box, called Alpine (or whatever name you chose during step 1 in the dialogue above). Click on it to see further information on your guest.

One of the entries should read Mass storage, and offer an IDE controller with a primary master (the virtual hard disc) and a secondary master (the virtual optical drive).

Click on the secondary master, a context menu will pop up. Choose the entry “choose image” and open the Alpine ISO you downloaded earlier.

Once that is done, click on the green start arrow on the menu bar.

Install Alpine on the virtual computer

Follow the steps described in the Installation Handbook, just as if you installed Alpine on a real PC.

Tip: Do not reboot your virtual box after the installation. Rather, shut the virtual machine down, remove the Alpine ISO from the virtual optical drive, and then restart the virtual machine.

Install drivers for Virtual Box

Once you successfully rebooted into the installed Alpine, there are two steps left:

  1. Enable the Community Respository
  2. Enable VirtualBox shared folders

These two steps install all drivers that other programs might request, and also activate several comfort functions.

Note: The Virtualbox webcam driver is not present in the kernel provided with the Virtual Alpine ISO. To use the webcam whilst keeping the installation footprint small, install the linux-firmware-none package using apk, and then install the linux-vanilla package to download a kernel with the appropriate drivers, without pulling in 100s of MB of firmware files too. Uninstall the linux-virt package and reboot to use the new kernel.