https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Kody&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T07:52:07ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Dualbooting&diff=14466Dualbooting2018-02-07T16:51:28Z<p>Kody: Fixed typo</p>
<hr />
<div>Assume you have a box where you run Ubuntu or your favourite distro. Now you would like to be able to boot either your already installed system or Alpine.<br />
<br />
= Prepare your hardware =<br />
You will need a partition for your Alpine installation. If you don't already have one free, you need to create a primary partition with enough space for your Alpine installation. The tools you use for managing your partitions might differ, so you need to figure out your self how to use them. <tt>fdisk</tt> can help.<br />
<br />
Make notes of what partition you will use for your Alpine installation. In this example we are going to install Alpine on '''/dev/sda3'''.<br />
<br />
= Installing Alpine on HDD =<br />
<br />
Now it's time to install Alpine. Boot your system with a CD containing the latest Alpine Standard from [http://alpinelinux.org/downloads Downloads].<br />
<br />
== Format and mount HDD partition ==<br />
<br />
First format your partition. We will need some tools for doing the formatting. After you are done those tools can be removed.<br />
<br />
{{Cmd|apk add e2fsprogs<br />
mkfs.ext3 /dev/sda3<br />
apk del e2fsprogs}}<br />
<br />
{{Warning|Make sure you format the right partition! The {{Path|/dev/sda3}} is only a example. If you choose the wrong partition your data will be gone. Make a backup first when you are unsure.}}<br />
<br />
Mount the newly formatted partition. After the mounting the partition will be available at {{Path|/mnt}}.<br />
{{Cmd|mount -t ext3 /dev/sda3 /mnt}}<br />
<br />
== Basic setup ==<br />
<br />
Next, do some basic setup for your Alpine system.<br />
<br />
In Alpine 2.2.3 or newer, type:<br />
{{Cmd|setup-timezone<br />
setup-alpine -q<br />
setup-sshd<br />
setup-ntp}}<br />
<br />
See [[setup-alpine]] for more details. (If you omit the <code>-q</code> flag to <code>setup-alpine</code>, you'll be prompted "Which disks yous you like to use?" Answer "none", and also answer "none" to the remaining prompts, about storing configs and an apk cache directory.)<br />
<br />
<!-- If the "answerfile" functionality of setup-alpine is changed to permit specifying "-m none" for setup-disk, this sequence could be expressed more concisely.--><br />
<br />
== Install Alpine ==<br />
<br />
Now it's time to put our files on the partition.<br />
<br />
If using Alpine Linux 2.2.3 or higher, just type:<br />
{{Cmd|setup-disk -m sys /mnt}}<br />
<br />
{{Tip|If you use extlinux and you didn't create a separate boot partition ({{Path|/boot}} is on the root partition {{Path|/}}), you might need to update the path to vmlinuz in {{Path|/boot/extlinux.conf}}, eg.:<br />
<pre>[...]<br />
LABEL hardened<br />
MENU DEFAULT<br />
MENU LABEL Linux hardened<br />
LINUX /boot/vmlinuz-hardened<br />
INITRD /boot/initramfs-hardened<br />
[...]</pre><br />
}}<br />
<br />
If using an earlier version of Alpine Linux, you'll need to install the files and [[Bootloaders|bootloader]] manually, as described below.<br />
<br />
=== Installing files manually ===<br />
<br />
{{Tip|If using a version of Alpine Linux older than 2.2.0, replace {{Path|/etc/apk/world}} in the last line with {{Path|/var/lib/apk/world}}}}<br />
<br />
{{Cmd|lbu package - {{!}} tar -C /mnt -xzf -<br />
apk add --root /mnt --initdb --repositories-file /etc/apk/repositories --keys-dir \<br />
/etc/apk/keys $(cat /etc/apk/world) acct linux-hardened alpine-base}}<br />
<br />
Your system is now on {{Path|/dev/sda3}}. Next thing is to be able to boot on it.<br />
<br />
=== Installing bootloader manually ===<br />
<br />
On your system you already have a bootloader of some kind. The bootloaders vary, so you need to figure out how to make it boot your Alpine distro. Hopefully you get some ideas by looking at the following example below.<br />
<br />
In my case I have Grub2 so I will describe what I did to boot Alpine.<br />
<br />
Reboot your system ''(start Ubuntu)''.<br />
<br />
Start a 'terminal' ''(ALT-F2 + "terminal" + [Run])''<br />
<br />
Take notes of the UUID of the partition you are planning to use:<br />
{{Cmd|sudo blkid /dev/sda3}}<br />
<br />
Start editing grub2 configuration <br />
{{Cmd|gksudo gedit /etc/grub.d/40_custom}}<br />
<br />
I edited the file so it looks something like this:<br />
<pre>#!/bin/sh<br />
echo "Adding Alpine" >&2<br />
cat << EOF<br />
menuentry "Alpine Linux" {<br />
set root=(hd0,3)<br />
linux /boot/vmlinuz-hardened root=UUID=8de6973a-4a8c-40ed-b710-c4e2b42d6b7a modules=sd-mod,usb-storage,ext3 quiet<br />
initrd /boot/initramfs-hardened<br />
}<br />
EOF</pre><br />
{{Note|The UUID-value mentioned above '8de6973a-4a8c-40ed-b710-c4e2b42d6b7a' should be replaced with the UUID you got when running your 'blkid' command.}}<br />
We need to tell grub2 that the config has changed<br />
{{Cmd|update-grub2}}<br />
<br />
Now it's time to test. Reboot your box.<br />
{{Note|You might need to press SHIFT when booting up your box in order to see the grub-menu.}}<br />
<br />
[[Category:Installation]]</div>Kody