<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Itoffshore</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Itoffshore"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Itoffshore"/>
	<updated>2026-04-30T13:57:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=16533</id>
		<title>Root on ZFS with native encryption</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=16533"/>
		<updated>2019-10-20T12:48:11Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: fix typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
This documentation describes how to set up Alpine Linux using ZFS with a pool that uses ZFS&#039; native encryption capabilities, which have been recently introduced in ZFS on Linux (ZoL) 0.8.0.&lt;br /&gt;
&lt;br /&gt;
Note that you must install the &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; directory on an unencrypted partition (either an unencrypted ZFS pool or any other FS of your choosing, if it&#039;s compatible with your bootloader) to boot correctly.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
You&#039;ll need a medium to put a live image on. You can use any live medium that supports ZoL &amp;gt;=0.8.x, but as of writing this it&#039;s easiest to use [https://cdimage.debian.org/cdimage/weekly-live-builds/amd64/iso-hybrid/ Debian Buster&#039;s live images] for this.&lt;br /&gt;
&lt;br /&gt;
== Hard Disk Device Name ==&lt;br /&gt;
&lt;br /&gt;
The following documentation uses the &amp;lt;code&amp;gt;/dev/sda&amp;lt;/code&amp;gt; device as installation destination. If your environment uses a different device name for your hard disk, use the corresponding device names in the examples. It also uses &amp;lt;code&amp;gt;rpool&amp;lt;/code&amp;gt; as name of the root pool, you can change this at will, but be sure to change it everywhere it&#039;s mentioned.&lt;br /&gt;
&lt;br /&gt;
= Setting up Alpine Linux Using ZFS with native encryption =&lt;br /&gt;
&lt;br /&gt;
To install Alpine Linux in a ZFS pool with encryption enable, you cannot use the [[Installation|official installation]] procedure, so follow along this guide.&lt;br /&gt;
&lt;br /&gt;
== Preparing the Installation Environment ==&lt;br /&gt;
&lt;br /&gt;
This section assumes that you&#039;re using the previously mentioned Debian installation medium. If you&#039;re using a different medium feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
After booting the Debian image you&#039;ll have to enable the &amp;lt;code&amp;gt;experimental&amp;lt;/code&amp;gt; repos for the time being to be able to access ZFS 0.8. For this you&#039;ll have to edit &amp;lt;code&amp;gt;/etc/apt/sources.list&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 # sed &#039;s/buster/experimental/&#039; -i /etc/apt/sources.list&lt;br /&gt;
 # echo &#039;deb http://deb.debian.org/debian experimental contrib&#039;&lt;br /&gt;
&lt;br /&gt;
Now install ZFS 0.8:&lt;br /&gt;
&lt;br /&gt;
 # apt update&lt;br /&gt;
 # apt install libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-dkms zfsutils-linux zfs-zed&lt;br /&gt;
&lt;br /&gt;
And load the ZFS module:&lt;br /&gt;
&lt;br /&gt;
 # modprobe zfs&lt;br /&gt;
&lt;br /&gt;
== Creating the Partition Layout ==&lt;br /&gt;
&lt;br /&gt;
Linux requires an unencrypted &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; partition to boot. You can assign the remaining space for the encrypted ZFS pool.&lt;br /&gt;
&lt;br /&gt;
* Start the &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility to set up partitions:&lt;br /&gt;
&lt;br /&gt;
 # fdisk /dev/sda&lt;br /&gt;
&lt;br /&gt;
:* Create the &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; partition:&lt;br /&gt;
::* Enter &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;100m&amp;lt;/code&amp;gt; to create a new 100 MB primary partition.&lt;br /&gt;
&lt;br /&gt;
:* Set the &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; partition active:&lt;br /&gt;
::* Enter &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
:* Create the ZFS partition:&lt;br /&gt;
::* Enter &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; to start creating the next partition. Press &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to select the default start cylinder. Enter the size of partition. For example, &amp;lt;code&amp;gt;512m&amp;lt;/code&amp;gt; for 512 MB or &amp;lt;code&amp;gt;5g&amp;lt;/code&amp;gt; for 5 GB. Alternatively press &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to set the maximum available size.&lt;br /&gt;
&lt;br /&gt;
:* To verify the settings, press &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;. The output shows, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Device     Boot  Start      End  Sectors  Size Id Type&lt;br /&gt;
/dev/sda1  *      2048   206847   204800  100M 83 Linux&lt;br /&gt;
/dev/sda2       206848 41943039 41736192 19.9G 83 Linux&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Press &amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; to save the changes.&lt;br /&gt;
&lt;br /&gt;
== Setting up the root pool ==&lt;br /&gt;
&lt;br /&gt;
You can create your rootpool with the following command:&lt;br /&gt;
&lt;br /&gt;
 # zpool create -o ashift=12 \&lt;br /&gt;
      -O acltype=posixacl -O canmount=off -O compression=lz4 \&lt;br /&gt;
      -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa \&lt;br /&gt;
      -O encryption=aes-256-gcm -O keylocation=prompt -O keyformat=passphrase \&lt;br /&gt;
      -O mountpoint=/ -R /mnt \&lt;br /&gt;
      rpool /dev/sda2&lt;br /&gt;
&lt;br /&gt;
You will have to enter your passphrase at this point. Choose wisely, as your passphrase is most likely [https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions#5-security-aspects the weakest link in this setup].&lt;br /&gt;
&lt;br /&gt;
A few notes on the options supplied to zpool:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ashift=12&amp;lt;/code&amp;gt; is recommended here because many drives today have 4KiB (or larger) physical sectors, even though they present 512B logical sectors&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;acltype=posixacl&amp;lt;/code&amp;gt; enables POSIX ACLs globally&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;normalization=formD&amp;lt;/code&amp;gt; eliminates some corner cases relating to UTF-8 filename normalization. It also enables &amp;lt;code&amp;gt;utf8only=on&amp;lt;/code&amp;gt;, meaning that only files with valid UTF-8 filenames will be accepted.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;xattr=sa&amp;lt;/code&amp;gt; vastly improves the performance of extended attributes, but is Linux-only. If you care about using this pool on other OpenZFS implementation don&#039;t specify this option.&lt;br /&gt;
&lt;br /&gt;
After completing this, confirm that the pool has been created:&lt;br /&gt;
&lt;br /&gt;
 # zpool status&lt;br /&gt;
&lt;br /&gt;
Should return something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pool: rpool&lt;br /&gt;
 state: ONLINE&lt;br /&gt;
  scan: none requested&lt;br /&gt;
config:&lt;br /&gt;
&lt;br /&gt;
	NAME         STATE     READ WRITE CKSUM&lt;br /&gt;
	rpool       ONLINE       0     0     0&lt;br /&gt;
	  sda2  ONLINE       0     0     0&lt;br /&gt;
&lt;br /&gt;
errors: No known data errors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating the required datasets ===&lt;br /&gt;
&lt;br /&gt;
 # zfs create -o mountpoint=none -o canmount=off rpool/ROOT&lt;br /&gt;
 # zfs create -o mountpoint=legacy rpool/ROOT/alpine&lt;br /&gt;
 # mount -t zfs rpool/ROOT/alpine /mnt/&lt;br /&gt;
&lt;br /&gt;
=== Creating optional datasets (feel free to add your own) ===&lt;br /&gt;
&lt;br /&gt;
 # zfs create -o mountpoint=/home rpool/HOME&lt;br /&gt;
 # zfs create -o mountpoint=/var/log rpool/LOG&lt;br /&gt;
&lt;br /&gt;
== Creating the &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; filesystem ==&lt;br /&gt;
&lt;br /&gt;
 # mkfs.ext4 /dev/sda1&lt;br /&gt;
&lt;br /&gt;
== Mounting the &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; filesystem ==&lt;br /&gt;
&lt;br /&gt;
* Create the &amp;lt;code&amp;gt;/mnt/boot/&amp;lt;/code&amp;gt; directory and mount the &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt; partition in this directory:&lt;br /&gt;
&lt;br /&gt;
 # mkdir /mnt/boot/&lt;br /&gt;
 # mount -t ext4 /dev/sda1 /mnt/boot/&lt;br /&gt;
&lt;br /&gt;
== Installing Alpine Linux ==&lt;br /&gt;
&lt;br /&gt;
Please follow [[Installing_Alpine_Linux_in_a_chroot|Installing Alpine Linux in a chroot]] to setup a base install of Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
After you&#039;ve followed that guide, you still have to do some additional setup for ZFS:&lt;br /&gt;
&lt;br /&gt;
* As of the time of writing this ZFS 0.8.x is only available in [[Edge]], so you&#039;ll have to enable it in &amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;. Check [https://pkgs.alpinelinux.org/packages?name=zfs pkgs.alpinelinux.org] to see the status of this.&lt;br /&gt;
&lt;br /&gt;
* Install the ZoL and linux-vanilla package: &amp;lt;code&amp;gt;apk install linux-vanilla zfs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Enable ZFS&#039; services:&lt;br /&gt;
&lt;br /&gt;
 # rc-update add zfs-import sysinit&lt;br /&gt;
 # rc-update add zfs-mount sysinit&lt;br /&gt;
&lt;br /&gt;
* Edit the &amp;lt;code&amp;gt;/etc/mkinitfs/mkinitfs.conf&amp;lt;/code&amp;gt; file and append &amp;lt;code&amp;gt;zfs&amp;lt;/code&amp;gt; module to the &amp;lt;code&amp;gt;features&amp;lt;/code&amp;gt; parameter:&lt;br /&gt;
&lt;br /&gt;
 features=&amp;quot;ata base ide scsi usb virtio ext4 lvm &amp;lt;u&amp;gt;zfs&amp;lt;/u&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Be mindful to also include other modules which may be required for your setup, such as the &amp;lt;code&amp;gt;nvme&amp;lt;/code&amp;gt; module.&lt;br /&gt;
&lt;br /&gt;
* Rebuild the initial RAM disk:&lt;br /&gt;
&lt;br /&gt;
 # mkinitfs $(ls /lib/modules/)&lt;br /&gt;
&lt;br /&gt;
* Edit the &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;/code&amp;gt; file, set the root ZFS dataset and append the following kernel options to the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; parameter:&lt;br /&gt;
&lt;br /&gt;
 root=rpool/ROOT/alpine&lt;br /&gt;
 default_kernel_opts=&amp;quot;... &amp;lt;u&amp;gt;rootfstype=zfs&amp;lt;/u&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Update extlinux&#039;s config (if you&#039;re not using a different bootloader)&lt;br /&gt;
&lt;br /&gt;
 # update-extlinux&lt;br /&gt;
 # exit&lt;br /&gt;
&lt;br /&gt;
: Ignore the errors the &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt; utility displays.&lt;br /&gt;
&lt;br /&gt;
* Write the MBR to the &amp;lt;code&amp;gt;/dev/sda&amp;lt;/code&amp;gt; device:&lt;br /&gt;
&lt;br /&gt;
 # dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/sda&lt;br /&gt;
&lt;br /&gt;
== Unmounting the filesystems ==&lt;br /&gt;
&lt;br /&gt;
* Unmount &amp;lt;code&amp;gt;/mnt/boot/&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 # umount /mnt/boot/&lt;br /&gt;
&lt;br /&gt;
* Unmount all zfs filesystems:&lt;br /&gt;
&lt;br /&gt;
 # zfs unmount -a&lt;br /&gt;
&lt;br /&gt;
* Reboot the system:&lt;br /&gt;
&lt;br /&gt;
 # reboot&lt;br /&gt;
&lt;br /&gt;
== Booting the system ==&lt;br /&gt;
&lt;br /&gt;
Right now mkinitfs doesn&#039;t support ZFS asking for passwords during boot, so it&#039;ll throw you into a rescue shell for you to enter the password during boot. You have to do the following things after pressing enter:&lt;br /&gt;
&lt;br /&gt;
 # zfs load-key -a&lt;br /&gt;
 # mount -t zfs rpool/ROOT/alpine /sysroot&lt;br /&gt;
 # exit&lt;br /&gt;
&lt;br /&gt;
And your system should continue booting! :)&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
== General Procedure ==&lt;br /&gt;
&lt;br /&gt;
In case your system fails to boot, you can verify the settings and fix incorrect configurations:&lt;br /&gt;
&lt;br /&gt;
* [[#Preparing_the_Installation_Environment|Preparing the Installation Environment]]&lt;br /&gt;
&lt;br /&gt;
* Load the ZFS kernel module:&lt;br /&gt;
&lt;br /&gt;
 # modprobe zfs&lt;br /&gt;
&lt;br /&gt;
* [[#Mounting_the_File_Systems|Mount the file systems]]&lt;br /&gt;
&lt;br /&gt;
 # zpool import -R /mnt rpool&lt;br /&gt;
 # mount -t ext4 /dev/sda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
* Verify that you run the steps described in the [[#Installing_Alpine_Linux|Installing Alpine Linux]] section correctly. Update the configuration if necessary.&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11548</id>
		<title>Setting up a OpenVPN server</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11548"/>
		<updated>2015-12-31T23:49:16Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Initial setup for administrating certificates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This article describes how to set up an OpenVPN server with the Alpine Linux.&lt;br /&gt;
This is an ideal solution for allowing single users or devices to remotely connect to your network. To establish connectivity with a Remote Office or site, [http://wiki.alpinelinux.org/w/index.php?title=Using_Racoon_for_Remote_Sites Racoon/Opennhrp] would provide better functionality. &lt;br /&gt;
&lt;br /&gt;
It is recommended that you have a publicly routable static IP address in order for this to work. This means that your IP address cannot be in the private IP address ranges described here: [http://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses WikiPedia]&lt;br /&gt;
&lt;br /&gt;
If your Internet-connected machine doesn&#039;t have a static IP address, [http://www.dyndns.com DynDNS] can be used for resolving DNS names to IP addresses.&lt;br /&gt;
&lt;br /&gt;
= Setup Alpine =&lt;br /&gt;
== Initial Setup ==&lt;br /&gt;
Follow [[Installing_Alpine]] to setup Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Install programs ==&lt;br /&gt;
Install openvpn&lt;br /&gt;
{{Cmd| apk add openvpn}}&lt;br /&gt;
&lt;br /&gt;
Prepare autostart of OpenVPN&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add openvpn default}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe tun&lt;br /&gt;
echo &amp;quot;tun&amp;quot; &amp;gt;&amp;gt;/etc/modules}}&lt;br /&gt;
&lt;br /&gt;
= Certificates =&lt;br /&gt;
One of the first things that needs to be done is to make sure that you have secure keys to work with. Alpine makes this easy by having a web interface to manage the certificates. Documentation for it can be found here: [[Generating_SSL_certs_with_ACF]]. It is a best practice not to have your certificate server be on the same machine as the router being used for remote connectivity.&lt;br /&gt;
&lt;br /&gt;
You will need to create a server (ssl_server_cert) certificate for the server and one client (ssl_client_cert) for each client. To use the certificates, you should download the .pfx file and extract it.&lt;br /&gt;
&lt;br /&gt;
To extract the three parts of each .pfx file, use the following commands:&lt;br /&gt;
 &lt;br /&gt;
To get the ca cert out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -cacerts -nokeys -out ca.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the cert file out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nokeys -clcerts -out cert.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the private key file out. Make sure this stays private.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nocerts -nodes -out key.pem}}&lt;br /&gt;
&lt;br /&gt;
On the VPN server, you can also install the &#039;&#039;&#039;acf-openvpn&#039;&#039;&#039; package, which contains a web page to automatically upload and extract the server certificate. There is also a button to automatically generate the Diffie Hellman parameters.&lt;br /&gt;
&lt;br /&gt;
If you would prefer to generate your certificates using OpenVPN utilities, see [[#Alternative Certificate Method]]&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN server =&lt;br /&gt;
Example configuration file for server. Place the following content in /etc/openvpn/openvpn.conf:&lt;br /&gt;
 local &amp;quot;Public Ip address&amp;quot;&lt;br /&gt;
 port 1194&lt;br /&gt;
 proto udp&lt;br /&gt;
 dev tun&lt;br /&gt;
 ca openvpn_certs/server-ca.pem&lt;br /&gt;
 cert openvpn_certs/server-cert.pem&lt;br /&gt;
 dh openvpn_certs/dh1024.pem #to generate by hand #openssl dhparam -out dh1024.pem 1024&lt;br /&gt;
 server 10.0.0.0 255.255.255.0&lt;br /&gt;
 ifconfig-pool-persist ipp.txt&lt;br /&gt;
 push &amp;quot;route 10.0.0.0 255.0.0.0&amp;quot;&lt;br /&gt;
 push &amp;quot;dhcp-option DNS 10.0.0.1&amp;quot;&lt;br /&gt;
 keepalive 10 120&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 user nobody&lt;br /&gt;
 group nobody&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 status /var/log/openvpn-status.log&lt;br /&gt;
 log-append  /var/log/openvpn.log&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#server openvpn.net/howto.html#server]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
== Test your configuration ==&lt;br /&gt;
Test configuration and certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openvpn --config /etc/openvpn/openvpn.conf}}&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN client =&lt;br /&gt;
Example client.conf:&lt;br /&gt;
 client&lt;br /&gt;
 dev tun&lt;br /&gt;
 proto udp&lt;br /&gt;
 remote &amp;quot;public IP&amp;quot; 1194&lt;br /&gt;
 resolv-retry infinite&lt;br /&gt;
 nobind&lt;br /&gt;
 ns-cert-type server # This means that the certificate on the openvpn server needs to have this field. Prevents MitM attacks&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 ca client-ca.pem&lt;br /&gt;
 cert client-cert.pem&lt;br /&gt;
 key client-key.pem&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#client openvpn.net/howto.html#client]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
= Save settings =&lt;br /&gt;
Don&#039;t forget to save all your settings if you are running a RAM-based system.&lt;br /&gt;
{{Cmd|lbu commit}}&lt;br /&gt;
&lt;br /&gt;
= More than one server or client =&lt;br /&gt;
&lt;br /&gt;
If you want more than one server or client running on the same alpine box, use the standard [[Multiple Instances of Services]] process.&lt;br /&gt;
&lt;br /&gt;
For example, to create a config named &amp;quot;AlphaBravo&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
* Create an approriate /etc/openvpn/openvpn.conf file, but name it &amp;quot;/etc/openvpn/AlphaBravo.conf&amp;quot; &lt;br /&gt;
* create a new symlink of the init.d script:&lt;br /&gt;
{{Cmd|ln -s /etc/init.d/openvpn /etc/init.d/openvpn.AlphaBravo}}&lt;br /&gt;
* Have the new service start automatically&lt;br /&gt;
{{Cmd|rc-update add openvpn.AlphaBravo}}&lt;br /&gt;
&lt;br /&gt;
= Alternative Certificate Method =&lt;br /&gt;
== Manual Certificate Commands ==&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#pki openvpn.net/howto.html#pki]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
=== Initial setup for administrating certificates ===&lt;br /&gt;
The following instructions assume that you want to save your configs, certs and keys in &#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;.&amp;lt;BR&amp;gt;&lt;br /&gt;
Start by moving to the &#039;&#039;&#039;/usr/share/openvpn/easy-rsa&#039;&#039;&#039; folder to execute commands&lt;br /&gt;
{{Cmd|apk add easy-rsa # from the community repo&lt;br /&gt;
cd /usr/share/easy-rsa}}&lt;br /&gt;
If not already done then create a folder where you will save your certificates and save a copy of your &#039;&#039;&#039;/usr/share/easy-rsa/vars&#039;&#039;&#039; for later use.&amp;lt;BR&amp;gt;&lt;br /&gt;
{{Cmd|mkdir /etc/openvpn/keys&lt;br /&gt;
cp ./vars.example ./vars    #easy-rsa v3&lt;br /&gt;
cp ./vars /etc/openvpn/keys #easy-rsa v2}}&lt;br /&gt;
&lt;br /&gt;
For EasyRSA v3 see: https://community.openvpn.net/openvpn/wiki/EasyRSA&lt;br /&gt;
&lt;br /&gt;
The instructions below are for EasyRSA v2:&lt;br /&gt;
&lt;br /&gt;
If not already done then edit &#039;&#039;&#039;/etc/openvpn/keys/vars&#039;&#039;&#039;&amp;lt;BR&amp;gt;&lt;br /&gt;
(&#039;&#039;This file is used for defining paths and other standard settings&#039;&#039;)&lt;br /&gt;
{{Cmd|vim /etc/openvpn/keys/vars}}&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_DIR=&#039;&#039;&#039; from &amp;quot;&#039;&#039;&#039;$EASY_RSA/keys&#039;&#039;&#039;&amp;quot; to &amp;quot;&#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_SIZE, CA_EXPIRE, KEY_EXPIRE, KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, KEY_EMAIL&#039;&#039;&#039; to match your system.&lt;br /&gt;
source the &#039;&#039;&#039;vars&#039;&#039;&#039; to set properties&lt;br /&gt;
{{Cmd|source /etc/openvpn/keys/vars}}&lt;br /&gt;
{{Cmd|touch /etc/openvpn/keys/index.txt&lt;br /&gt;
echo 00 &amp;gt; /etc/openvpn/keys/serial}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;Certificate Authority&#039; (CA) ===&lt;br /&gt;
Clean up the &#039;&#039;&#039;keys&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./clean-all}}&lt;br /&gt;
&lt;br /&gt;
Generate Diffie Hellman parameters&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-dh}}&lt;br /&gt;
&lt;br /&gt;
Now lets make the CA certificates and keys&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-ca}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Server&#039; ===&lt;br /&gt;
Create server certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-key-server &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Client&#039; ===&lt;br /&gt;
Create client certificates&lt;br /&gt;
{{Cmd|./build-key &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Revoke a certificate ===&lt;br /&gt;
To revoke a certificate&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./revoke-full &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The revoke-full script will generate a CRL (certificate revocation list) file called &#039;&#039;&#039;crl.pem&#039;&#039;&#039; in the &#039;&#039;&#039;keys&#039;&#039;&#039; subdirectory.&amp;lt;BR&amp;gt;The file should be copied to a directory where the OpenVPN server can access it, then CRL verification should be enabled in the server configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|crl-verify crl.pem}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
= openVPN and LXC =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s call this LXC &amp;quot;mylxc&amp;quot;...&lt;br /&gt;
&lt;br /&gt;
On the host &amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe tun&lt;br /&gt;
mkdir /var/lib/lxc/mylxc/rootfs/dev/net&lt;br /&gt;
mknod /var/lib/lxc/mylxc/rootfs/dev/net/tun c 10 200&lt;br /&gt;
chmod 666 /var/lib/lxc/mylxc/rootfs/dev/net/tun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In /var/lib/lxc/mylxc/config &amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.cgroup.devices.allow = c 10:200 rwm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the guest &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add openvpn&lt;br /&gt;
&amp;lt;/pre&amp;gt; Then config as usual...&lt;br /&gt;
&lt;br /&gt;
This should work both as server and as client.&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11547</id>
		<title>Setting up a OpenVPN server</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11547"/>
		<updated>2015-12-31T23:46:32Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Initial setup for administrating certificates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This article describes how to set up an OpenVPN server with the Alpine Linux.&lt;br /&gt;
This is an ideal solution for allowing single users or devices to remotely connect to your network. To establish connectivity with a Remote Office or site, [http://wiki.alpinelinux.org/w/index.php?title=Using_Racoon_for_Remote_Sites Racoon/Opennhrp] would provide better functionality. &lt;br /&gt;
&lt;br /&gt;
It is recommended that you have a publicly routable static IP address in order for this to work. This means that your IP address cannot be in the private IP address ranges described here: [http://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses WikiPedia]&lt;br /&gt;
&lt;br /&gt;
If your Internet-connected machine doesn&#039;t have a static IP address, [http://www.dyndns.com DynDNS] can be used for resolving DNS names to IP addresses.&lt;br /&gt;
&lt;br /&gt;
= Setup Alpine =&lt;br /&gt;
== Initial Setup ==&lt;br /&gt;
Follow [[Installing_Alpine]] to setup Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Install programs ==&lt;br /&gt;
Install openvpn&lt;br /&gt;
{{Cmd| apk add openvpn}}&lt;br /&gt;
&lt;br /&gt;
Prepare autostart of OpenVPN&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add openvpn default}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe tun&lt;br /&gt;
echo &amp;quot;tun&amp;quot; &amp;gt;&amp;gt;/etc/modules}}&lt;br /&gt;
&lt;br /&gt;
= Certificates =&lt;br /&gt;
One of the first things that needs to be done is to make sure that you have secure keys to work with. Alpine makes this easy by having a web interface to manage the certificates. Documentation for it can be found here: [[Generating_SSL_certs_with_ACF]]. It is a best practice not to have your certificate server be on the same machine as the router being used for remote connectivity.&lt;br /&gt;
&lt;br /&gt;
You will need to create a server (ssl_server_cert) certificate for the server and one client (ssl_client_cert) for each client. To use the certificates, you should download the .pfx file and extract it.&lt;br /&gt;
&lt;br /&gt;
To extract the three parts of each .pfx file, use the following commands:&lt;br /&gt;
 &lt;br /&gt;
To get the ca cert out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -cacerts -nokeys -out ca.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the cert file out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nokeys -clcerts -out cert.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the private key file out. Make sure this stays private.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nocerts -nodes -out key.pem}}&lt;br /&gt;
&lt;br /&gt;
On the VPN server, you can also install the &#039;&#039;&#039;acf-openvpn&#039;&#039;&#039; package, which contains a web page to automatically upload and extract the server certificate. There is also a button to automatically generate the Diffie Hellman parameters.&lt;br /&gt;
&lt;br /&gt;
If you would prefer to generate your certificates using OpenVPN utilities, see [[#Alternative Certificate Method]]&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN server =&lt;br /&gt;
Example configuration file for server. Place the following content in /etc/openvpn/openvpn.conf:&lt;br /&gt;
 local &amp;quot;Public Ip address&amp;quot;&lt;br /&gt;
 port 1194&lt;br /&gt;
 proto udp&lt;br /&gt;
 dev tun&lt;br /&gt;
 ca openvpn_certs/server-ca.pem&lt;br /&gt;
 cert openvpn_certs/server-cert.pem&lt;br /&gt;
 dh openvpn_certs/dh1024.pem #to generate by hand #openssl dhparam -out dh1024.pem 1024&lt;br /&gt;
 server 10.0.0.0 255.255.255.0&lt;br /&gt;
 ifconfig-pool-persist ipp.txt&lt;br /&gt;
 push &amp;quot;route 10.0.0.0 255.0.0.0&amp;quot;&lt;br /&gt;
 push &amp;quot;dhcp-option DNS 10.0.0.1&amp;quot;&lt;br /&gt;
 keepalive 10 120&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 user nobody&lt;br /&gt;
 group nobody&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 status /var/log/openvpn-status.log&lt;br /&gt;
 log-append  /var/log/openvpn.log&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#server openvpn.net/howto.html#server]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
== Test your configuration ==&lt;br /&gt;
Test configuration and certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openvpn --config /etc/openvpn/openvpn.conf}}&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN client =&lt;br /&gt;
Example client.conf:&lt;br /&gt;
 client&lt;br /&gt;
 dev tun&lt;br /&gt;
 proto udp&lt;br /&gt;
 remote &amp;quot;public IP&amp;quot; 1194&lt;br /&gt;
 resolv-retry infinite&lt;br /&gt;
 nobind&lt;br /&gt;
 ns-cert-type server # This means that the certificate on the openvpn server needs to have this field. Prevents MitM attacks&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 ca client-ca.pem&lt;br /&gt;
 cert client-cert.pem&lt;br /&gt;
 key client-key.pem&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#client openvpn.net/howto.html#client]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
= Save settings =&lt;br /&gt;
Don&#039;t forget to save all your settings if you are running a RAM-based system.&lt;br /&gt;
{{Cmd|lbu commit}}&lt;br /&gt;
&lt;br /&gt;
= More than one server or client =&lt;br /&gt;
&lt;br /&gt;
If you want more than one server or client running on the same alpine box, use the standard [[Multiple Instances of Services]] process.&lt;br /&gt;
&lt;br /&gt;
For example, to create a config named &amp;quot;AlphaBravo&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
* Create an approriate /etc/openvpn/openvpn.conf file, but name it &amp;quot;/etc/openvpn/AlphaBravo.conf&amp;quot; &lt;br /&gt;
* create a new symlink of the init.d script:&lt;br /&gt;
{{Cmd|ln -s /etc/init.d/openvpn /etc/init.d/openvpn.AlphaBravo}}&lt;br /&gt;
* Have the new service start automatically&lt;br /&gt;
{{Cmd|rc-update add openvpn.AlphaBravo}}&lt;br /&gt;
&lt;br /&gt;
= Alternative Certificate Method =&lt;br /&gt;
== Manual Certificate Commands ==&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#pki openvpn.net/howto.html#pki]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
=== Initial setup for administrating certificates ===&lt;br /&gt;
The following instructions assume that you want to save your configs, certs and keys in &#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;.&amp;lt;BR&amp;gt;&lt;br /&gt;
Start by moving to the &#039;&#039;&#039;/usr/share/openvpn/easy-rsa&#039;&#039;&#039; folder to execute commands&lt;br /&gt;
{{Cmd|apk add easy-rsa # from the community repo&lt;br /&gt;
cd /usr/share/easy-rsa}}&lt;br /&gt;
If not already done then create a folder where you will save your certificates and save a copy of your &#039;&#039;&#039;/usr/share/easy-rsa/vars&#039;&#039;&#039; for later use.&amp;lt;BR&amp;gt;&lt;br /&gt;
{{Cmd|mkdir /etc/openvpn/keys&lt;br /&gt;
cp ./vars.example ./vars    #easy-rsa v3&lt;br /&gt;
cp ./vars /etc/openvpn/keys #easy-rsa v2}}&lt;br /&gt;
&lt;br /&gt;
For EasyRSA v3 see: https://community.openvpn.net/openvpn/wiki/EasyRSA3-OpenVPN-Howto&lt;br /&gt;
&lt;br /&gt;
The instructions below are for EasyRSA v2:&lt;br /&gt;
&lt;br /&gt;
If not already done then edit &#039;&#039;&#039;/etc/openvpn/keys/vars&#039;&#039;&#039;&amp;lt;BR&amp;gt;&lt;br /&gt;
(&#039;&#039;This file is used for defining paths and other standard settings&#039;&#039;)&lt;br /&gt;
{{Cmd|vim /etc/openvpn/keys/vars}}&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_DIR=&#039;&#039;&#039; from &amp;quot;&#039;&#039;&#039;$EASY_RSA/keys&#039;&#039;&#039;&amp;quot; to &amp;quot;&#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_SIZE, CA_EXPIRE, KEY_EXPIRE, KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, KEY_EMAIL&#039;&#039;&#039; to match your system.&lt;br /&gt;
source the &#039;&#039;&#039;vars&#039;&#039;&#039; to set properties&lt;br /&gt;
{{Cmd|source /etc/openvpn/keys/vars}}&lt;br /&gt;
{{Cmd|touch /etc/openvpn/keys/index.txt&lt;br /&gt;
echo 00 &amp;gt; /etc/openvpn/keys/serial}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;Certificate Authority&#039; (CA) ===&lt;br /&gt;
Clean up the &#039;&#039;&#039;keys&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./clean-all}}&lt;br /&gt;
&lt;br /&gt;
Generate Diffie Hellman parameters&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-dh}}&lt;br /&gt;
&lt;br /&gt;
Now lets make the CA certificates and keys&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-ca}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Server&#039; ===&lt;br /&gt;
Create server certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-key-server &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Client&#039; ===&lt;br /&gt;
Create client certificates&lt;br /&gt;
{{Cmd|./build-key &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Revoke a certificate ===&lt;br /&gt;
To revoke a certificate&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./revoke-full &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The revoke-full script will generate a CRL (certificate revocation list) file called &#039;&#039;&#039;crl.pem&#039;&#039;&#039; in the &#039;&#039;&#039;keys&#039;&#039;&#039; subdirectory.&amp;lt;BR&amp;gt;The file should be copied to a directory where the OpenVPN server can access it, then CRL verification should be enabled in the server configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|crl-verify crl.pem}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
= openVPN and LXC =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s call this LXC &amp;quot;mylxc&amp;quot;...&lt;br /&gt;
&lt;br /&gt;
On the host &amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe tun&lt;br /&gt;
mkdir /var/lib/lxc/mylxc/rootfs/dev/net&lt;br /&gt;
mknod /var/lib/lxc/mylxc/rootfs/dev/net/tun c 10 200&lt;br /&gt;
chmod 666 /var/lib/lxc/mylxc/rootfs/dev/net/tun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In /var/lib/lxc/mylxc/config &amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.cgroup.devices.allow = c 10:200 rwm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the guest &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add openvpn&lt;br /&gt;
&amp;lt;/pre&amp;gt; Then config as usual...&lt;br /&gt;
&lt;br /&gt;
This should work both as server and as client.&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11546</id>
		<title>Setting up a OpenVPN server</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11546"/>
		<updated>2015-12-31T23:00:43Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Initial setup for administrating certificates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This article describes how to set up an OpenVPN server with the Alpine Linux.&lt;br /&gt;
This is an ideal solution for allowing single users or devices to remotely connect to your network. To establish connectivity with a Remote Office or site, [http://wiki.alpinelinux.org/w/index.php?title=Using_Racoon_for_Remote_Sites Racoon/Opennhrp] would provide better functionality. &lt;br /&gt;
&lt;br /&gt;
It is recommended that you have a publicly routable static IP address in order for this to work. This means that your IP address cannot be in the private IP address ranges described here: [http://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses WikiPedia]&lt;br /&gt;
&lt;br /&gt;
If your Internet-connected machine doesn&#039;t have a static IP address, [http://www.dyndns.com DynDNS] can be used for resolving DNS names to IP addresses.&lt;br /&gt;
&lt;br /&gt;
= Setup Alpine =&lt;br /&gt;
== Initial Setup ==&lt;br /&gt;
Follow [[Installing_Alpine]] to setup Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Install programs ==&lt;br /&gt;
Install openvpn&lt;br /&gt;
{{Cmd| apk add openvpn}}&lt;br /&gt;
&lt;br /&gt;
Prepare autostart of OpenVPN&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add openvpn default}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe tun&lt;br /&gt;
echo &amp;quot;tun&amp;quot; &amp;gt;&amp;gt;/etc/modules}}&lt;br /&gt;
&lt;br /&gt;
= Certificates =&lt;br /&gt;
One of the first things that needs to be done is to make sure that you have secure keys to work with. Alpine makes this easy by having a web interface to manage the certificates. Documentation for it can be found here: [[Generating_SSL_certs_with_ACF]]. It is a best practice not to have your certificate server be on the same machine as the router being used for remote connectivity.&lt;br /&gt;
&lt;br /&gt;
You will need to create a server (ssl_server_cert) certificate for the server and one client (ssl_client_cert) for each client. To use the certificates, you should download the .pfx file and extract it.&lt;br /&gt;
&lt;br /&gt;
To extract the three parts of each .pfx file, use the following commands:&lt;br /&gt;
 &lt;br /&gt;
To get the ca cert out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -cacerts -nokeys -out ca.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the cert file out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nokeys -clcerts -out cert.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the private key file out. Make sure this stays private.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nocerts -nodes -out key.pem}}&lt;br /&gt;
&lt;br /&gt;
On the VPN server, you can also install the &#039;&#039;&#039;acf-openvpn&#039;&#039;&#039; package, which contains a web page to automatically upload and extract the server certificate. There is also a button to automatically generate the Diffie Hellman parameters.&lt;br /&gt;
&lt;br /&gt;
If you would prefer to generate your certificates using OpenVPN utilities, see [[#Alternative Certificate Method]]&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN server =&lt;br /&gt;
Example configuration file for server. Place the following content in /etc/openvpn/openvpn.conf:&lt;br /&gt;
 local &amp;quot;Public Ip address&amp;quot;&lt;br /&gt;
 port 1194&lt;br /&gt;
 proto udp&lt;br /&gt;
 dev tun&lt;br /&gt;
 ca openvpn_certs/server-ca.pem&lt;br /&gt;
 cert openvpn_certs/server-cert.pem&lt;br /&gt;
 dh openvpn_certs/dh1024.pem #to generate by hand #openssl dhparam -out dh1024.pem 1024&lt;br /&gt;
 server 10.0.0.0 255.255.255.0&lt;br /&gt;
 ifconfig-pool-persist ipp.txt&lt;br /&gt;
 push &amp;quot;route 10.0.0.0 255.0.0.0&amp;quot;&lt;br /&gt;
 push &amp;quot;dhcp-option DNS 10.0.0.1&amp;quot;&lt;br /&gt;
 keepalive 10 120&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 user nobody&lt;br /&gt;
 group nobody&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 status /var/log/openvpn-status.log&lt;br /&gt;
 log-append  /var/log/openvpn.log&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#server openvpn.net/howto.html#server]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
== Test your configuration ==&lt;br /&gt;
Test configuration and certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openvpn --config /etc/openvpn/openvpn.conf}}&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN client =&lt;br /&gt;
Example client.conf:&lt;br /&gt;
 client&lt;br /&gt;
 dev tun&lt;br /&gt;
 proto udp&lt;br /&gt;
 remote &amp;quot;public IP&amp;quot; 1194&lt;br /&gt;
 resolv-retry infinite&lt;br /&gt;
 nobind&lt;br /&gt;
 ns-cert-type server # This means that the certificate on the openvpn server needs to have this field. Prevents MitM attacks&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 ca client-ca.pem&lt;br /&gt;
 cert client-cert.pem&lt;br /&gt;
 key client-key.pem&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#client openvpn.net/howto.html#client]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
= Save settings =&lt;br /&gt;
Don&#039;t forget to save all your settings if you are running a RAM-based system.&lt;br /&gt;
{{Cmd|lbu commit}}&lt;br /&gt;
&lt;br /&gt;
= More than one server or client =&lt;br /&gt;
&lt;br /&gt;
If you want more than one server or client running on the same alpine box, use the standard [[Multiple Instances of Services]] process.&lt;br /&gt;
&lt;br /&gt;
For example, to create a config named &amp;quot;AlphaBravo&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
* Create an approriate /etc/openvpn/openvpn.conf file, but name it &amp;quot;/etc/openvpn/AlphaBravo.conf&amp;quot; &lt;br /&gt;
* create a new symlink of the init.d script:&lt;br /&gt;
{{Cmd|ln -s /etc/init.d/openvpn /etc/init.d/openvpn.AlphaBravo}}&lt;br /&gt;
* Have the new service start automatically&lt;br /&gt;
{{Cmd|rc-update add openvpn.AlphaBravo}}&lt;br /&gt;
&lt;br /&gt;
= Alternative Certificate Method =&lt;br /&gt;
== Manual Certificate Commands ==&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#pki openvpn.net/howto.html#pki]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
=== Initial setup for administrating certificates ===&lt;br /&gt;
The following instructions assume that you want to save your configs, certs and keys in &#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;.&amp;lt;BR&amp;gt;&lt;br /&gt;
Start by moving to the &#039;&#039;&#039;/usr/share/openvpn/easy-rsa&#039;&#039;&#039; folder to execute commands&lt;br /&gt;
{{Cmd|apk add easy-rsa # from the community repo&lt;br /&gt;
cd /usr/share/easy-rsa}}&lt;br /&gt;
If not already done then create a folder where you will save your certificates and save a copy of your &#039;&#039;&#039;/usr/share/easy-rsa/vars&#039;&#039;&#039; for later use.&amp;lt;BR&amp;gt;&lt;br /&gt;
{{Cmd|mkdir /etc/openvpn/keys&lt;br /&gt;
cp ./vars.example /etc/openvpn/keys/vars}}&lt;br /&gt;
If not already done then edit &#039;&#039;&#039;/etc/openvpn/keys/vars&#039;&#039;&#039;&amp;lt;BR&amp;gt;&lt;br /&gt;
(&#039;&#039;This file is used for defining paths and other standard settings&#039;&#039;)&lt;br /&gt;
{{Cmd|vim /etc/openvpn/keys/vars}}&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_DIR=&#039;&#039;&#039; from &amp;quot;&#039;&#039;&#039;$EASY_RSA/keys&#039;&#039;&#039;&amp;quot; to &amp;quot;&#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_SIZE, CA_EXPIRE, KEY_EXPIRE, KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, KEY_EMAIL&#039;&#039;&#039; to match your system.&lt;br /&gt;
source the &#039;&#039;&#039;vars&#039;&#039;&#039; to set properties&lt;br /&gt;
{{Cmd|source /etc/openvpn/keys/vars}}&lt;br /&gt;
{{Cmd|touch /etc/openvpn/keys/index.txt&lt;br /&gt;
echo 00 &amp;gt; /etc/openvpn/keys/serial}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;Certificate Authority&#039; (CA) ===&lt;br /&gt;
Clean up the &#039;&#039;&#039;keys&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./clean-all}}&lt;br /&gt;
&lt;br /&gt;
Generate Diffie Hellman parameters&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-dh}}&lt;br /&gt;
&lt;br /&gt;
Now lets make the CA certificates and keys&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-ca}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Server&#039; ===&lt;br /&gt;
Create server certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-key-server &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Client&#039; ===&lt;br /&gt;
Create client certificates&lt;br /&gt;
{{Cmd|./build-key &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Revoke a certificate ===&lt;br /&gt;
To revoke a certificate&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./revoke-full &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The revoke-full script will generate a CRL (certificate revocation list) file called &#039;&#039;&#039;crl.pem&#039;&#039;&#039; in the &#039;&#039;&#039;keys&#039;&#039;&#039; subdirectory.&amp;lt;BR&amp;gt;The file should be copied to a directory where the OpenVPN server can access it, then CRL verification should be enabled in the server configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|crl-verify crl.pem}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
= openVPN and LXC =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s call this LXC &amp;quot;mylxc&amp;quot;...&lt;br /&gt;
&lt;br /&gt;
On the host &amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe tun&lt;br /&gt;
mkdir /var/lib/lxc/mylxc/rootfs/dev/net&lt;br /&gt;
mknod /var/lib/lxc/mylxc/rootfs/dev/net/tun c 10 200&lt;br /&gt;
chmod 666 /var/lib/lxc/mylxc/rootfs/dev/net/tun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In /var/lib/lxc/mylxc/config &amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.cgroup.devices.allow = c 10:200 rwm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the guest &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add openvpn&lt;br /&gt;
&amp;lt;/pre&amp;gt; Then config as usual...&lt;br /&gt;
&lt;br /&gt;
This should work both as server and as client.&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11545</id>
		<title>Setting up a OpenVPN server</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11545"/>
		<updated>2015-12-31T22:58:22Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Initial setup for administrating certificates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This article describes how to set up an OpenVPN server with the Alpine Linux.&lt;br /&gt;
This is an ideal solution for allowing single users or devices to remotely connect to your network. To establish connectivity with a Remote Office or site, [http://wiki.alpinelinux.org/w/index.php?title=Using_Racoon_for_Remote_Sites Racoon/Opennhrp] would provide better functionality. &lt;br /&gt;
&lt;br /&gt;
It is recommended that you have a publicly routable static IP address in order for this to work. This means that your IP address cannot be in the private IP address ranges described here: [http://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses WikiPedia]&lt;br /&gt;
&lt;br /&gt;
If your Internet-connected machine doesn&#039;t have a static IP address, [http://www.dyndns.com DynDNS] can be used for resolving DNS names to IP addresses.&lt;br /&gt;
&lt;br /&gt;
= Setup Alpine =&lt;br /&gt;
== Initial Setup ==&lt;br /&gt;
Follow [[Installing_Alpine]] to setup Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Install programs ==&lt;br /&gt;
Install openvpn&lt;br /&gt;
{{Cmd| apk add openvpn}}&lt;br /&gt;
&lt;br /&gt;
Prepare autostart of OpenVPN&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add openvpn default}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe tun&lt;br /&gt;
echo &amp;quot;tun&amp;quot; &amp;gt;&amp;gt;/etc/modules}}&lt;br /&gt;
&lt;br /&gt;
= Certificates =&lt;br /&gt;
One of the first things that needs to be done is to make sure that you have secure keys to work with. Alpine makes this easy by having a web interface to manage the certificates. Documentation for it can be found here: [[Generating_SSL_certs_with_ACF]]. It is a best practice not to have your certificate server be on the same machine as the router being used for remote connectivity.&lt;br /&gt;
&lt;br /&gt;
You will need to create a server (ssl_server_cert) certificate for the server and one client (ssl_client_cert) for each client. To use the certificates, you should download the .pfx file and extract it.&lt;br /&gt;
&lt;br /&gt;
To extract the three parts of each .pfx file, use the following commands:&lt;br /&gt;
 &lt;br /&gt;
To get the ca cert out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -cacerts -nokeys -out ca.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the cert file out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nokeys -clcerts -out cert.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the private key file out. Make sure this stays private.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nocerts -nodes -out key.pem}}&lt;br /&gt;
&lt;br /&gt;
On the VPN server, you can also install the &#039;&#039;&#039;acf-openvpn&#039;&#039;&#039; package, which contains a web page to automatically upload and extract the server certificate. There is also a button to automatically generate the Diffie Hellman parameters.&lt;br /&gt;
&lt;br /&gt;
If you would prefer to generate your certificates using OpenVPN utilities, see [[#Alternative Certificate Method]]&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN server =&lt;br /&gt;
Example configuration file for server. Place the following content in /etc/openvpn/openvpn.conf:&lt;br /&gt;
 local &amp;quot;Public Ip address&amp;quot;&lt;br /&gt;
 port 1194&lt;br /&gt;
 proto udp&lt;br /&gt;
 dev tun&lt;br /&gt;
 ca openvpn_certs/server-ca.pem&lt;br /&gt;
 cert openvpn_certs/server-cert.pem&lt;br /&gt;
 dh openvpn_certs/dh1024.pem #to generate by hand #openssl dhparam -out dh1024.pem 1024&lt;br /&gt;
 server 10.0.0.0 255.255.255.0&lt;br /&gt;
 ifconfig-pool-persist ipp.txt&lt;br /&gt;
 push &amp;quot;route 10.0.0.0 255.0.0.0&amp;quot;&lt;br /&gt;
 push &amp;quot;dhcp-option DNS 10.0.0.1&amp;quot;&lt;br /&gt;
 keepalive 10 120&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 user nobody&lt;br /&gt;
 group nobody&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 status /var/log/openvpn-status.log&lt;br /&gt;
 log-append  /var/log/openvpn.log&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#server openvpn.net/howto.html#server]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
== Test your configuration ==&lt;br /&gt;
Test configuration and certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openvpn --config /etc/openvpn/openvpn.conf}}&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN client =&lt;br /&gt;
Example client.conf:&lt;br /&gt;
 client&lt;br /&gt;
 dev tun&lt;br /&gt;
 proto udp&lt;br /&gt;
 remote &amp;quot;public IP&amp;quot; 1194&lt;br /&gt;
 resolv-retry infinite&lt;br /&gt;
 nobind&lt;br /&gt;
 ns-cert-type server # This means that the certificate on the openvpn server needs to have this field. Prevents MitM attacks&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 ca client-ca.pem&lt;br /&gt;
 cert client-cert.pem&lt;br /&gt;
 key client-key.pem&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#client openvpn.net/howto.html#client]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
= Save settings =&lt;br /&gt;
Don&#039;t forget to save all your settings if you are running a RAM-based system.&lt;br /&gt;
{{Cmd|lbu commit}}&lt;br /&gt;
&lt;br /&gt;
= More than one server or client =&lt;br /&gt;
&lt;br /&gt;
If you want more than one server or client running on the same alpine box, use the standard [[Multiple Instances of Services]] process.&lt;br /&gt;
&lt;br /&gt;
For example, to create a config named &amp;quot;AlphaBravo&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
* Create an approriate /etc/openvpn/openvpn.conf file, but name it &amp;quot;/etc/openvpn/AlphaBravo.conf&amp;quot; &lt;br /&gt;
* create a new symlink of the init.d script:&lt;br /&gt;
{{Cmd|ln -s /etc/init.d/openvpn /etc/init.d/openvpn.AlphaBravo}}&lt;br /&gt;
* Have the new service start automatically&lt;br /&gt;
{{Cmd|rc-update add openvpn.AlphaBravo}}&lt;br /&gt;
&lt;br /&gt;
= Alternative Certificate Method =&lt;br /&gt;
== Manual Certificate Commands ==&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#pki openvpn.net/howto.html#pki]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
=== Initial setup for administrating certificates ===&lt;br /&gt;
The following instructions assume that you want to save your configs, certs and keys in &#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;.&amp;lt;BR&amp;gt;&lt;br /&gt;
Start by moving to the &#039;&#039;&#039;/usr/share/openvpn/easy-rsa&#039;&#039;&#039; folder to execute commands&lt;br /&gt;
{{Cmd|apk add easy-rsa # from the community repo&lt;br /&gt;
cd /usr/share/easy-rsa}}&lt;br /&gt;
If not already done then create a folder where you will save your certificates and save a copy of your &#039;&#039;&#039;/usr/share/easy-rsa/vars&#039;&#039;&#039; for later use.&amp;lt;BR&amp;gt;&lt;br /&gt;
{{Cmd|mkdir /etc/openvpn/keys&lt;br /&gt;
cp ./vars.example /etc/openvpn/keys}}&lt;br /&gt;
If not already done then edit &#039;&#039;&#039;/etc/openvpn/keys/vars&#039;&#039;&#039;&amp;lt;BR&amp;gt;&lt;br /&gt;
(&#039;&#039;This file is used for defining paths and other standard settings&#039;&#039;)&lt;br /&gt;
{{Cmd|vim /etc/openvpn/keys/vars}}&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_DIR=&#039;&#039;&#039; from &amp;quot;&#039;&#039;&#039;$EASY_RSA/keys&#039;&#039;&#039;&amp;quot; to &amp;quot;&#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_SIZE, CA_EXPIRE, KEY_EXPIRE, KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, KEY_EMAIL&#039;&#039;&#039; to match your system.&lt;br /&gt;
source the &#039;&#039;&#039;vars&#039;&#039;&#039; to set properties&lt;br /&gt;
{{Cmd|source /etc/openvpn/keys/vars}}&lt;br /&gt;
{{Cmd|touch /etc/openvpn/keys/index.txt&lt;br /&gt;
echo 00 &amp;gt; /etc/openvpn/keys/serial}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;Certificate Authority&#039; (CA) ===&lt;br /&gt;
Clean up the &#039;&#039;&#039;keys&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./clean-all}}&lt;br /&gt;
&lt;br /&gt;
Generate Diffie Hellman parameters&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-dh}}&lt;br /&gt;
&lt;br /&gt;
Now lets make the CA certificates and keys&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-ca}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Server&#039; ===&lt;br /&gt;
Create server certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-key-server &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Client&#039; ===&lt;br /&gt;
Create client certificates&lt;br /&gt;
{{Cmd|./build-key &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Revoke a certificate ===&lt;br /&gt;
To revoke a certificate&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./revoke-full &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The revoke-full script will generate a CRL (certificate revocation list) file called &#039;&#039;&#039;crl.pem&#039;&#039;&#039; in the &#039;&#039;&#039;keys&#039;&#039;&#039; subdirectory.&amp;lt;BR&amp;gt;The file should be copied to a directory where the OpenVPN server can access it, then CRL verification should be enabled in the server configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|crl-verify crl.pem}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
= openVPN and LXC =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s call this LXC &amp;quot;mylxc&amp;quot;...&lt;br /&gt;
&lt;br /&gt;
On the host &amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe tun&lt;br /&gt;
mkdir /var/lib/lxc/mylxc/rootfs/dev/net&lt;br /&gt;
mknod /var/lib/lxc/mylxc/rootfs/dev/net/tun c 10 200&lt;br /&gt;
chmod 666 /var/lib/lxc/mylxc/rootfs/dev/net/tun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In /var/lib/lxc/mylxc/config &amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.cgroup.devices.allow = c 10:200 rwm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the guest &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add openvpn&lt;br /&gt;
&amp;lt;/pre&amp;gt; Then config as usual...&lt;br /&gt;
&lt;br /&gt;
This should work both as server and as client.&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11544</id>
		<title>Setting up a OpenVPN server</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_OpenVPN_server&amp;diff=11544"/>
		<updated>2015-12-31T22:45:57Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Manual Certificate Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This article describes how to set up an OpenVPN server with the Alpine Linux.&lt;br /&gt;
This is an ideal solution for allowing single users or devices to remotely connect to your network. To establish connectivity with a Remote Office or site, [http://wiki.alpinelinux.org/w/index.php?title=Using_Racoon_for_Remote_Sites Racoon/Opennhrp] would provide better functionality. &lt;br /&gt;
&lt;br /&gt;
It is recommended that you have a publicly routable static IP address in order for this to work. This means that your IP address cannot be in the private IP address ranges described here: [http://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses WikiPedia]&lt;br /&gt;
&lt;br /&gt;
If your Internet-connected machine doesn&#039;t have a static IP address, [http://www.dyndns.com DynDNS] can be used for resolving DNS names to IP addresses.&lt;br /&gt;
&lt;br /&gt;
= Setup Alpine =&lt;br /&gt;
== Initial Setup ==&lt;br /&gt;
Follow [[Installing_Alpine]] to setup Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Install programs ==&lt;br /&gt;
Install openvpn&lt;br /&gt;
{{Cmd| apk add openvpn}}&lt;br /&gt;
&lt;br /&gt;
Prepare autostart of OpenVPN&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add openvpn default}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe tun&lt;br /&gt;
echo &amp;quot;tun&amp;quot; &amp;gt;&amp;gt;/etc/modules}}&lt;br /&gt;
&lt;br /&gt;
= Certificates =&lt;br /&gt;
One of the first things that needs to be done is to make sure that you have secure keys to work with. Alpine makes this easy by having a web interface to manage the certificates. Documentation for it can be found here: [[Generating_SSL_certs_with_ACF]]. It is a best practice not to have your certificate server be on the same machine as the router being used for remote connectivity.&lt;br /&gt;
&lt;br /&gt;
You will need to create a server (ssl_server_cert) certificate for the server and one client (ssl_client_cert) for each client. To use the certificates, you should download the .pfx file and extract it.&lt;br /&gt;
&lt;br /&gt;
To extract the three parts of each .pfx file, use the following commands:&lt;br /&gt;
 &lt;br /&gt;
To get the ca cert out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -cacerts -nokeys -out ca.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the cert file out...&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nokeys -clcerts -out cert.pem}}&lt;br /&gt;
&lt;br /&gt;
To get the private key file out. Make sure this stays private.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl pkcs12 -in PFXFILE -nocerts -nodes -out key.pem}}&lt;br /&gt;
&lt;br /&gt;
On the VPN server, you can also install the &#039;&#039;&#039;acf-openvpn&#039;&#039;&#039; package, which contains a web page to automatically upload and extract the server certificate. There is also a button to automatically generate the Diffie Hellman parameters.&lt;br /&gt;
&lt;br /&gt;
If you would prefer to generate your certificates using OpenVPN utilities, see [[#Alternative Certificate Method]]&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN server =&lt;br /&gt;
Example configuration file for server. Place the following content in /etc/openvpn/openvpn.conf:&lt;br /&gt;
 local &amp;quot;Public Ip address&amp;quot;&lt;br /&gt;
 port 1194&lt;br /&gt;
 proto udp&lt;br /&gt;
 dev tun&lt;br /&gt;
 ca openvpn_certs/server-ca.pem&lt;br /&gt;
 cert openvpn_certs/server-cert.pem&lt;br /&gt;
 dh openvpn_certs/dh1024.pem #to generate by hand #openssl dhparam -out dh1024.pem 1024&lt;br /&gt;
 server 10.0.0.0 255.255.255.0&lt;br /&gt;
 ifconfig-pool-persist ipp.txt&lt;br /&gt;
 push &amp;quot;route 10.0.0.0 255.0.0.0&amp;quot;&lt;br /&gt;
 push &amp;quot;dhcp-option DNS 10.0.0.1&amp;quot;&lt;br /&gt;
 keepalive 10 120&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 user nobody&lt;br /&gt;
 group nobody&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 status /var/log/openvpn-status.log&lt;br /&gt;
 log-append  /var/log/openvpn.log&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#server openvpn.net/howto.html#server]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
== Test your configuration ==&lt;br /&gt;
Test configuration and certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openvpn --config /etc/openvpn/openvpn.conf}}&lt;br /&gt;
&lt;br /&gt;
= Configure OpenVPN client =&lt;br /&gt;
Example client.conf:&lt;br /&gt;
 client&lt;br /&gt;
 dev tun&lt;br /&gt;
 proto udp&lt;br /&gt;
 remote &amp;quot;public IP&amp;quot; 1194&lt;br /&gt;
 resolv-retry infinite&lt;br /&gt;
 nobind&lt;br /&gt;
 ns-cert-type server # This means that the certificate on the openvpn server needs to have this field. Prevents MitM attacks&lt;br /&gt;
 persist-key&lt;br /&gt;
 persist-tun&lt;br /&gt;
 ca client-ca.pem&lt;br /&gt;
 cert client-cert.pem&lt;br /&gt;
 key client-key.pem&lt;br /&gt;
 comp-lzo&lt;br /&gt;
 verb 3&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#client openvpn.net/howto.html#client]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
= Save settings =&lt;br /&gt;
Don&#039;t forget to save all your settings if you are running a RAM-based system.&lt;br /&gt;
{{Cmd|lbu commit}}&lt;br /&gt;
&lt;br /&gt;
= More than one server or client =&lt;br /&gt;
&lt;br /&gt;
If you want more than one server or client running on the same alpine box, use the standard [[Multiple Instances of Services]] process.&lt;br /&gt;
&lt;br /&gt;
For example, to create a config named &amp;quot;AlphaBravo&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
* Create an approriate /etc/openvpn/openvpn.conf file, but name it &amp;quot;/etc/openvpn/AlphaBravo.conf&amp;quot; &lt;br /&gt;
* create a new symlink of the init.d script:&lt;br /&gt;
{{Cmd|ln -s /etc/init.d/openvpn /etc/init.d/openvpn.AlphaBravo}}&lt;br /&gt;
* Have the new service start automatically&lt;br /&gt;
{{Cmd|rc-update add openvpn.AlphaBravo}}&lt;br /&gt;
&lt;br /&gt;
= Alternative Certificate Method =&lt;br /&gt;
== Manual Certificate Commands ==&lt;br /&gt;
(&#039;&#039;Instructions are based on [http://openvpn.net/howto.html#pki openvpn.net/howto.html#pki]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
=== Initial setup for administrating certificates ===&lt;br /&gt;
The following instructions assume that you want to save your configs, certs and keys in &#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;.&amp;lt;BR&amp;gt;&lt;br /&gt;
Start by moving to the &#039;&#039;&#039;/usr/share/openvpn/easy-rsa&#039;&#039;&#039; folder to execute commands&lt;br /&gt;
{{Cmd|apk add easy-rsa # from the community repo&lt;br /&gt;
cd /usr/share/easy-rsa}}&lt;br /&gt;
If not already done then create a folder where you will save your certificates and save a copy of your &#039;&#039;&#039;/usr/share/easy-rsa/vars&#039;&#039;&#039; for later use.&amp;lt;BR&amp;gt;&lt;br /&gt;
{{Cmd|mkdir /etc/openvpn/keys&lt;br /&gt;
cp ./vars /etc/openvpn/keys}}&lt;br /&gt;
If not already done then edit &#039;&#039;&#039;/etc/openvpn/keys/vars&#039;&#039;&#039;&amp;lt;BR&amp;gt;&lt;br /&gt;
(&#039;&#039;This file is used for defining paths and other standard settings&#039;&#039;)&lt;br /&gt;
{{Cmd|vim /etc/openvpn/keys/vars}}&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_DIR=&#039;&#039;&#039; from &amp;quot;&#039;&#039;&#039;$EASY_RSA/keys&#039;&#039;&#039;&amp;quot; to &amp;quot;&#039;&#039;&#039;/etc/openvpn/keys&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
* Change &#039;&#039;&#039;KEY_SIZE, CA_EXPIRE, KEY_EXPIRE, KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, KEY_EMAIL&#039;&#039;&#039; to match your system.&lt;br /&gt;
source the &#039;&#039;&#039;vars&#039;&#039;&#039; to set properties&lt;br /&gt;
{{Cmd|source /etc/openvpn/keys/vars}}&lt;br /&gt;
{{Cmd|touch /etc/openvpn/keys/index.txt&lt;br /&gt;
echo 00 &amp;gt; /etc/openvpn/keys/serial}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;Certificate Authority&#039; (CA) ===&lt;br /&gt;
Clean up the &#039;&#039;&#039;keys&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./clean-all}}&lt;br /&gt;
&lt;br /&gt;
Generate Diffie Hellman parameters&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-dh}}&lt;br /&gt;
&lt;br /&gt;
Now lets make the CA certificates and keys&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-ca}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Server&#039; ===&lt;br /&gt;
Create server certificates&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./build-key-server &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Set up a &#039;OpenVPN Client&#039; ===&lt;br /&gt;
Create client certificates&lt;br /&gt;
{{Cmd|./build-key &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Revoke a certificate ===&lt;br /&gt;
To revoke a certificate&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./revoke-full &amp;lt;commonname&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The revoke-full script will generate a CRL (certificate revocation list) file called &#039;&#039;&#039;crl.pem&#039;&#039;&#039; in the &#039;&#039;&#039;keys&#039;&#039;&#039; subdirectory.&amp;lt;BR&amp;gt;The file should be copied to a directory where the OpenVPN server can access it, then CRL verification should be enabled in the server configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|crl-verify crl.pem}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
= openVPN and LXC =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s call this LXC &amp;quot;mylxc&amp;quot;...&lt;br /&gt;
&lt;br /&gt;
On the host &amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe tun&lt;br /&gt;
mkdir /var/lib/lxc/mylxc/rootfs/dev/net&lt;br /&gt;
mknod /var/lib/lxc/mylxc/rootfs/dev/net/tun c 10 200&lt;br /&gt;
chmod 666 /var/lib/lxc/mylxc/rootfs/dev/net/tun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In /var/lib/lxc/mylxc/config &amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.cgroup.devices.allow = c 10:200 rwm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the guest &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add openvpn&lt;br /&gt;
&amp;lt;/pre&amp;gt; Then config as usual...&lt;br /&gt;
&lt;br /&gt;
This should work both as server and as client.&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Include:Copying_Alpine_to_Flash&amp;diff=11528</id>
		<title>Include:Copying Alpine to Flash</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Include:Copying_Alpine_to_Flash&amp;diff=11528"/>
		<updated>2015-12-20T12:28:36Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Add note for creating USB in KVM&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Boot Alpine Linux CD-ROM ===&lt;br /&gt;
# Insert the Alpine Linux CD-ROM into a computer.&lt;br /&gt;
# Boot the computer from the Alpine Linux CD-ROM.&lt;br /&gt;
#* This step may require changes to the BIOS settings to select booting from CD. &lt;br /&gt;
# Login with the username &#039;&#039;root&#039;&#039;. No password is needed.&lt;br /&gt;
&lt;br /&gt;
{{Tip|If you&#039;re not able to boot from the CD, then another option is to boot from a regular Alpine installation, and [[Burning_ISOs|manually mount the ISO image to {{Path|/media/cdrom}}]].}} &lt;br /&gt;
&lt;br /&gt;
=== Determine the Device Name of the {{{1|Flash Medium}}} ===&lt;br /&gt;
Determine the name your computer uses for your {{{1|flash medium}}}. The following step is one way to do this.&lt;br /&gt;
# After inserting the {{{1|flash medium}}}, run the command:&lt;br /&gt;
#* {{Cmd|dmesg}}&lt;br /&gt;
#* At the end of this command you should see the name of your {{{1|flash medium}}}, likely starting with &amp;quot;sd&amp;quot;. (For example: &amp;quot;sda&amp;quot;).&lt;br /&gt;
#* The remainder of this document will assume that your {{{1|flash medium}}} is called /dev/sda&lt;br /&gt;
&lt;br /&gt;
{{Warning|If you are not using a virtual machine, be very careful about this. You do not want to mistakenly wipe your hard drive if it&#039;s on /dev/sda}}&lt;br /&gt;
&lt;br /&gt;
=== Format {{{1|Flash Medium}}} ===&lt;br /&gt;
Run fdisk (replacing sda with your {{{1|flash medium}}} name):&lt;br /&gt;
{{Cmd|fdisk /dev/sda}}&lt;br /&gt;
&lt;br /&gt;
# (&#039;&#039;Optional&#039;&#039;) - Create new partition table with one FAT32 partition&lt;br /&gt;
#* &#039;&#039;&#039;d&#039;&#039;&#039; Delete all partitions (this may take a few steps)&lt;br /&gt;
#* &#039;&#039;&#039;n&#039;&#039;&#039; Create a new partition&lt;br /&gt;
#* &#039;&#039;&#039;p&#039;&#039;&#039; A primary partition&lt;br /&gt;
#* &#039;&#039;&#039;1&#039;&#039;&#039; Partition number 1&lt;br /&gt;
#** Use defaults for first and last cylinder (just press [Enter] twice).&lt;br /&gt;
#* &#039;&#039;&#039;t&#039;&#039;&#039; Change partition type&lt;br /&gt;
#* &#039;&#039;&#039;c&#039;&#039;&#039; Partition type (Win95 FAT32/LBA)&lt;br /&gt;
#Verify that the primary partition is bootable&lt;br /&gt;
#* &#039;&#039;&#039;p&#039;&#039;&#039; Print list of partitions&lt;br /&gt;
#* If there is no &#039;*&#039; next to the first partition, follow the next steps:&lt;br /&gt;
#** &#039;&#039;&#039;a&#039;&#039;&#039; &amp;lt;big&amp;gt;Make the partition bootable (set boot flag)&amp;lt;/big&amp;gt;&lt;br /&gt;
#** &#039;&#039;&#039;1&#039;&#039;&#039; Partition number 1&lt;br /&gt;
#&#039;&#039;&#039;w&#039;&#039;&#039; Write your changes to the device&lt;br /&gt;
&lt;br /&gt;
=== Add Alpine Linux to the {{{1|Flash Medium}}}  ===&lt;br /&gt;
To boot from your {{{1|flash medium}}} you need to copy the contents of the CDROM to the {{{1|flash medium}}} and make it bootable. Those two operations can be automated with the [[setup-bootable]] tool or can be done manually.&lt;br /&gt;
&lt;br /&gt;
See also notes to [http://it-offshore.co.uk/linux/alpine-linux/48-alpine-linux-usb-stick-kvm create an Alpine Linux USB stick from within KVM] with [[setup-bootable]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If the following commands fail due to &#039;No such file or directory&#039;, you may have to remove and reinsert the {{{1|flash medium}}}, or even reboot, to get /dev/sda1 to appear}}&lt;br /&gt;
&lt;br /&gt;
==== Automated ====&lt;br /&gt;
{{Tip|If using Alpine Linux 1.10.4 or newer, you can use this section to complete the install. Otherwise, follow the Manual steps below.}}&lt;br /&gt;
{{Note|The target partition has to be formatted. Use the &amp;lt;code&amp;gt;mkdosfs&amp;lt;/code&amp;gt; command from the Manual steps below if needed.}}&lt;br /&gt;
# Run the [[setup-bootable]] script to add Alpine Linux to the {{{1|flash medium}}} and make it bootable (replacing sda with your {{{1|flash medium}}} name):&lt;br /&gt;
#: {{Cmd|setup-bootable /media/cdrom /dev/sda1}}&lt;br /&gt;
{{Note|If you get something like &#039;&amp;lt;code&amp;gt;Failed to mount /dev/sda1 on /media/sda1&amp;lt;/code&amp;gt;&#039; when running the above [[setup-bootable]] command, you might want to try running:&lt;br /&gt;
{{Cmd|modprobe vfat}}&lt;br /&gt;
and then try re-run the [[setup-bootable]] command as described above.}}&lt;br /&gt;
{{Warning|If you are installing to a USB Stick, you may need to modify the {{Path|syslinux.cfg}} file to say &amp;lt;code&amp;gt;usbdisk&amp;lt;/code&amp;gt; as [[#Wrong_Device_Name|described below]], or you will face possible problems booting and definite problems with the package cache. Recent versions of &amp;lt;code&amp;gt;setup-bootable&amp;lt;/code&amp;gt; will specify the alpine_dev using a UUID instead, so it should work properly by default.}}&lt;br /&gt;
&lt;br /&gt;
==== Manual ====&lt;br /&gt;
# (&#039;&#039;Optional&#039;&#039;) - If you created a new partition above, format the {{{1|flash medium}}} with a FAT32 filesystem (replacing sda with your {{{1|flash medium}}} name):&lt;br /&gt;
#: {{Cmd|apk add dosfstools&amp;lt;BR&amp;gt;mkdosfs -F32 /dev/sda1}}&lt;br /&gt;
# Install syslinux and MBR (replacing sda with your {{{1|flash medium}}} name):&lt;br /&gt;
#: {{Cmd|{{{|apk add syslinux&amp;lt;BR&amp;gt;dd if=/usr/share/syslinux/mbr.bin of=/dev/sda}}}&amp;lt;BR&amp;gt;syslinux /dev/sda1}}&lt;br /&gt;
#Copy the files to the {{{1|flash medium}}} (replacing sda with your {{{1|flash medium}}} name):&lt;br /&gt;
#: {{Cmd|&amp;lt;nowiki&amp;gt;mkdir -p /media/sda1&lt;br /&gt;
mount -t vfat /dev/sda1 /media/sda1&lt;br /&gt;
cd /media/cdrom&lt;br /&gt;
cp -a .alpine-release * /media/sda1/&lt;br /&gt;
umount /media/sda1&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# (&#039;&#039;Optional&#039;&#039;) Remove any apkovl files that were transfered as part of the copy process.  This should be done if you wish to have a fresh install.  Replace sda with your {{{1|flash medium}}} name)&lt;br /&gt;
#: {{Cmd|&amp;lt;nowiki&amp;gt;mount -t vfat /dev/sda1 /media/sda1&lt;br /&gt;
rm /media/sda1/*.apkovl.tar.gz&lt;br /&gt;
umount /media/sda1&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Wrong Device Name ===&lt;br /&gt;
If you cannot boot from the {{{1|flash medium}}} and you see something like:&lt;br /&gt;
 Mounting boot media failed.&lt;br /&gt;
 initramfs emergency recovery shell launched. Type &#039;exit&#039; to continue boot&lt;br /&gt;
then it is likely that the device name in {{Path|syslinux.cfg}} is wrong. You should replace the device name in this line:&lt;br /&gt;
 append initrd=/boot/grsec.gz alpine_dev=&#039;&#039;&#039;usbdisk&#039;&#039;&#039;:vfat modules=loop,cramfs,sd-mod,usb-storage quiet&lt;br /&gt;
with the proper device name.&lt;br /&gt;
* For boot from USB, the device name should be &#039;usbdisk&#039; (as shown above)&lt;br /&gt;
* For other options, you can run &amp;lt;code&amp;gt;cat /proc/partitions&amp;lt;/code&amp;gt; to see the available disks (i.e. &#039;sda&#039; or &#039;sdb&#039;)&lt;br /&gt;
&lt;br /&gt;
=== Non-FAT32 Filesystems ===&lt;br /&gt;
When your {{{1|flash medium}}} is formatted with a filesystem other than FAT32, you might have to specify the necessary filesystem modules in the boot parameters.&lt;br /&gt;
&lt;br /&gt;
To do so, mount the {{{1|flash medium}}} and change the {{Path|syslinux.cfg}} file line from &lt;br /&gt;
 append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet&lt;br /&gt;
to&lt;br /&gt;
 append initrd=/boot/grsec.gz alpine_dev=usbdisk:&#039;&#039;&#039;ext3&#039;&#039;&#039; modules=loop,cramfs,sd-mod,usb-storage&#039;&#039;&#039;,ext3&#039;&#039;&#039; quiet&lt;br /&gt;
in the case of an ext3 formatted partition. A similar procedure might apply to other filesystems (if they are supported by syslinux and the Alpine Linux kernel).&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=11524</id>
		<title>LXC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=11524"/>
		<updated>2015-12-11T15:05:52Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Ubuntu template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://lxc.sourceforge.net/ Linux Containers (LXC)] provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the &amp;quot;host&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Install the required packages:&lt;br /&gt;
{{Cmd|apk add lxc lxc-templates bridge}}&lt;br /&gt;
&lt;br /&gt;
== Prepare network on host ==&lt;br /&gt;
Set up a [[bridge]] on the host. Example &#039;&#039;/etc/network/interfaces&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auto br0&lt;br /&gt;
iface br0 inet dhcp&lt;br /&gt;
    bridge-ports eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network configuration template for the guests, &#039;&#039;/etc/lxc/lxc.conf&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a guest ==&lt;br /&gt;
&lt;br /&gt;
=== Alpine Template ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine}}&lt;br /&gt;
&lt;br /&gt;
This will create a &#039;&#039;/var/lib/lxc/guest1&#039;&#039; directory with a &#039;&#039;config&#039;&#039; file and a &#039;&#039;rootfs&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Note that by default alpine template &#039;&#039;&#039;does not have networking service on&#039;&#039;&#039;, you will need to add it using lxc-console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If running on x86_64 architecture, it is possible to create a 32bit guest:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine -- --arch x86}}&lt;br /&gt;
&lt;br /&gt;
=== Debian template ===&lt;br /&gt;
&lt;br /&gt;
In order to create a debian template container you will need to install some packages:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add debootstrap rsync}}&lt;br /&gt;
&lt;br /&gt;
Also you will need to turn off some grsecurity chroot options otherwise the debootstrap will fail:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
Now you can run:&lt;br /&gt;
{{Cmd|SUITE{{=}}wheezy lxc-create -n guest1 -f /etc/lxc/lxc.conf -t debian}}&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu template ===&lt;br /&gt;
&lt;br /&gt;
In order to create an ubuntu template container you will need to turn off some grsecurity chroot options:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
Now you can run (replace %MIRROR% with the actual hostname):&lt;br /&gt;
&lt;br /&gt;
MIRROR=&amp;quot;http://%MIRROR%/ubuntu/&amp;quot; lxc-create -n ubtn -f /etc/lxc/default.conf -t ubuntu -- -r trusty&lt;br /&gt;
&lt;br /&gt;
=== Unprivileged LXC images (Debian / Ubuntu / Centos etc..) ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add gnupg xz&lt;br /&gt;
lxc-create -n container-name -t download}}&lt;br /&gt;
&amp;amp; choose the Distribution | Release | Architecture.&lt;br /&gt;
&lt;br /&gt;
To be able to login to a Debian container you currently need to:&lt;br /&gt;
{{Cmd|rm /lib/systemd/system/container-getty\@.service}}&lt;br /&gt;
&lt;br /&gt;
You can also [http://without-systemd.org/wiki/index.php/How_to_remove_systemd_from_a_Debian_jessie/sid_installationers remove Systemd from the container].&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping the guest ==&lt;br /&gt;
Create a symlink to the &#039;&#039;/etc/init.d/lxc&#039;&#039; script for your guest.&lt;br /&gt;
{{Cmd|ln -s lxc /etc/init.d/lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can start your guest with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 start}}&lt;br /&gt;
&lt;br /&gt;
Stop it with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 stop}}&lt;br /&gt;
&lt;br /&gt;
Make it autostart on boot up with:&lt;br /&gt;
{{Cmd| rc-update add lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can also add to the container config: &amp;lt;code&amp;gt;lxc.start.auto = 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp; {{Cmd|rc-update add lxc}}&lt;br /&gt;
&lt;br /&gt;
to autostart containers by the lxc service only.&lt;br /&gt;
&lt;br /&gt;
== Connecting to the guest ==&lt;br /&gt;
By default sshd is not installed, so you will have to connect to a virtual console. This is done with:&lt;br /&gt;
{{Cmd|lxc-console -n guest1}}&lt;br /&gt;
&lt;br /&gt;
To disconnect from it, press {{key|Ctrl}}+{{key|a}} {{key|q}}&lt;br /&gt;
&lt;br /&gt;
== Deleting a guest ==&lt;br /&gt;
Make sure the guest is stopped and run:&lt;br /&gt;
{{Cmd|lxc-destroy -n guest1}}&lt;br /&gt;
This will erase everything, without asking any questions. It is equivalent to: {{Cmd|rm -r /var/lib/lxc/guest1}}&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a LXC container without modifying your network interfaces ===&lt;br /&gt;
&lt;br /&gt;
The problem with bridging is that the interface you bridge gets replaced with your new bridge interface.&lt;br /&gt;
That is to say that say you have an interface eth0 that you want to bridge, your eth0 interface gets replaced with the br0 interface that you create. It also means that the interface you use needs to be placed into promiscuous mode to catch all the traffic that could de destined to the other side of the bridge, which again may not be what you want.&lt;br /&gt;
&lt;br /&gt;
The solution is to create a dummy network interface, bridge that, and set up NAT so that traffic out of your bridge interface gets pushed through the interface of your choice.&lt;br /&gt;
&lt;br /&gt;
So, first, lets create that dummy interface (thanks to ncopa for talking me out of macvlan and pointing out the dummy interface kernel module)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe dummy}}&lt;br /&gt;
&lt;br /&gt;
This will create a dummy interface called dummy0 on your host.&lt;br /&gt;
&lt;br /&gt;
Now we will create a bridge called br0&lt;br /&gt;
&lt;br /&gt;
{{Cmd |brctl addbr br0&lt;br /&gt;
brctl setfd br0 0 }}&lt;br /&gt;
&lt;br /&gt;
and then make that dummy interface one end of the bridge&lt;br /&gt;
&lt;br /&gt;
{{Cmd | brctl addif br0 dummy0 }}&lt;br /&gt;
&lt;br /&gt;
Next, let&#039;s give that bridged interface a reason to exists&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | ifconfig br0 192.168.1.1 netmask 255.255.255.0 up}}&lt;br /&gt;
&lt;br /&gt;
Create a file for your container, let&#039;s say /etc/lxc/bridgenat.conf, with the following settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.name = eth1&lt;br /&gt;
lxc.network.ipv4 = 192.168.1.2/24&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and build your container with that file&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | lxc-create -n alpine -f /etc/lxc/bridgenat.conf -t alpine }}&lt;br /&gt;
&lt;br /&gt;
You should now be able to ping your container from your hosts, and your host from your container.&lt;br /&gt;
&lt;br /&gt;
Your container needs to know where to push traffic that isn&#039;t within it&#039;s subnet. To do so, we tell the container to route through the bridge interface br0&lt;br /&gt;
From inside the container run&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | route add default gw 192.168.1.1 }}&lt;br /&gt;
&lt;br /&gt;
The next step is you push the traffic coming from your private subnet over br0 out through your internet facing interface, or any interface you chose&lt;br /&gt;
&lt;br /&gt;
We are messing with your IP tables here, so make sure these settings don&#039;t conflict with anything you may have already set up, obviously.&lt;br /&gt;
&lt;br /&gt;
Say eth0 was your internet facing network interface, and br0 is the name of the bridge you made earlier, we&#039;d do this:&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE&lt;br /&gt;
iptables --append FORWARD --in-interface br0 -j ACCEPT&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you should be able to route through your bridge interface to the internet facing interface of your host from your container, just like at home!&lt;br /&gt;
&lt;br /&gt;
You could also have a dhcp server running on your host, and set it up to give IP addresses from your private subnet to any container that requests it, and then have one template for multiple alpine LXC containers, perfect for alpine development :)&lt;br /&gt;
&lt;br /&gt;
=== Using static IP ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using static IP, you need to configure this properly on guest&#039;s /etc/network/interfaces. To stay on the above example, modify &#039;&#039;/var/lib/lxc/guest1/rootfs/etc/network/interfaces&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
from&lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;dhcp&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
to &lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;static&#039;&#039;&#039;&lt;br /&gt;
     address &amp;lt;lxc-container-ip&amp;gt;   # IP which the lxc container should use&lt;br /&gt;
     gateway &amp;lt;gateway-ip&amp;gt;         # IP of gateway to use, mostly same as on lxc-host&lt;br /&gt;
     netmask &amp;lt;netmask&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mem and swap ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vim /boot/extlinux.conf}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
  APPEND initrd{{=}}initramfs-3.10.13-1-grsec root{{=}}UUID{{=}}7cd8789f-5659-40f8-9548-ae8f89c918ab modules{{=}}sd-mod,usb-storage,ext4 quiet cgroup_enable{{=}}memory swapaccount{{=}}1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== checkconfig ===&lt;br /&gt;
{{Cmd|lxc-checkconfig}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
Kernel configuration not found at /proc/config.gz; searching...&lt;br /&gt;
Kernel configuration found at /boot/config-3.10.13-1-grsec&lt;br /&gt;
--- Namespaces ---&lt;br /&gt;
Namespaces: enabled&lt;br /&gt;
Utsname namespace: enabled&lt;br /&gt;
Ipc namespace: enabled&lt;br /&gt;
Pid namespace: enabled&lt;br /&gt;
User namespace: missing&lt;br /&gt;
Network namespace: enabled&lt;br /&gt;
Multiple /dev/pts instances: enabled&lt;br /&gt;
&lt;br /&gt;
--- Control groups ---&lt;br /&gt;
Cgroup: enabled&lt;br /&gt;
Cgroup clone_children flag: enabled&lt;br /&gt;
Cgroup device: enabled&lt;br /&gt;
Cgroup sched: enabled&lt;br /&gt;
Cgroup cpu account: enabled&lt;br /&gt;
Cgroup memory controller: missing&lt;br /&gt;
Cgroup cpuset: enabled&lt;br /&gt;
&lt;br /&gt;
--- Misc ---&lt;br /&gt;
Veth pair device: enabled&lt;br /&gt;
Macvlan: enabled&lt;br /&gt;
Vlan: enabled&lt;br /&gt;
File capabilities: enabled&lt;br /&gt;
&lt;br /&gt;
Note : Before booting a new kernel, you can check its configuration&lt;br /&gt;
usage : CONFIG{{=}}/path/to/config /usr/bin/lxc-checkconfig&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== VirtualBox ===&lt;br /&gt;
&lt;br /&gt;
In order for network to work on containers you need to set &amp;quot;Promiscuous Mode&amp;quot; to &amp;quot;Allow All&amp;quot; in VirtualBox settings for the network adapter.&lt;br /&gt;
&lt;br /&gt;
[[File:VirtualBoxNetworkAdapter.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Virtualization]]&lt;br /&gt;
&lt;br /&gt;
=== postgreSQL ===&lt;br /&gt;
&lt;br /&gt;
Inside the container run: {{Cmd|chmod go+w /dev/null}} to fix {{Cmd|rc-service postgresql start}}&lt;br /&gt;
&lt;br /&gt;
=== openVPN ===&lt;br /&gt;
&lt;br /&gt;
see [[Setting_up_a_OpenVPN_server#openVPN_and_LXC]]&lt;br /&gt;
&lt;br /&gt;
== LXC 1.0 Additional information ==&lt;br /&gt;
&lt;br /&gt;
Some info regarding new features in LXC 1.0&lt;br /&gt;
 &lt;br /&gt;
https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=11523</id>
		<title>LXC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=11523"/>
		<updated>2015-12-11T15:05:24Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://lxc.sourceforge.net/ Linux Containers (LXC)] provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the &amp;quot;host&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Install the required packages:&lt;br /&gt;
{{Cmd|apk add lxc lxc-templates bridge}}&lt;br /&gt;
&lt;br /&gt;
== Prepare network on host ==&lt;br /&gt;
Set up a [[bridge]] on the host. Example &#039;&#039;/etc/network/interfaces&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auto br0&lt;br /&gt;
iface br0 inet dhcp&lt;br /&gt;
    bridge-ports eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network configuration template for the guests, &#039;&#039;/etc/lxc/lxc.conf&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a guest ==&lt;br /&gt;
&lt;br /&gt;
=== Alpine Template ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine}}&lt;br /&gt;
&lt;br /&gt;
This will create a &#039;&#039;/var/lib/lxc/guest1&#039;&#039; directory with a &#039;&#039;config&#039;&#039; file and a &#039;&#039;rootfs&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Note that by default alpine template &#039;&#039;&#039;does not have networking service on&#039;&#039;&#039;, you will need to add it using lxc-console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If running on x86_64 architecture, it is possible to create a 32bit guest:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine -- --arch x86}}&lt;br /&gt;
&lt;br /&gt;
=== Debian template ===&lt;br /&gt;
&lt;br /&gt;
In order to create a debian template container you will need to install some packages:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add debootstrap rsync}}&lt;br /&gt;
&lt;br /&gt;
Also you will need to turn off some grsecurity chroot options otherwise the debootstrap will fail:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
Now you can run:&lt;br /&gt;
{{Cmd|SUITE{{=}}wheezy lxc-create -n guest1 -f /etc/lxc/lxc.conf -t debian}}&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu template ===&lt;br /&gt;
&lt;br /&gt;
In order to create an ubuntu template container you will need to turn off some grsecurity chroot options:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
Now you can run (replace %MIRROR% with the actual hostname):&lt;br /&gt;
&lt;br /&gt;
MIRROR=&amp;quot;http://%MIRROR%/ubuntu/&amp;quot; lxc-create -n ubtn -f /etc/lxc/default.conf -t ubuntu -- -r trusty&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping the guest ==&lt;br /&gt;
Create a symlink to the &#039;&#039;/etc/init.d/lxc&#039;&#039; script for your guest.&lt;br /&gt;
{{Cmd|ln -s lxc /etc/init.d/lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can start your guest with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 start}}&lt;br /&gt;
&lt;br /&gt;
Stop it with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 stop}}&lt;br /&gt;
&lt;br /&gt;
Make it autostart on boot up with:&lt;br /&gt;
{{Cmd| rc-update add lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can also add to the container config: &amp;lt;code&amp;gt;lxc.start.auto = 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp; {{Cmd|rc-update add lxc}}&lt;br /&gt;
&lt;br /&gt;
to autostart containers by the lxc service only.&lt;br /&gt;
&lt;br /&gt;
== Connecting to the guest ==&lt;br /&gt;
By default sshd is not installed, so you will have to connect to a virtual console. This is done with:&lt;br /&gt;
{{Cmd|lxc-console -n guest1}}&lt;br /&gt;
&lt;br /&gt;
To disconnect from it, press {{key|Ctrl}}+{{key|a}} {{key|q}}&lt;br /&gt;
&lt;br /&gt;
== Deleting a guest ==&lt;br /&gt;
Make sure the guest is stopped and run:&lt;br /&gt;
{{Cmd|lxc-destroy -n guest1}}&lt;br /&gt;
This will erase everything, without asking any questions. It is equivalent to: {{Cmd|rm -r /var/lib/lxc/guest1}}&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a LXC container without modifying your network interfaces ===&lt;br /&gt;
&lt;br /&gt;
The problem with bridging is that the interface you bridge gets replaced with your new bridge interface.&lt;br /&gt;
That is to say that say you have an interface eth0 that you want to bridge, your eth0 interface gets replaced with the br0 interface that you create. It also means that the interface you use needs to be placed into promiscuous mode to catch all the traffic that could de destined to the other side of the bridge, which again may not be what you want.&lt;br /&gt;
&lt;br /&gt;
The solution is to create a dummy network interface, bridge that, and set up NAT so that traffic out of your bridge interface gets pushed through the interface of your choice.&lt;br /&gt;
&lt;br /&gt;
So, first, lets create that dummy interface (thanks to ncopa for talking me out of macvlan and pointing out the dummy interface kernel module)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe dummy}}&lt;br /&gt;
&lt;br /&gt;
This will create a dummy interface called dummy0 on your host.&lt;br /&gt;
&lt;br /&gt;
Now we will create a bridge called br0&lt;br /&gt;
&lt;br /&gt;
{{Cmd |brctl addbr br0&lt;br /&gt;
brctl setfd br0 0 }}&lt;br /&gt;
&lt;br /&gt;
and then make that dummy interface one end of the bridge&lt;br /&gt;
&lt;br /&gt;
{{Cmd | brctl addif br0 dummy0 }}&lt;br /&gt;
&lt;br /&gt;
Next, let&#039;s give that bridged interface a reason to exists&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | ifconfig br0 192.168.1.1 netmask 255.255.255.0 up}}&lt;br /&gt;
&lt;br /&gt;
Create a file for your container, let&#039;s say /etc/lxc/bridgenat.conf, with the following settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.name = eth1&lt;br /&gt;
lxc.network.ipv4 = 192.168.1.2/24&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and build your container with that file&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | lxc-create -n alpine -f /etc/lxc/bridgenat.conf -t alpine }}&lt;br /&gt;
&lt;br /&gt;
You should now be able to ping your container from your hosts, and your host from your container.&lt;br /&gt;
&lt;br /&gt;
Your container needs to know where to push traffic that isn&#039;t within it&#039;s subnet. To do so, we tell the container to route through the bridge interface br0&lt;br /&gt;
From inside the container run&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | route add default gw 192.168.1.1 }}&lt;br /&gt;
&lt;br /&gt;
The next step is you push the traffic coming from your private subnet over br0 out through your internet facing interface, or any interface you chose&lt;br /&gt;
&lt;br /&gt;
We are messing with your IP tables here, so make sure these settings don&#039;t conflict with anything you may have already set up, obviously.&lt;br /&gt;
&lt;br /&gt;
Say eth0 was your internet facing network interface, and br0 is the name of the bridge you made earlier, we&#039;d do this:&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE&lt;br /&gt;
iptables --append FORWARD --in-interface br0 -j ACCEPT&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you should be able to route through your bridge interface to the internet facing interface of your host from your container, just like at home!&lt;br /&gt;
&lt;br /&gt;
You could also have a dhcp server running on your host, and set it up to give IP addresses from your private subnet to any container that requests it, and then have one template for multiple alpine LXC containers, perfect for alpine development :)&lt;br /&gt;
&lt;br /&gt;
=== Using static IP ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using static IP, you need to configure this properly on guest&#039;s /etc/network/interfaces. To stay on the above example, modify &#039;&#039;/var/lib/lxc/guest1/rootfs/etc/network/interfaces&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
from&lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;dhcp&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
to &lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;static&#039;&#039;&#039;&lt;br /&gt;
     address &amp;lt;lxc-container-ip&amp;gt;   # IP which the lxc container should use&lt;br /&gt;
     gateway &amp;lt;gateway-ip&amp;gt;         # IP of gateway to use, mostly same as on lxc-host&lt;br /&gt;
     netmask &amp;lt;netmask&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mem and swap ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vim /boot/extlinux.conf}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
  APPEND initrd{{=}}initramfs-3.10.13-1-grsec root{{=}}UUID{{=}}7cd8789f-5659-40f8-9548-ae8f89c918ab modules{{=}}sd-mod,usb-storage,ext4 quiet cgroup_enable{{=}}memory swapaccount{{=}}1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== checkconfig ===&lt;br /&gt;
{{Cmd|lxc-checkconfig}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
Kernel configuration not found at /proc/config.gz; searching...&lt;br /&gt;
Kernel configuration found at /boot/config-3.10.13-1-grsec&lt;br /&gt;
--- Namespaces ---&lt;br /&gt;
Namespaces: enabled&lt;br /&gt;
Utsname namespace: enabled&lt;br /&gt;
Ipc namespace: enabled&lt;br /&gt;
Pid namespace: enabled&lt;br /&gt;
User namespace: missing&lt;br /&gt;
Network namespace: enabled&lt;br /&gt;
Multiple /dev/pts instances: enabled&lt;br /&gt;
&lt;br /&gt;
--- Control groups ---&lt;br /&gt;
Cgroup: enabled&lt;br /&gt;
Cgroup clone_children flag: enabled&lt;br /&gt;
Cgroup device: enabled&lt;br /&gt;
Cgroup sched: enabled&lt;br /&gt;
Cgroup cpu account: enabled&lt;br /&gt;
Cgroup memory controller: missing&lt;br /&gt;
Cgroup cpuset: enabled&lt;br /&gt;
&lt;br /&gt;
--- Misc ---&lt;br /&gt;
Veth pair device: enabled&lt;br /&gt;
Macvlan: enabled&lt;br /&gt;
Vlan: enabled&lt;br /&gt;
File capabilities: enabled&lt;br /&gt;
&lt;br /&gt;
Note : Before booting a new kernel, you can check its configuration&lt;br /&gt;
usage : CONFIG{{=}}/path/to/config /usr/bin/lxc-checkconfig&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== VirtualBox ===&lt;br /&gt;
&lt;br /&gt;
In order for network to work on containers you need to set &amp;quot;Promiscuous Mode&amp;quot; to &amp;quot;Allow All&amp;quot; in VirtualBox settings for the network adapter.&lt;br /&gt;
&lt;br /&gt;
[[File:VirtualBoxNetworkAdapter.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Virtualization]]&lt;br /&gt;
&lt;br /&gt;
=== postgreSQL ===&lt;br /&gt;
&lt;br /&gt;
Inside the container run: {{Cmd|chmod go+w /dev/null}} to fix {{Cmd|rc-service postgresql start}}&lt;br /&gt;
&lt;br /&gt;
=== openVPN ===&lt;br /&gt;
&lt;br /&gt;
see [[Setting_up_a_OpenVPN_server#openVPN_and_LXC]]&lt;br /&gt;
&lt;br /&gt;
== LXC 1.0 Additional information ==&lt;br /&gt;
&lt;br /&gt;
Some info regarding new features in LXC 1.0&lt;br /&gt;
 &lt;br /&gt;
https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=11522</id>
		<title>LXC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=11522"/>
		<updated>2015-12-11T15:02:25Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Debian template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://lxc.sourceforge.net/ Linux Containers (LXC)] provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the &amp;quot;host&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Install the required packages:&lt;br /&gt;
{{Cmd|apk add lxc lxc-templates bridge}}&lt;br /&gt;
&lt;br /&gt;
== Prepare network on host ==&lt;br /&gt;
Set up a [[bridge]] on the host. Example &#039;&#039;/etc/network/interfaces&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auto br0&lt;br /&gt;
iface br0 inet dhcp&lt;br /&gt;
    bridge-ports eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network configuration template for the guests, &#039;&#039;/etc/lxc/lxc.conf&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a guest ==&lt;br /&gt;
&lt;br /&gt;
=== Alpine Template ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine}}&lt;br /&gt;
&lt;br /&gt;
This will create a &#039;&#039;/var/lib/lxc/guest1&#039;&#039; directory with a &#039;&#039;config&#039;&#039; file and a &#039;&#039;rootfs&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Note that by default alpine template &#039;&#039;&#039;does not have networking service on&#039;&#039;&#039;, you will need to add it using lxc-console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If running on x86_64 architecture, it is possible to create a 32bit guest:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine -- --arch x86}}&lt;br /&gt;
&lt;br /&gt;
=== Debian template ===&lt;br /&gt;
&lt;br /&gt;
In order to create a debian template container you will need to install some packages:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add debootstrap rsync}}&lt;br /&gt;
&lt;br /&gt;
Also you will need to turn off some grsecurity chroot options otherwise the debootstrap will fail:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
Now you can run:&lt;br /&gt;
{{Cmd|SUITE{{=}}wheezy lxc-create -n guest1 -f /etc/lxc/lxc.conf -t debian}}&lt;br /&gt;
&lt;br /&gt;
=== Unprivileged LXC images (Debian / Ubuntu / Centos etc..) ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add gnupg xz&lt;br /&gt;
lxc-create -n container-name -t download}}&lt;br /&gt;
&amp;amp; choose the Distribution | Release | Architecture.&lt;br /&gt;
&lt;br /&gt;
To be able to login to a Debian container you currently need to:&lt;br /&gt;
{{Cmd|rm /lib/systemd/system/container-getty\@.service}}&lt;br /&gt;
&lt;br /&gt;
You can also [http://without-systemd.org/wiki/index.php/How_to_remove_systemd_from_a_Debian_jessie/sid_installationers remove Systemd from the container].&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu template ===&lt;br /&gt;
&lt;br /&gt;
In order to create an ubuntu template container you will need to turn off some grsecurity chroot options:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
Now you can run (replace %MIRROR% with the actual hostname):&lt;br /&gt;
&lt;br /&gt;
MIRROR=&amp;quot;http://%MIRROR%/ubuntu/&amp;quot; lxc-create -n ubtn -f /etc/lxc/default.conf -t ubuntu -- -r trusty&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping the guest ==&lt;br /&gt;
Create a symlink to the &#039;&#039;/etc/init.d/lxc&#039;&#039; script for your guest.&lt;br /&gt;
{{Cmd|ln -s lxc /etc/init.d/lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can start your guest with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 start}}&lt;br /&gt;
&lt;br /&gt;
Stop it with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 stop}}&lt;br /&gt;
&lt;br /&gt;
Make it autostart on boot up with:&lt;br /&gt;
{{Cmd| rc-update add lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can also add to the container config: &amp;lt;code&amp;gt;lxc.start.auto = 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp; {{Cmd|rc-update add lxc}}&lt;br /&gt;
&lt;br /&gt;
to autostart containers by the lxc service only.&lt;br /&gt;
&lt;br /&gt;
== Connecting to the guest ==&lt;br /&gt;
By default sshd is not installed, so you will have to connect to a virtual console. This is done with:&lt;br /&gt;
{{Cmd|lxc-console -n guest1}}&lt;br /&gt;
&lt;br /&gt;
To disconnect from it, press {{key|Ctrl}}+{{key|a}} {{key|q}}&lt;br /&gt;
&lt;br /&gt;
== Deleting a guest ==&lt;br /&gt;
Make sure the guest is stopped and run:&lt;br /&gt;
{{Cmd|lxc-destroy -n guest1}}&lt;br /&gt;
This will erase everything, without asking any questions. It is equivalent to: {{Cmd|rm -r /var/lib/lxc/guest1}}&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a LXC container without modifying your network interfaces ===&lt;br /&gt;
&lt;br /&gt;
The problem with bridging is that the interface you bridge gets replaced with your new bridge interface.&lt;br /&gt;
That is to say that say you have an interface eth0 that you want to bridge, your eth0 interface gets replaced with the br0 interface that you create. It also means that the interface you use needs to be placed into promiscuous mode to catch all the traffic that could de destined to the other side of the bridge, which again may not be what you want.&lt;br /&gt;
&lt;br /&gt;
The solution is to create a dummy network interface, bridge that, and set up NAT so that traffic out of your bridge interface gets pushed through the interface of your choice.&lt;br /&gt;
&lt;br /&gt;
So, first, lets create that dummy interface (thanks to ncopa for talking me out of macvlan and pointing out the dummy interface kernel module)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe dummy}}&lt;br /&gt;
&lt;br /&gt;
This will create a dummy interface called dummy0 on your host.&lt;br /&gt;
&lt;br /&gt;
Now we will create a bridge called br0&lt;br /&gt;
&lt;br /&gt;
{{Cmd |brctl addbr br0&lt;br /&gt;
brctl setfd br0 0 }}&lt;br /&gt;
&lt;br /&gt;
and then make that dummy interface one end of the bridge&lt;br /&gt;
&lt;br /&gt;
{{Cmd | brctl addif br0 dummy0 }}&lt;br /&gt;
&lt;br /&gt;
Next, let&#039;s give that bridged interface a reason to exists&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | ifconfig br0 192.168.1.1 netmask 255.255.255.0 up}}&lt;br /&gt;
&lt;br /&gt;
Create a file for your container, let&#039;s say /etc/lxc/bridgenat.conf, with the following settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.name = eth1&lt;br /&gt;
lxc.network.ipv4 = 192.168.1.2/24&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and build your container with that file&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | lxc-create -n alpine -f /etc/lxc/bridgenat.conf -t alpine }}&lt;br /&gt;
&lt;br /&gt;
You should now be able to ping your container from your hosts, and your host from your container.&lt;br /&gt;
&lt;br /&gt;
Your container needs to know where to push traffic that isn&#039;t within it&#039;s subnet. To do so, we tell the container to route through the bridge interface br0&lt;br /&gt;
From inside the container run&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | route add default gw 192.168.1.1 }}&lt;br /&gt;
&lt;br /&gt;
The next step is you push the traffic coming from your private subnet over br0 out through your internet facing interface, or any interface you chose&lt;br /&gt;
&lt;br /&gt;
We are messing with your IP tables here, so make sure these settings don&#039;t conflict with anything you may have already set up, obviously.&lt;br /&gt;
&lt;br /&gt;
Say eth0 was your internet facing network interface, and br0 is the name of the bridge you made earlier, we&#039;d do this:&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE&lt;br /&gt;
iptables --append FORWARD --in-interface br0 -j ACCEPT&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you should be able to route through your bridge interface to the internet facing interface of your host from your container, just like at home!&lt;br /&gt;
&lt;br /&gt;
You could also have a dhcp server running on your host, and set it up to give IP addresses from your private subnet to any container that requests it, and then have one template for multiple alpine LXC containers, perfect for alpine development :)&lt;br /&gt;
&lt;br /&gt;
=== Using static IP ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using static IP, you need to configure this properly on guest&#039;s /etc/network/interfaces. To stay on the above example, modify &#039;&#039;/var/lib/lxc/guest1/rootfs/etc/network/interfaces&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
from&lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;dhcp&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
to &lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;static&#039;&#039;&#039;&lt;br /&gt;
     address &amp;lt;lxc-container-ip&amp;gt;   # IP which the lxc container should use&lt;br /&gt;
     gateway &amp;lt;gateway-ip&amp;gt;         # IP of gateway to use, mostly same as on lxc-host&lt;br /&gt;
     netmask &amp;lt;netmask&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mem and swap ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vim /boot/extlinux.conf}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
  APPEND initrd{{=}}initramfs-3.10.13-1-grsec root{{=}}UUID{{=}}7cd8789f-5659-40f8-9548-ae8f89c918ab modules{{=}}sd-mod,usb-storage,ext4 quiet cgroup_enable{{=}}memory swapaccount{{=}}1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== checkconfig ===&lt;br /&gt;
{{Cmd|lxc-checkconfig}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
Kernel configuration not found at /proc/config.gz; searching...&lt;br /&gt;
Kernel configuration found at /boot/config-3.10.13-1-grsec&lt;br /&gt;
--- Namespaces ---&lt;br /&gt;
Namespaces: enabled&lt;br /&gt;
Utsname namespace: enabled&lt;br /&gt;
Ipc namespace: enabled&lt;br /&gt;
Pid namespace: enabled&lt;br /&gt;
User namespace: missing&lt;br /&gt;
Network namespace: enabled&lt;br /&gt;
Multiple /dev/pts instances: enabled&lt;br /&gt;
&lt;br /&gt;
--- Control groups ---&lt;br /&gt;
Cgroup: enabled&lt;br /&gt;
Cgroup clone_children flag: enabled&lt;br /&gt;
Cgroup device: enabled&lt;br /&gt;
Cgroup sched: enabled&lt;br /&gt;
Cgroup cpu account: enabled&lt;br /&gt;
Cgroup memory controller: missing&lt;br /&gt;
Cgroup cpuset: enabled&lt;br /&gt;
&lt;br /&gt;
--- Misc ---&lt;br /&gt;
Veth pair device: enabled&lt;br /&gt;
Macvlan: enabled&lt;br /&gt;
Vlan: enabled&lt;br /&gt;
File capabilities: enabled&lt;br /&gt;
&lt;br /&gt;
Note : Before booting a new kernel, you can check its configuration&lt;br /&gt;
usage : CONFIG{{=}}/path/to/config /usr/bin/lxc-checkconfig&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== VirtualBox ===&lt;br /&gt;
&lt;br /&gt;
In order for network to work on containers you need to set &amp;quot;Promiscuous Mode&amp;quot; to &amp;quot;Allow All&amp;quot; in VirtualBox settings for the network adapter.&lt;br /&gt;
&lt;br /&gt;
[[File:VirtualBoxNetworkAdapter.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Virtualization]]&lt;br /&gt;
&lt;br /&gt;
=== postgreSQL ===&lt;br /&gt;
&lt;br /&gt;
Inside the container run: {{Cmd|chmod go+w /dev/null}} to fix {{Cmd|rc-service postgresql start}}&lt;br /&gt;
&lt;br /&gt;
=== openVPN ===&lt;br /&gt;
&lt;br /&gt;
see [[Setting_up_a_OpenVPN_server#openVPN_and_LXC]]&lt;br /&gt;
&lt;br /&gt;
== LXC 1.0 Additional information ==&lt;br /&gt;
&lt;br /&gt;
Some info regarding new features in LXC 1.0&lt;br /&gt;
 &lt;br /&gt;
https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=11369</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=11369"/>
		<updated>2015-11-04T04:28:56Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
The manual notes on this page can be [http://it-offshore.co.uk/linux/21-linux/alpine-linux/25-alpine-linux-luks-encrypted-installations automated] with:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;A custom version of &#039;setup-disk&#039; with LUKS support.&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;A custom Partition Editor (&#039;setup-partitions&#039;) to create &amp;amp; mount normal / LUKS / LVM partitions.&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;[http://it-offshore.co.uk/linux/21-linux/alpine-linux/25-alpine-linux-luks-encrypted-installations Both scripts] support GPT Partition Schemes.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support &lt;br /&gt;
  mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
or alternatively rebuild the initramfs with:&lt;br /&gt;
&lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
rc-service haveged start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash whirlpool --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# *** note mounts under /dev/vol/partition NOT /dev/mapper/vol-partition - for installation ONLY.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# mkinitfs fails to generate a working initramfs for LUKS when installing a new system with /dev/mapper &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# LVM devices mounted (but boots installed systems with /dev/mapper LVM devices in /etc/fstab without problems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvmcrypt /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# alternative method (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# apk fix --root $MNT linux-grsec&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_disks_manually&amp;diff=11368</id>
		<title>Setting up disks manually</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_disks_manually&amp;diff=11368"/>
		<updated>2015-11-04T04:13:35Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Custom partitioning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
You may have complex needs that aren&#039;t handled automatically by the [[Alpine Setup Scripts]]. In those cases, you&#039;ll need to prepare your disks manually.&lt;br /&gt;
&lt;br /&gt;
It is possible to have one or more of RAID, encryption, and/or LVM on your {{Path|/}} (root) volume. However, the Alpine init script only knows how to handle them when they&#039;re layered in that order, and your initram and extlinux.conf file in the {{Path|/boot}} partition are configured properly.&lt;br /&gt;
&lt;br /&gt;
Your {{Path|/boot}} cannot reside on a encrypted or LVM volume, at least not with Alpine&#039;s default bootloader (extlinux). (Grub2 can deal with {{Path|/boot}} being on an LVM volume.) The usual practice is to create a small partition for {{Path|/boot}}, and then devote the rest of your disk to a separate partition on which you layer one or more of RAID, encryption, and/or LVM.&lt;br /&gt;
&lt;br /&gt;
Sometimes {{Path|/boot}} is also setup as a mirrored (RAID1) volume, however this is just for post-init access. That way, when you write a new kernel or bootloader config file to {{Path|/boot}}, it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from.&lt;br /&gt;
&lt;br /&gt;
So, typical setups might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
One-disk system&lt;br /&gt;
---------------&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
  |  small partition (32--100M), holding           |&lt;br /&gt;
  |  only /boot, filesystem needn&#039;t be journaled   |&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
  |  rest of disk in second partition              |&lt;br /&gt;
  |  +------------------------------------------+  |&lt;br /&gt;
  |  | cryptsetup volume                        |  |&lt;br /&gt;
  |  |  +-------------------------------------+ |  |&lt;br /&gt;
  |  |  |  LVM PV, containing single VG,      | |  |&lt;br /&gt;
  |  |  |  containing multiple LVs, holding   | |  |&lt;br /&gt;
  |  |  |  /, /home, swap, etc                | |  |&lt;br /&gt;
  |  |  +-------------------------------------+ |  |&lt;br /&gt;
  |  +------------------------------------------+  |&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two-disk system&lt;br /&gt;
---------------&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+&lt;br /&gt;
  |  small partition (32--100M), holding           |  |  small partition (32--100M), holding           | These 2 partitions might&lt;br /&gt;
  |  only /boot, filesystem needn&#039;t be journaled   |  |  only /boot, filesystem needn&#039;t be journaled   | form a mirrored (RAID1)&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+ volume&lt;br /&gt;
  |  rest of disk in second partition              |  |  rest of disk in second partition              |&lt;br /&gt;
  | T================================================================================================T | These 2 partitions form&lt;br /&gt;
  | T +--------------------------------------------------------------------------------------------+ T | a second mirrored&lt;br /&gt;
  | T | cryptsetup volume                                                                          | T | (RAID1) volume&lt;br /&gt;
  | T |  +---------------------------------------------------------------------------------------+ | T |&lt;br /&gt;
  | T |  | LVM PV, containing single VG,                                                         | | T |&lt;br /&gt;
  | T |  | containing multiple LVs, holding                                                      | | T |&lt;br /&gt;
  | T |  | /, /home, swap, etc                                                                   | | T |&lt;br /&gt;
  | T |  +---------------------------------------------------------------------------------------+ | T |&lt;br /&gt;
  | T +--------------------------------------------------------------------------------------------+ T |&lt;br /&gt;
  | T================================================================================================T |&lt;br /&gt;
  |                                                |  |                                                |&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In a three-disk system, the {{Path|/boot}} would still be RAID1, but the larger partition might in that case be RAID5.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RAID ===&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build a RAID array if you supply the &#039;&#039;&#039;-r&#039;&#039;&#039; switch, or if you specify more than one device.&lt;br /&gt;
&lt;br /&gt;
If you instead want to build your RAID array manually, see [[Setting up a software RAID array]]. Then you can add additional layers of encryption and/or LVM, or just assemble the RAID array, and supply the {{Path|/dev/md&amp;lt;i&amp;gt;i&amp;lt;/i&amp;gt;}} device directly to [[setup-disk]]. When you&#039;re finished, be sure to disassemble the RAID array before rebooting.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; sees that you&#039;re using RAID---either because you gave it the &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt; switch, or multiple devices, or a {{Path|/dev/md&amp;lt;i&amp;gt;i&amp;lt;/i&amp;gt;}} device---then it will setup your initramfs and extlinux.conf file properly. However, in other cases, such as when you&#039;re also using encryption, or you invoke &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; with a mounted directory argument, these might not be properly setup for RAID. In that case, you may need to manually edit/rebuild them. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=echo &amp;quot;/sbin/mdadm&amp;quot; &amp;gt; $MNT/etc/mkinitfs/files.d/raid&lt;br /&gt;
echo &amp;quot;/etc/mdadm.conf&amp;quot; &amp;gt;&amp;gt; $MNT/etc/mkinitfs/files.d/raid&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes raid (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure modules=... contains&lt;br /&gt;
&amp;amp;#35; raid1 or raid456 (whichever your / is on; this field is comma-separated)&lt;br /&gt;
&amp;amp;#35; also check the root= setting&lt;br /&gt;
extlinux --raid --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Todo|Does adding the &amp;lt;code&amp;gt;--update&amp;lt;/code&amp;gt; option to &amp;lt;code&amp;gt;extlinux ...&amp;lt;/code&amp;gt; suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;, as well?}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. And you might need to copy {{Path|/usr/share/syslinux/mbr.bin}} to your disk&#039;s MBR.&lt;br /&gt;
&lt;br /&gt;
=== Encryption ===&lt;br /&gt;
&lt;br /&gt;
See [[Setting up encrypted volumes with LUKS]]. Then you can add an additional layer of LVM, or just unlock the volume you&#039;ve created (using &amp;lt;code&amp;gt;cryptsetup luksOpen ...&amp;lt;/code&amp;gt;), and supply the {{Path|/dev/mapper/&amp;lt;i&amp;gt;something&amp;lt;/i&amp;gt;}} device directly to [[setup-disk]]. When you&#039;re finished, be sure to relock the volume (using &amp;lt;code&amp;gt;cryptsetup luksClose ...&amp;lt;/code&amp;gt;) before rebooting.&lt;br /&gt;
&lt;br /&gt;
If you install your {{Path|/}} (root) on an encrypted volume, you&#039;ll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into, that you&#039;ve created the cryptvolume on the device {{Path|/dev/md2}}, and that you want to unlock the encrypted volume into a virtual volume named &amp;quot;crypt&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes cryptsetup (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted)&lt;br /&gt;
&amp;amp;#35; also check the root= setting&lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Todo|Does adding the &amp;lt;code&amp;gt;--update&amp;lt;/code&amp;gt; option to &amp;lt;code&amp;gt;extlinux ...&amp;lt;/code&amp;gt; suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;, as well?}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.&lt;br /&gt;
&lt;br /&gt;
=== LVM ===&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build and use volumes in a LVM group if you supply the &#039;&#039;&#039;-L&#039;&#039;&#039; switch.&lt;br /&gt;
&lt;br /&gt;
If you instead want to build your LVM system manually, see [[Setting up Logical Volumes with LVM]]. Then &amp;lt;code&amp;gt;vgchange -ay&amp;lt;/code&amp;gt;, format and mount your volumes, and supply the root mountpoint to [[setup-disk]]. When you&#039;re finished, be sure to&lt;br /&gt;
{{Cmd|umount ...&lt;br /&gt;
vgchange -an}}&lt;br /&gt;
before rebooting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; sees that you&#039;re using LVM---perhaps because you gave it the &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt; switch---then it will setup your initram and extlinux.conf file properly. However, in other cases, these might not be properly setup. In that case, you may need to manually edit/rebuild them. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes lvm (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly&lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Todo|Does adding the &amp;lt;code&amp;gt;--update&amp;lt;/code&amp;gt; option to &amp;lt;code&amp;gt;extlinux ...&amp;lt;/code&amp;gt; suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;, as well?}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.&lt;br /&gt;
&lt;br /&gt;
=== Custom partitioning ===&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will by default set up a root parition, a separate /boot partition and a swap. If you want a different layout you can manually create the parititions, filesystems and mount them up on {{Path|/mnt}} (or any other mount point) and then run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|setup-disk /mnt}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will install your running system on the mounted root, detect your file system layout and generate a fstab. You are responsible for making the proper partition bootable and make sure the MBR is ok for extlinux.&lt;br /&gt;
&lt;br /&gt;
See also [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]&lt;br /&gt;
&lt;br /&gt;
=== Dual-booting ===&lt;br /&gt;
See [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]&lt;br /&gt;
&lt;br /&gt;
=== Other needs ===&lt;br /&gt;
* [[Installing Alpine Linux in a chroot]]&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 Create partition with with type &amp;quot;Linux&amp;quot; (83).&lt;br /&gt;
 apk_add e2fsprogs rsync&lt;br /&gt;
 mkfs.ext3 /dev/hda1&lt;br /&gt;
 mount -t ext3 /dev/hda1 /mnt&lt;br /&gt;
 ROOT=/mnt apk_add uclibc busybox apk-tools alpine-baselayout alpine-conf&lt;br /&gt;
 # Install busybox links&lt;br /&gt;
 mkdir /mnt/proc &amp;amp;&amp;amp; mount --bind /proc /mnt/proc &amp;amp;&amp;amp; chroot /mnt /bin/busybox --install -s &amp;amp;&amp;amp; umount /mnt/proc&lt;br /&gt;
 # Copy the apk repository&lt;br /&gt;
 rsync -ruav /media/cdrom/apks /mnt&lt;br /&gt;
 mkdir /mnt/etc/apk &amp;amp;&amp;amp; echo &amp;quot;APK_PATH=file://apks&amp;quot; &amp;gt; /mnt/etc/apk/apk.conf&lt;br /&gt;
 # Copy the hd/ext3 initramfs image, kernel and kernel modules&lt;br /&gt;
 rsync -ruav /media/cdrom/kernel/generic/hd-ext3.gz /media/cdrom/kernel/generic/bzImage /mnt&lt;br /&gt;
 rsync -ruav /lib/modules/* /mnt/lib/modules/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Setting up the RAID ==&lt;br /&gt;
Set up a raid array as described [[Setting up a software RAID1 array|here]].&lt;br /&gt;
In this document two raid arrays are configured: md0 for swap (512MB) and md1 for /var. &lt;br /&gt;
&lt;br /&gt;
== Create filesystem ==&lt;br /&gt;
We need to install the software to create the filesystem (&amp;quot;format&amp;quot; the partition).&lt;br /&gt;
 apk_add e2fsprogs&lt;br /&gt;
&lt;br /&gt;
If you use an Alpine release older than 1.3.8 you will need to manually create a link to /etc/mtab.&lt;br /&gt;
 ln -fs /proc/mounts /etc/mtab&lt;br /&gt;
&lt;br /&gt;
Create the filesystem. The -j option makes it ext&#039;&#039;&#039;3&#039;&#039;&#039;. Without the -j option it will become non-journaling ext&#039;&#039;&#039;2&#039;&#039;&#039;. This step might take some time if your partition is big.&lt;br /&gt;
 mke2fs -j /dev/md1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now edit /etc/fstab and add your new partitions. Mine looks like this:&lt;br /&gt;
 none            /proc           proc    defaults 0 0&lt;br /&gt;
 none            /sys            sysfs   defaults 0 0&lt;br /&gt;
 udev            /dev            tmpfs   size=100k 0 0&lt;br /&gt;
 none            /dev/pts        devpts  defaults 0 0&lt;br /&gt;
 tmpfs           /dev/shm        tmpfs   defaults 0 0&lt;br /&gt;
 /dev/cdrom      /media/cdrom    iso9660 ro 0 0&lt;br /&gt;
 /dev/fd0        /media/floppy   vfat    noauto  0 0&lt;br /&gt;
 /dev/usba1      /media/usb      vfat    noauto  0 0&lt;br /&gt;
 none            /proc/bus/usb   usbfs noauto 0 0&lt;br /&gt;
  &lt;br /&gt;
 /dev/md0        swap            swap    defaults 0 0&lt;br /&gt;
 /dev/md1        /var            ext3    defaults 0 0&lt;br /&gt;
&lt;br /&gt;
== Move the data ==&lt;br /&gt;
Now you should stop all services running that put anything in /var (syslog for example). If you have booted on a clean installation and not run setup-alpine, then no services should be running. However, some packages might have created dirs in /var so we need to backup /var mount the new and move all backed up dirs back to the raided /var.&lt;br /&gt;
&lt;br /&gt;
 mv /var /var.tmp&lt;br /&gt;
 mkdir /var&lt;br /&gt;
 mount /var&lt;br /&gt;
 mv /var.tmp/* /var&lt;br /&gt;
 rmdir /var.tmp&lt;br /&gt;
&lt;br /&gt;
Verify that everyting looks ok with the &#039;&#039;df&#039;&#039; utility.&lt;br /&gt;
 ~ $ df&lt;br /&gt;
 Filesystem           1k-blocks      Used Available Use% Mounted on&lt;br /&gt;
 none                    255172     23544    231628   9% /&lt;br /&gt;
 udev                       100         0       100   0% /dev&lt;br /&gt;
 /dev/cdrom              142276    142276         0 100% /media/cdrom&lt;br /&gt;
 /dev/md1              37977060    181056  35866876   1% /var&lt;br /&gt;
&lt;br /&gt;
== Survive reboots ==&lt;br /&gt;
Now we have everything up and running. We need to make sure that everything will be restored during next reboot.&lt;br /&gt;
&lt;br /&gt;
Create an initscript that will mount /var for you during boot. I call it /etc/init.d/mountdisk and it looks like this:&lt;br /&gt;
 #!/sbin/runscript&lt;br /&gt;
 &lt;br /&gt;
 start() {&lt;br /&gt;
         ebegin &amp;quot;Mounting /var&amp;quot;&lt;br /&gt;
         mount /var&lt;br /&gt;
         eend $?&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 stop() {&lt;br /&gt;
         ebegin &amp;quot;Unmounting /var&amp;quot;&lt;br /&gt;
         umount /var&lt;br /&gt;
         eend $?&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Make it exectutable:&lt;br /&gt;
 chmod +x /etc/init.d/mountdisk&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Since Alpine-1.7.3 there is a &#039;&#039;localmount&#039;&#039; script shipped so you will not need to create your own &#039;&#039;mountdisk&#039;&#039; script.&lt;br /&gt;
&lt;br /&gt;
And that /var is mounted *after* raid is created. The -k option will make alpine to unmount the /Var partition during boot. Also add start of swap too boot&lt;br /&gt;
 rc_add -k -s 06 mountdisk&lt;br /&gt;
 rc_add -k -s 06 swap&lt;br /&gt;
&lt;br /&gt;
The /dev/md* device nodes will not be created automatically so we need to put the on floppy too.&lt;br /&gt;
 lbu include /dev/md*&lt;br /&gt;
&lt;br /&gt;
If you have users on the server and want /home to be permanent, you can create a directory /var/home and create links to /var/home.&lt;br /&gt;
 mkdir /var/home&lt;br /&gt;
 mv /home/* /var/home/&lt;br /&gt;
 ln -s /var/home/* /home/&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You cannot just replace /home with a link that points to /var/home since the base has a /home directory. When the boot tries to copy the config from floppy it will fail because of the already existing /home directory.&lt;br /&gt;
&lt;br /&gt;
Make sure the links are stored to floppy:&lt;br /&gt;
 lbu include /home/*&lt;br /&gt;
&lt;br /&gt;
Also remember to move any newly created users to /var/home and create a link:&lt;br /&gt;
 adduser bob&lt;br /&gt;
 mv /home/bob /var/home/&lt;br /&gt;
 ln -s /var/home/bob /home/bob&lt;br /&gt;
 lbu include /home/bob&lt;br /&gt;
&lt;br /&gt;
Save to floppy:&lt;br /&gt;
 lbu commit floppy&lt;br /&gt;
&lt;br /&gt;
== Test it works ==&lt;br /&gt;
Reboot computer. Now should the raid start and /var should be mounted. Check with df:&lt;br /&gt;
 ~ $ df&lt;br /&gt;
 Filesystem           1k-blocks      Used Available Use% Mounted on&lt;br /&gt;
 none                    255172     23976    231196   9% /&lt;br /&gt;
 mdev                       100         0       100   0% /dev&lt;br /&gt;
 /dev/cdrom              140932    140932         0 100% /media/cdrom&lt;br /&gt;
 /dev/md1              37977060    180984  35866948   1% /var&lt;br /&gt;
&lt;br /&gt;
== Upgrades ==&lt;br /&gt;
Since the package database is placed on disk, you cannot update by simply replacing the CDROM. You will have to either run the upgrade on the new CDROM or run &#039;&#039;apk_add -u ... &amp;amp;&amp;amp; update-conf&#039;&#039; manually.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting up swap ==&lt;br /&gt;
&lt;br /&gt;
# create partition with type &amp;quot;linux swap&amp;quot; (82) (If you&#039;re going to use an LVM logical volume for swap, skip this step and &amp;lt;code&amp;gt;lvcreate&amp;lt;/code&amp;gt; that instead.)&lt;br /&gt;
# &amp;lt;code&amp;gt;mkswap /dev/sda2&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;echo -e &amp;quot;/dev/sda2 none swap sw 0 0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;swapon /dev/sda2&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;rc-service swap start&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Then {{Cmd|free -m}} will show how much swap space is available (in MB).&lt;br /&gt;
&lt;br /&gt;
If you prefer maximum speed, you don&#039;t need configure any raid devices for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically. The downside is that at the moment one disk fails, the system will go down. For better reliability, put swap on RAID1. &lt;br /&gt;
&lt;br /&gt;
{{Todo|Instructions for cryptswap?}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Storage]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Logical_Volumes_with_LVM&amp;diff=11367</id>
		<title>Setting up Logical Volumes with LVM</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Logical_Volumes_with_LVM&amp;diff=11367"/>
		<updated>2015-11-04T04:06:09Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* More Info on LVM */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Storage]]&lt;br /&gt;
{{Tip|This process can be done automatically by using the [[setup-disk]] script, using the -L option.}}&lt;br /&gt;
This document how to create logical volumes in Alpine using lvm2.&lt;br /&gt;
&lt;br /&gt;
LVM is collection of programs that allow larger physical disks to be reassembled into &amp;quot;logical&amp;quot; disks that can be shrunk or expanded as data needs change.&lt;br /&gt;
&lt;br /&gt;
In this document we will use a [[Setting up a software RAID array|software RAID1 device]] as physical storage for our logical volumes. We will set up a swap partition and a data partition for [[Setting up a basic vserver|vservers ]]&lt;br /&gt;
=== Installing LVM software ===&lt;br /&gt;
First we need to load the kernel driver, &#039;&#039;dm-mod&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe dm-mod}}&lt;br /&gt;
&lt;br /&gt;
We also want it to be loaded during next reboot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo dm-mod &amp;gt;&amp;gt; /etc/modules}}&lt;br /&gt;
&lt;br /&gt;
We also need the userspace programs.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add lvm2}}&lt;br /&gt;
&lt;br /&gt;
=== Preparing the physical volumes ===&lt;br /&gt;
First we need to tell LVM that the partition is available as a physical volume and can be added to a volume group. In this example we use a software raid array as physical volume.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|pvcreate /dev/md0}}&lt;br /&gt;
&lt;br /&gt;
=== Preparing the Volume Group ===&lt;br /&gt;
We can then create a volume group and add the physical volume &#039;&#039;/dev/md0&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vgcreate vg0 /dev/md0}}&lt;br /&gt;
&lt;br /&gt;
If we later need more space we can add additional physcal volumes with &#039;&#039;vgextend&#039;&#039;. All physcal disks/partitions added need to be prepared with &#039;&#039;pvcreate&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Creating Logical volumes ===&lt;br /&gt;
In the volume group we can create logical volumes. To create a 1GB volume called &#039;&#039;swap&#039;&#039; and a 6GB volume called &#039;vservers&#039;&#039; on the volume group &#039;&#039;vg0&#039;&#039; we run&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lvcreate -n swap -L 1G vg0&lt;br /&gt;
lvcreate -n vservers -L 6G vg0}}&lt;br /&gt;
&lt;br /&gt;
=== Display Logical Volumes ===&lt;br /&gt;
You can now se the logical volumes with the lvdisplay utility.&lt;br /&gt;
&lt;br /&gt;
 lvdisplay&lt;br /&gt;
  --- Logical volume ---&lt;br /&gt;
  LV Name                /dev/vg0/swap&lt;br /&gt;
  VG Name                vg0&lt;br /&gt;
  LV UUID                a4NYOi-FQP6-Lj5Q-0TYk-Jjtk-Qxjt-nxeBPn&lt;br /&gt;
  LV Write Access        read/write&lt;br /&gt;
  LV Status              available&lt;br /&gt;
  # open                 0&lt;br /&gt;
  LV Size                1.00 GB&lt;br /&gt;
  Current LE             256&lt;br /&gt;
  Segments               1&lt;br /&gt;
  Allocation             inherit&lt;br /&gt;
  Read ahead sectors     0&lt;br /&gt;
  Block device           253:0&lt;br /&gt;
   &lt;br /&gt;
  --- Logical volume ---&lt;br /&gt;
  LV Name                /dev/vg0/vservers&lt;br /&gt;
  VG Name                vg0&lt;br /&gt;
  LV UUID                16VMmy-7I0s-eeoW-tL2V-JrlN-jM6C-d0wEg0&lt;br /&gt;
  LV Write Access        read/write&lt;br /&gt;
  LV Status              available&lt;br /&gt;
  # open                 0&lt;br /&gt;
  LV Size                6.00 GB&lt;br /&gt;
  Current LE             1536&lt;br /&gt;
  Segments               1&lt;br /&gt;
  Allocation             inherit&lt;br /&gt;
  Read ahead sectors     0&lt;br /&gt;
  Block device           253:1&lt;br /&gt;
&lt;br /&gt;
=== Rename Logical Volumes ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lvrename /dev/vg0/vservers /dev/vg0/database}}&lt;br /&gt;
&lt;br /&gt;
=== Extend Logical Volumes ===&lt;br /&gt;
If you want to add space and the volume has the room for it...&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lvextend -L +50G /dev/vg0/vservers}}&lt;br /&gt;
&lt;br /&gt;
If you want to set the space to a new larger size...&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lvextend -L 10G /dev/vg0/vservers}}&lt;br /&gt;
&lt;br /&gt;
=== Start LVM during Boot ===&lt;br /&gt;
We want lvm to init the logical volumes during boot. There is a boot service named &#039;&#039;lvm&#039;&#039; to do this. If your volumes are on raid, make sure that &#039;&#039;/etc/init.d/lvm&#039;&#039; is started after mdadm-raid.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add lvm}}&lt;br /&gt;
&lt;br /&gt;
Or, on Alpine Linux 1.8 or earlier:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc_add -s 12 -k lvm}}&lt;br /&gt;
&lt;br /&gt;
=== Setting up swap ===&lt;br /&gt;
Now we have our devices in /dev/vg0 and can use them as normal disk paritions. To set up swap:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkswap /dev/vg0/swap}}&lt;br /&gt;
&lt;br /&gt;
Add the following line to your &#039;&#039;/etc/fstab&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 /dev/vg0/swap   none            swap     sw    0 0&lt;br /&gt;
&lt;br /&gt;
=== Setting up /vservers partition ===&lt;br /&gt;
Finally we want to set up an XFS partition for /vservers.&lt;br /&gt;
&lt;br /&gt;
Install xfsprogs.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add xfsprogs}}&lt;br /&gt;
&lt;br /&gt;
Create filesystem on /dev/vg0/vservers.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkfs.xfs /dev/vg0/vservers}}&lt;br /&gt;
&lt;br /&gt;
Add the mount information to your /etc/fstab: NOTE:tagxid may cause this not to mount. Try this by hand and check dmesg to see if there are any errors&lt;br /&gt;
&lt;br /&gt;
 /dev/vg0/vservers /vservers     xfs     noatime,tagxid 0 0&lt;br /&gt;
&lt;br /&gt;
Note that the &#039;&#039;tagxid&#039;&#039; option is specific for setting up vserver [http://oldwiki.linux-vserver.org/Disk+Limits disk limits] so it might be you don&#039;t want it. The &#039;&#039;noatime&#039;&#039; option is to increase performance but you will no longer know when files were accessed last time.&lt;br /&gt;
&lt;br /&gt;
=== Starting localmount and swap ===&lt;br /&gt;
&lt;br /&gt;
Now we can mount our partition.&lt;br /&gt;
{{Cmd|mount /vservers}}&lt;br /&gt;
&lt;br /&gt;
Make sure we run &#039;&#039;localmount&#039;&#039; during boot too, and that it is done after lvm. In Alpine Linux 1.9 and newer this should not be needed&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add localmount boot}}&lt;br /&gt;
&lt;br /&gt;
Or, on Alpine Linux 1.8 or earlier:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc_add -s 14 -k localmount}}&lt;br /&gt;
&lt;br /&gt;
Start the swap service and make sure it starts during next reboot and that it starts &#039;&#039;&#039;after&#039;&#039;&#039; lvm.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|/etc/init.d/swap start&lt;br /&gt;
rc-update add swap}}&lt;br /&gt;
&lt;br /&gt;
Or, on Alpine Linux 1.8 or earlier:&lt;br /&gt;
{{Cmd|/etc/init.d/swap start&lt;br /&gt;
rc_add -s 14 -k swap}}&lt;br /&gt;
&lt;br /&gt;
=== More Info on LVM ===&lt;br /&gt;
These resources may be helpful:&lt;br /&gt;
&lt;br /&gt;
* the [http://tldp.org/HOWTO/LVM-HOWTO/commontask.html common tasks] section in the [http://tldp.org/HOWTO/LVM-HOWTO/index.html LVM Howto]&lt;br /&gt;
* [http://wiki.alpinelinux.org/wiki/LVM_on_LUKS Alpine wiki page for LVM on LUKS]&lt;br /&gt;
* [https://wiki.archlinux.org/index.php/LVM Arch wiki page on LVM]&lt;br /&gt;
* [https://wiki.archlinux.org/index.php/Software_RAID_and_LVM Arch wiki page on RAID and LVM]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=11366</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=11366"/>
		<updated>2015-11-04T04:02:03Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
The manual notes on this page can be [http://it-offshore.co.uk/linux/21-linux/alpine-linux/25-alpine-linux-luks-encrypted-installations automated] with:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;A custom version of &#039;setup-disk&#039; with LUKS support.&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;A custom Partition Editor (&#039;setup-partitions&#039;) to create &amp;amp; mount normal / LUKS / LVM partitions.&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Both scripts support GPT Partition Schemes.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support &lt;br /&gt;
  mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
or alternatively rebuild the initramfs with:&lt;br /&gt;
&lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
rc-service haveged start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash whirlpool --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# *** note mounts under /dev/vol/partition NOT /dev/mapper/vol-partition - for installation ONLY.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# mkinitfs fails to generate a working initramfs for LUKS when installing a new system with /dev/mapper &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# LVM devices mounted (but boots installed systems with /dev/mapper LVM devices in /etc/fstab without problems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvmcrypt /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# alternative method (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# apk fix --root $MNT linux-grsec&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_encrypted_volumes_with_LUKS&amp;diff=11365</id>
		<title>Setting up encrypted volumes with LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_encrypted_volumes_with_LUKS&amp;diff=11365"/>
		<updated>2015-11-04T03:36:26Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See:&lt;br /&gt;
&lt;br /&gt;
http://wiki.alpinelinux.org/wiki/LVM_on_LUKS &lt;br /&gt;
&lt;br /&gt;
https://wiki.archlinux.org/index.php/System_Encryption_with_LUKS&amp;lt;nowiki /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Itoffshore&amp;diff=11043</id>
		<title>User:Itoffshore</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Itoffshore&amp;diff=11043"/>
		<updated>2015-07-11T22:59:32Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Created page with &amp;quot;On &amp;lt;code&amp;gt;#alpine-linux&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;#alpine-devel&amp;lt;/code&amp;gt; I am &amp;lt;code&amp;gt;BitL0G1c&amp;lt;/code&amp;gt;  Various guides for Alpine can be found on [http://it-offshore.co.uk/linux/alpine-linux m...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;On &amp;lt;code&amp;gt;#alpine-linux&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;#alpine-devel&amp;lt;/code&amp;gt; I am &amp;lt;code&amp;gt;BitL0G1c&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Various guides for Alpine can be found on [http://it-offshore.co.uk/linux/alpine-linux my website].&lt;br /&gt;
&lt;br /&gt;
My setup-scripts are hosted on [https://github.com/itoffshore/alpine-linux-scripts Github].&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Creating_patches&amp;diff=10840</id>
		<title>Creating patches</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Creating_patches&amp;diff=10840"/>
		<updated>2015-05-06T16:10:00Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: fix git send-mail for multiple patches&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Patches should be created with git and submitted to [mailto:alpine-aports@lists.alpinelinux.org alpine-aports] mailing list with &#039;&#039;git send-email&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Only the last commit with &#039;git send-email&#039; ==&lt;br /&gt;
&lt;br /&gt;
To submit the last commit as a patch to [mailto:alpine-aports@lists.alpinelinux.org alpine-aports] mailing list:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|git send-email --to alpine-aports@lists.alpinelinux.org HEAD^}}&lt;br /&gt;
&lt;br /&gt;
The first line in commit message will be &#039;&#039;subject&#039;&#039; and the long description (separated with empty line) will be the body in the email. The example below shows &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Initial APKBUILD file of packagename  &amp;lt;- Subject line&lt;br /&gt;
&lt;br /&gt;
Enter some details about your package &amp;lt;- Mail body&lt;br /&gt;
here if you like. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The git send-email command is provided by the &#039;&#039;&#039;git-email&#039;&#039;&#039; package (&#039;&#039;&#039;git-perl&#039;&#039;&#039; in v2.7 and older). }}&lt;br /&gt;
&lt;br /&gt;
Read [[Development using git]] to send patch with SMTP Auth.&lt;br /&gt;
&lt;br /&gt;
== Multiple commits with &#039;git send-email&#039; ==&lt;br /&gt;
&lt;br /&gt;
If you have many commits you can create a directory with patches and send them with &amp;lt;tt&amp;gt;git send-email&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;rm -Rf patches&lt;br /&gt;
mkdir patches&lt;br /&gt;
git format-patch -o patches origin&lt;br /&gt;
git send-email patches --compose --no-chain-reply-to --to alpine-aports@lists.alpinelinux.org&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can also format patches for the last x number of commits with:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;git format-patch -x -o patches&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This will produce the patches for each local commit in the directory &amp;quot;patches&amp;quot; and send them.&lt;br /&gt;
Use --no-chain-reply-to make sure it doesn&#039;t reply.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- what does the following mean? --&amp;gt;&lt;br /&gt;
Don&#039;t do:&lt;br /&gt;
* [PATCH 0/m]&lt;br /&gt;
** [PATCH 1/m]&lt;br /&gt;
*** [PATCH 2/m]&lt;br /&gt;
**** ...&lt;br /&gt;
But do:&lt;br /&gt;
* [PATCH 0/m]&lt;br /&gt;
** [PATCH 1/m]&lt;br /&gt;
** [PATCH 2/m]&lt;br /&gt;
** ..&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Git]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=10834</id>
		<title>LXC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=10834"/>
		<updated>2015-05-03T21:17:26Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Add note for postgresql + autostart note - I think the original autostart note is broken in current LXC &amp;amp; s/be removed ?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://lxc.sourceforge.net/ Linux Containers (LXC)] provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the &amp;quot;host&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Install the required packages:&lt;br /&gt;
{{Cmd|apk add lxc lxc-templates bridge}}&lt;br /&gt;
&lt;br /&gt;
== Prepare network on host ==&lt;br /&gt;
Set up a [[bridge]] on the host. Example &#039;&#039;/etc/network/interfaces&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auto br0&lt;br /&gt;
iface br0 inet dhcp&lt;br /&gt;
    bridge-ports eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network configuration template for the guests, &#039;&#039;/etc/lxc/lxc.conf&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a guest ==&lt;br /&gt;
&lt;br /&gt;
=== Alpine Template ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine}}&lt;br /&gt;
&lt;br /&gt;
This will create a &#039;&#039;/var/lib/lxc/guest1&#039;&#039; directory with a &#039;&#039;config&#039;&#039; file and a &#039;&#039;rootfs&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Note that by default alpine template &#039;&#039;&#039;does not have networking service on&#039;&#039;&#039;, you will need to add it using lxc-console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If running on x86_64 architecture, it is possible to create a 32bit guest:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine -- --arch x86}}&lt;br /&gt;
&lt;br /&gt;
=== Debian template ===&lt;br /&gt;
&lt;br /&gt;
In order to create a debian template container you will need to install some packages:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add debootstrap rsync}}&lt;br /&gt;
&lt;br /&gt;
Also you will need to turn off some grsecurity chroot options otherwise the debootstrap will fail:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you can run:&lt;br /&gt;
{{Cmd|SUITE{{=}}wheezy lxc-create -n guest1 -f /etc/lxc/lxc.conf -t debian}}&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping the guest ==&lt;br /&gt;
Create a symlink to the &#039;&#039;/etc/init.d/lxc&#039;&#039; script for your guest.&lt;br /&gt;
{{Cmd|ln -s lxc /etc/init.d/lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can start your guest with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 start}}&lt;br /&gt;
&lt;br /&gt;
Stop it with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 stop}}&lt;br /&gt;
&lt;br /&gt;
Make it autostart on boot up with:&lt;br /&gt;
{{Cmd| rc-update add lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can also add to the container config: &amp;lt;code&amp;gt;lxc.start.auto = 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp; {{Cmd|rc-update add lxc}}&lt;br /&gt;
&lt;br /&gt;
to autostart containers by the lxc service only.&lt;br /&gt;
&lt;br /&gt;
== Connecting to the guest ==&lt;br /&gt;
By default sshd is not installed, so you will have to connect to a virtual console. This is done with:&lt;br /&gt;
{{Cmd|lxc-console -n guest1}}&lt;br /&gt;
&lt;br /&gt;
To disconnect from it, press {{key|Ctrl}}+{{key|a}} {{key|q}}&lt;br /&gt;
&lt;br /&gt;
== Deleting a guest ==&lt;br /&gt;
Make sure the guest is stopped and run:&lt;br /&gt;
{{Cmd|lxc-destroy -n guest1}}&lt;br /&gt;
This will erase everything, without asking any questions. It is equivalent to: {{Cmd|rm -r /var/lib/lxc/guest1}}&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a LXC container without modifying your network interfaces ===&lt;br /&gt;
&lt;br /&gt;
The problem with bridging is that the interface you bridge gets replaced with your new bridge interface.&lt;br /&gt;
That is to say that say you have an interface eth0 that you want to bridge, your eth0 interface gets replaced with the br0 interface that you create. It also means that the interface you use needs to be placed into promiscuous mode to catch all the traffic that could de destined to the other side of the bridge, which again may not be what you want.&lt;br /&gt;
&lt;br /&gt;
The solution is to create a dummy network interface, bridge that, and set up NAT so that traffic out of your bridge interface gets pushed through the interface of your choice.&lt;br /&gt;
&lt;br /&gt;
So, first, lets create that dummy interface (thanks to ncopa for talking me out of macvlan and pointing out the dummy interface kernel module)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|modprobe dummy}}&lt;br /&gt;
&lt;br /&gt;
This will create a dummy interface called dummy0 on your host.&lt;br /&gt;
&lt;br /&gt;
Now we will create a bridge called br0&lt;br /&gt;
&lt;br /&gt;
{{Cmd |brctl addbr br0&lt;br /&gt;
brctl setfd br0 0 }}&lt;br /&gt;
&lt;br /&gt;
and then make that dummy interface one end of the bridge&lt;br /&gt;
&lt;br /&gt;
{{Cmd | brctl addif br0 dummy0 }}&lt;br /&gt;
&lt;br /&gt;
Next, let&#039;s give that bridged interface a reason to exists&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | ifconfig br0 192.168.1.1 netmask 255.255.255.0 up}}&lt;br /&gt;
&lt;br /&gt;
Create a file for your container, let&#039;s say /etc/lxc/bridgenat.conf, with the following settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.name = eth1&lt;br /&gt;
lxc.network.ipv4 = 192.168.1.2/24&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and build your container with that file&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | lxc-create -n alpine -f /etc/lxc/bridgenat.conf -t alpine }}&lt;br /&gt;
&lt;br /&gt;
You should now be able to ping your container from your hosts, and your host from your container.&lt;br /&gt;
&lt;br /&gt;
Your container needs to know where to push traffic that isn&#039;t within it&#039;s subnet. To do so, we tell the container to route through the bridge interface br0&lt;br /&gt;
From inside the container run&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | route add default gw 192.168.1.1 }}&lt;br /&gt;
&lt;br /&gt;
The next step is you push the traffic coming from your private subnet over br0 out through your internet facing interface, or any interface you chose&lt;br /&gt;
&lt;br /&gt;
We are messing with your IP tables here, so make sure these settings don&#039;t conflict with anything you may have already set up, obviously.&lt;br /&gt;
&lt;br /&gt;
Say eth0 was your internet facing network interface, and br0 is the name of the bridge you made earlier, we&#039;d do this:&lt;br /&gt;
&lt;br /&gt;
{{ Cmd | echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE&lt;br /&gt;
iptables --append FORWARD --in-interface br0 -j ACCEPT&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you should be able to route through your bridge interface to the internet facing interface of your host from your container, just like at home!&lt;br /&gt;
&lt;br /&gt;
You could also have a dhcp server running on your host, and set it up to give IP addresses from your private subnet to any container that requests it, and then have one template for multiple alpine LXC containers, perfect for alpine development :)&lt;br /&gt;
&lt;br /&gt;
=== Using static IP ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using static IP, you need to configure this properly on guest&#039;s /etc/network/interfaces. To stay on the above example, modify &#039;&#039;/var/lib/lxc/guest1/rootfs/etc/network/interfaces&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
from&lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;dhcp&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
to &lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;static&#039;&#039;&#039;&lt;br /&gt;
     address &amp;lt;lxc-container-ip&amp;gt;   # IP which the lxc container should use&lt;br /&gt;
     gateway &amp;lt;gateway-ip&amp;gt;         # IP of gateway to use, mostly same as on lxc-host&lt;br /&gt;
     netmask &amp;lt;netmask&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mem and swap ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vim /boot/extlinux.conf}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
  APPEND initrd{{=}}initramfs-3.10.13-1-grsec root{{=}}UUID{{=}}7cd8789f-5659-40f8-9548-ae8f89c918ab modules{{=}}sd-mod,usb-storage,ext4 quiet cgroup_enable{{=}}memory swapaccount{{=}}1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== checkconfig ===&lt;br /&gt;
{{Cmd|lxc-checkconfig}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
Kernel configuration not found at /proc/config.gz; searching...&lt;br /&gt;
Kernel configuration found at /boot/config-3.10.13-1-grsec&lt;br /&gt;
--- Namespaces ---&lt;br /&gt;
Namespaces: enabled&lt;br /&gt;
Utsname namespace: enabled&lt;br /&gt;
Ipc namespace: enabled&lt;br /&gt;
Pid namespace: enabled&lt;br /&gt;
User namespace: missing&lt;br /&gt;
Network namespace: enabled&lt;br /&gt;
Multiple /dev/pts instances: enabled&lt;br /&gt;
&lt;br /&gt;
--- Control groups ---&lt;br /&gt;
Cgroup: enabled&lt;br /&gt;
Cgroup clone_children flag: enabled&lt;br /&gt;
Cgroup device: enabled&lt;br /&gt;
Cgroup sched: enabled&lt;br /&gt;
Cgroup cpu account: enabled&lt;br /&gt;
Cgroup memory controller: missing&lt;br /&gt;
Cgroup cpuset: enabled&lt;br /&gt;
&lt;br /&gt;
--- Misc ---&lt;br /&gt;
Veth pair device: enabled&lt;br /&gt;
Macvlan: enabled&lt;br /&gt;
Vlan: enabled&lt;br /&gt;
File capabilities: enabled&lt;br /&gt;
&lt;br /&gt;
Note : Before booting a new kernel, you can check its configuration&lt;br /&gt;
usage : CONFIG{{=}}/path/to/config /usr/bin/lxc-checkconfig&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== VirtualBox ===&lt;br /&gt;
&lt;br /&gt;
In order for network to work on containers you need to set &amp;quot;Promiscuous Mode&amp;quot; to &amp;quot;Allow All&amp;quot; in VirtualBox settings for the network adapter.&lt;br /&gt;
&lt;br /&gt;
[[File:VirtualBoxNetworkAdapter.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Virtualization]]&lt;br /&gt;
&lt;br /&gt;
=== postgreSQL ===&lt;br /&gt;
&lt;br /&gt;
Inside the container run: {{Cmd|chmod go+w /dev/null}} to fix {{Cmd|rc-service postgresql start}}&lt;br /&gt;
&lt;br /&gt;
== LXC 1.0 Additional information ==&lt;br /&gt;
&lt;br /&gt;
Some info regarding new features in LXC 1.0&lt;br /&gt;
 &lt;br /&gt;
https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10602</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10602"/>
		<updated>2015-04-02T19:40:24Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Configuring LVM on top of LUKS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;An install script with LUKS support can be found [http://it-offshore.co.uk/linux/21-linux/alpine-linux/25-alpine-linux-luks-encrypted-installations here]. A script to create &amp;amp; mount LUKS / LVM partitions is also available.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Both scripts support GPT Partition Schemes.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support &lt;br /&gt;
  mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
or alternatively rebuild the initramfs with:&lt;br /&gt;
&lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
rc-service haveged start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash whirlpool --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# *** note mounts under /dev/vol/partition NOT /dev/mapper/vol-partition - for installation ONLY.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# mkinitfs fails to generate a working initramfs for LUKS when installing a new system with /dev/mapper &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# LVM devices mounted (but boots installed systems with /dev/mapper LVM devices in /etc/fstab without problems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvmcrypt /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# alternative method (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# apk fix --root $MNT linux-grsec&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10601</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10601"/>
		<updated>2015-04-02T19:37:32Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Configuring LVM on top of LUKS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;An install script with LUKS support can be found [http://it-offshore.co.uk/linux/21-linux/alpine-linux/25-alpine-linux-luks-encrypted-installations here]. A script to create &amp;amp; mount LUKS / LVM partitions is also available. Both scripts support GPT Partition Schemes.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support &lt;br /&gt;
  mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
or alternatively rebuild the initramfs with:&lt;br /&gt;
&lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
rc-service haveged start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash whirlpool --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# *** note mounts under /dev/vol/partition NOT /dev/mapper/vol-partition - for installation ONLY.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# mkinitfs fails to generate a working initramfs for LUKS when installing a new system with /dev/mapper &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# LVM devices mounted (but boots installed systems with /dev/mapper LVM devices in /etc/fstab without problems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvmcrypt /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# alternative method (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# apk fix --root $MNT linux-grsec&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10592</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10592"/>
		<updated>2015-03-26T17:40:35Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;An install script with LUKS support can be found [http://it-offshore.co.uk/linux/21-linux/alpine-linux/25-alpine-linux-luks-encrypted-installations here]. A script to create &amp;amp; mount LUKS / LVM partitions is also available.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support &lt;br /&gt;
  mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
or alternatively rebuild the initramfs with:&lt;br /&gt;
&lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
rc-service haveged start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash whirlpool --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# *** note mounts under /dev/vol/partition NOT /dev/mapper/vol-partition - for installation ONLY.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# mkinitfs fails to generate a working initramfs for LUKS when installing a new system with /dev/mapper &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# LVM devices mounted (but boots installed systems with /dev/mapper LVM devices in /etc/fstab without problems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvmcrypt /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# alternative method (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# apk fix --root $MNT linux-grsec&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10250</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=10250"/>
		<updated>2015-01-10T21:07:46Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Configuring LVM on top of LUKS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support &lt;br /&gt;
  mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
or alternatively rebuild the initramfs with:&lt;br /&gt;
&lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
rc-service haveged start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash whirlpool --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# *** note mounts under /dev/vol/partition NOT /dev/mapper/vol-partition - for installation ONLY.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# mkinitfs fails to generate a working initramfs for LUKS when installing a new system with /dev/mapper &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# LVM devices mounted (but boots installed systems with /dev/mapper LVM devices in /etc/fstab without problems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvmcrypt /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# alternative method (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# apk fix --root $MNT linux-grsec&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9974</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9974"/>
		<updated>2014-05-15T09:33:58Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
    rc-update add haveged default&lt;br /&gt;
&lt;br /&gt;
* As an alternative to creating a /tmp partition in the below instructions, /tmp can be mounted in RAM with the following entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
    tmpfs /tmp tmpfs defaults,noexec,noatime,nodev,nosuid,mode=1777   0 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9972</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9972"/>
		<updated>2014-05-13T11:47:43Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9965</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9965"/>
		<updated>2014-05-07T22:49:57Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid,mode=1777      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# &#039;apk fix&#039; will give an error for missing modules - fix with a symlink in /lib/modules &amp;amp; rerun &#039;apk fix&#039; above&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9951</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9951"/>
		<updated>2014-05-05T18:23:59Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid,mode=1777      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=9950</id>
		<title>Tutorials and Howtos</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=9950"/>
		<updated>2014-05-01T20:59:11Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: /* Storage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:package_edutainment.svg|right|link=]]&lt;br /&gt;
{{TOC left}}&lt;br /&gt;
&#039;&#039;&#039;Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The tutorials are hands-on and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.&lt;br /&gt;
&lt;br /&gt;
Howtos are smaller articles explaining how to perform a particular task with Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
We encourage people to send in both complete articles as well as requesting topics to be covered. If you think you have the skills and knowledge to write an Alpine Linux related article please do so on this Wiki. If you want to request a topic, please add your request in this page&#039;s [[Talk:Tutorials_and_Howtos|Discussion]].&lt;br /&gt;
&lt;br /&gt;
{{Clear}}&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039; &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up disks manually]] &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
* [[Setting up a software RAID1 array]]&lt;br /&gt;
&amp;lt;!-- ** [[Setting up a /var partition on software IDE raid1]]  Obsolete, Installation and Storage --&amp;gt; &lt;br /&gt;
* [[Raid Administration]]&lt;br /&gt;
* [[Setting up encrypted volumes with LUKS]]&lt;br /&gt;
* [[Setting up LVM on LUKS]]&lt;br /&gt;
* [[Setting up Logical Volumes with LVM]]&lt;br /&gt;
** [[Setting up LVM on GPT-labeled disks]]&lt;br /&gt;
** [[Installing on GPT LVM]]&lt;br /&gt;
* [[Filesystems|Formatting HD/Floppy/Other]] &amp;lt;!-- just a stub --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up iSCSI]]&lt;br /&gt;
** [[iSCSI Raid and Clustered File Systems]]&lt;br /&gt;
* [[High performance SCST iSCSI Target on Linux software Raid]] &#039;&#039;(deprecated)&#039;&#039; &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
* [[Linux iSCSI Target (TCM)]]&lt;br /&gt;
* [[Disk Replication with DRBD]] &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Burning ISOs]] &amp;lt;!-- just some links now --&amp;gt;&lt;br /&gt;
* [[Bootmanagers]]&lt;br /&gt;
* [[Migrating data]]&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
* [[Configure Networking]]&lt;br /&gt;
* [[Connecting to a wireless access point]]&lt;br /&gt;
* [[Bonding]]&lt;br /&gt;
* [[Vlan]]&lt;br /&gt;
* [[Bridge]]&lt;br /&gt;
* [[How to configure static routes]]&lt;br /&gt;
&lt;br /&gt;
* [[Alpine Wall]] - [[How-To Alpine Wall]] - [[Alpine Wall User&#039;s Guide]] &#039;&#039;(a new firewall management framework)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Using serial modem]]&lt;br /&gt;
* [[Using HSDPA modem]]&lt;br /&gt;
* [[Setting up Satellite Internet Connection]]&lt;br /&gt;
* [[Using Alpine on Windows domain with IPSEC isolation]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039; &amp;lt;!-- Server and Networking --&amp;gt;&lt;br /&gt;
* [[How to setup a wireless access point]] &#039;&#039;(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)&#039;&#039;&lt;br /&gt;
* [[Setting up a OpenVPN server with Alpine]] &#039;&#039;(Allowing single users or devices to remotely connect to your network)&#039;&#039;&lt;br /&gt;
&amp;lt;!-- [[Using Racoon for Remote Sites]] is a different VPN tunnelling method, but that article is just a stub --&amp;gt;&lt;br /&gt;
* [[Experiences with OpenVPN-client on ALIX.2D3]]  &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Generating SSL certs with ACF]] &amp;lt;!-- Generating SSL certs with ACF 1.9 --&amp;gt;&lt;br /&gt;
* [[Setting up unbound DNS server]]&lt;br /&gt;
* [[Setting up nsd DNS server]]&lt;br /&gt;
* [[TinyDNS Format]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]] &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
* [[Freeradius Active Directory Integration]]&lt;br /&gt;
* [[Multi_ISP]] &#039;&#039;(Dual-ISP setup with load-balancing and automatic failover)&#039;&#039;&lt;br /&gt;
* [[OwnCloud]] &#039;&#039;(Installing OwnCloud)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Post-Install ==&lt;br /&gt;
&amp;lt;!-- If you edit this, please coordinate with Installation#Post-Install and Developer_Documentation#Package_management.  Note that these three sections are not exact duplicates. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Alpine Linux package management|Package Management (apk)]] &#039;&#039;(How to add/remove packages on your Alpine)&#039;&#039;&lt;br /&gt;
   &amp;lt;!-- [[Alpine Linux package management#Local_Cache|How to enable APK caching]] --&amp;gt;&lt;br /&gt;
** [[Comparison with other distros]]&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &amp;lt;!-- new --&amp;gt;&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
* [[Alpine Linux Init System|Init System (OpenRC)]] &#039;&#039;(Configure a service to automatically boot at next reboot)&#039;&#039;&lt;br /&gt;
** [[Multiple Instances of Services]]&lt;br /&gt;
   &amp;lt;!-- [[Writing Init Scripts]] --&amp;gt;&lt;br /&gt;
* [[Upgrading Alpine]]&lt;br /&gt;
&amp;lt;!-- Obsolete&lt;br /&gt;
 [[Upgrading Alpine - v1.9.x]]&lt;br /&gt;
 [[Upgrading Alpine - CD v1.8.x]]&lt;br /&gt;
 [[Upgrading Alpine - HD v1.8.x]]&lt;br /&gt;
 [[Upgrade to repository main|Upgrading to signed repositories]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
* [[setup-acf]] &#039;&#039;(Configures ACF (webconfiguration) so you can manage your box through https)&#039;&#039;&lt;br /&gt;
* [[Changing passwords for ACF|Changing passwords]]&lt;br /&gt;
* [[Ansible]] &#039;&#039;(Configuration management)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[Error message on boot: Address space collision: host bridge window conflicts with Adaptor ROM]]&lt;br /&gt;
&lt;br /&gt;
== Desktop Environment ==&lt;br /&gt;
&lt;br /&gt;
* [[XFCE Setup]] and [[Xfce Desktop|Desktop Ideas]]&lt;br /&gt;
* [[EyeOS]] &#039;&#039;(Cloud Computing Desktop)&#039;&#039;&lt;br /&gt;
* [[Oneye]] &#039;&#039;(Cloud Computing Desktop - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Owncloud]] &#039;&#039;(Cloud Computing Desktop - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
** (to be merged with [[OwnCloud]] &#039;&#039;(Your personal Cloud for storing and sharing your data on-line)&#039;&#039;)&lt;br /&gt;
* [[Gnome Setup]]&lt;br /&gt;
* [[Awesome(wm) Setup]]&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
=== Telephony ===&lt;br /&gt;
* [[Setting up Zaptel/Asterisk on Alpine]]&lt;br /&gt;
** [[Setting up Streaming an Asterisk Channel]]&lt;br /&gt;
* [[Freepbx on Alpine Linux]]&lt;br /&gt;
* [[FreePBX_V3]] &#039;&#039;(FreeSWITCH, Asterisk GUI web acces tool)&#039;&#039;&lt;br /&gt;
* [[2600hz]] &#039;&#039;(FreeSWITCH, Asterisk GUI web access tool)&#039;&#039;&lt;br /&gt;
* [[Kamailio]] &#039;&#039;(SIP Server, formerly OpenSER)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Mail ===&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(Hosting mail, webservices and other services)&#039;&#039;&lt;br /&gt;
** [[Hosting Web/Email services on Alpine]]&lt;br /&gt;
* [[ISP Mail Server HowTo]] &amp;lt;!-- solution, Mail --&amp;gt;&lt;br /&gt;
** [[ISP Mail Server Upgrade 2.x]]&lt;br /&gt;
** [[ISP Mail Server 2.x HowTo]] &#039;&#039;(Beta, please test)&#039;&#039;&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Setting up postfix with virtual domains]]&lt;br /&gt;
* [[Protecting your email server with Alpine]]&lt;br /&gt;
* [[Setting up clamsmtp]]&lt;br /&gt;
* [[Setting up dovecot with imap and ssl]]&lt;br /&gt;
&lt;br /&gt;
=== HTTP ===&lt;br /&gt;
* [[Lighttpd]]&lt;br /&gt;
** [[Lighttpd Https access]]&lt;br /&gt;
** [[Setting Up Lighttpd with PHP]]&lt;br /&gt;
** [[Setting Up Lighttpd With FastCGI]]&lt;br /&gt;
* [[Cherokee]]&lt;br /&gt;
* [[Nginx]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
** [[Setting Up Apache with PHP]]&lt;br /&gt;
** [[Apache authentication: NTLM Single Signon]]&lt;br /&gt;
&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039; &amp;lt;!-- solution, Server --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
** [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[Setting up Explicit Squid Proxy]]&lt;br /&gt;
&lt;br /&gt;
* [[Drupal]] &#039;&#039;(Content Management System (CMS) written in PHP)&#039;&#039;&lt;br /&gt;
* [[WordPress]] &#039;&#039;(Web software to create website or blog)&#039;&#039;&lt;br /&gt;
* [[MediaWiki]] &#039;&#039;(Free web-based wiki software application)&#039;&#039;&lt;br /&gt;
* [[DokuWiki]]&lt;br /&gt;
* [[Darkhttpd]]&lt;br /&gt;
&lt;br /&gt;
=== Other Servers ===&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a nfs-server]]&lt;br /&gt;
* [[Phpizabi]] &#039;&#039;(Social Networking Platform)&#039;&#039;&lt;br /&gt;
* [[Statusnet]] &#039;&#039;(Microblogging Platform)&#039;&#039;&lt;br /&gt;
* [[Pastebin]] &#039;&#039;(Pastebin software application)&#039;&#039;&lt;br /&gt;
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]&lt;br /&gt;
&lt;br /&gt;
* [[Redmine]] &#039;&#039;(Project management system)&#039;&#039;&lt;br /&gt;
* [[Request-Tracker]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[OsTicket]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Setting up trac wiki|Trac]] &#039;&#039;(Enhanced wiki and issue tracking system for software development projects)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Cgit]]&lt;br /&gt;
** [[Setting up a git repository server with gitolite and cgit]] &amp;lt;!-- doesn&#039;t exist yet --&amp;gt;&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Glpi]] &#039;&#039;(Manage inventory of technical resources)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[How to setup a Alpine Linux mirror]]&lt;br /&gt;
* [[Cups]]&lt;br /&gt;
* [[NgIRCd]] &#039;&#039;(Server for Internet Relay Chat/IRC)&#039;&#039;&lt;br /&gt;
* [[OpenVCP]] &#039;&#039;(VServer Control Panel)&#039;&#039;&lt;br /&gt;
* [[Mahara]] &#039;&#039;(E-portfolio and social networking system)&#039;&#039;&lt;br /&gt;
* [[Chrony and GPSD | Using chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]&lt;br /&gt;
* [[Sending SMS using gnokii]]&lt;br /&gt;
&lt;br /&gt;
=== Monitoring ===&lt;br /&gt;
* [[Traffic monitoring]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up traffic monitoring using rrdtool (and snmp)]] &amp;lt;!-- Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up monitoring using rrdtool (and rrdcollect)]]&lt;br /&gt;
* [[Setting up Cacti|Cacti]] &#039;&#039;(Front-end for rrdtool networking monitor)&#039;&#039;&lt;br /&gt;
* [[Setting up Zabbix|Zabbix]] &#039;&#039;(Monitor and track the status of network services and hardware)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft, solution, Networking and Monitoring and Server --&amp;gt;&lt;br /&gt;
** [[Setting up NRPE daemon]] &#039;&#039;(Performs remote Nagios checks)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up Smokeping|Smokeping]] &#039;&#039;(Network latency monitoring)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
** [[Setting up MRTG and Smokeping to Monitor Bandwidth Usage and Network Latency]]&lt;br /&gt;
* [[Setting Up Fprobe And Ntop|Ntop]] &#039;&#039;(NetFlow collection and analysis using a remote fprobe instance)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Cvechecker]] &#039;&#039;(Compare installed packages for Common Vulnerabilities Exposure)&#039;&#039; &amp;lt;!-- Monitoring and Security --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[IP Accounting]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Piwik]] &#039;&#039;(A real time web analytics software program)&#039;&#039;&lt;br /&gt;
* [[Awstats]] &#039;&#039;(Free log file analyzer)&#039;&#039;&lt;br /&gt;
* [[Intrusion Detection using Snort]]&lt;br /&gt;
** [[Intrusion Detection using Snort, Sguil, Barnyard and more]]&lt;br /&gt;
* [[Dglog]] &#039;&#039;(Log analyzer for the web content filter DansGuardian)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Webmin]] &#039;&#039;(A web-based interface for Linux system)&#039;&#039;&lt;br /&gt;
* [[PhpPgAdmin]] &#039;&#039;(Web-based administration tool for PostgreSQL)&#039;&#039;&lt;br /&gt;
* [[PhpMyAdmin]] &#039;&#039;(Web-based administration tool for MYSQL)&#039;&#039;&lt;br /&gt;
* [[PhpSysInfo]] &#039;&#039;(A simple application that displays information about the host it&#039;s running on)&#039;&#039;&lt;br /&gt;
* [[Linfo]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up lm_sensors]]&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Shell]]&lt;br /&gt;
* [[:Category:Programming]]&lt;br /&gt;
* [[Running glibc programs]]&lt;br /&gt;
* [[:Category:Drivers]]&lt;br /&gt;
* [[:Category:Multimedia]]&lt;br /&gt;
&lt;br /&gt;
== Complete Solutions ==&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[High performance SCST iSCSI Target on Linux software Raid]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]]&lt;br /&gt;
* [[Experiences with OpenVPN-client on ALIX.2D3]]&lt;br /&gt;
&lt;br /&gt;
* [[ISP Mail Server HowTo]] &#039;&#039;(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-serivce ISP mail server)&#039;&#039;&lt;br /&gt;
** [[ISP Mail Server Upgrade 2.x]]&lt;br /&gt;
** [[ISP Mail Server 2.x HowTo]] &#039;&#039;(Beta, please test)&#039;&#039;&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
* [[Streaming Security Camera Video with VLC]]&lt;br /&gt;
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small_Office_Services]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
This does not attempt to be complete. Is it useful to have these listed here? I find them more accessible if grouped with their topics; also, an up-to-date list of all Draft or Obsolete pages can be found at [[Project:Wiki maintenance]].&lt;br /&gt;
&lt;br /&gt;
== Drafts ==&lt;br /&gt;
Currently unfinished/works-in-progress.&lt;br /&gt;
* [[Using Racoon for Remote Sites]]&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] &#039;&#039;(Covers Squid proxy and URL Filtering system)&#039;&#039;&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using the Squark Squid authentication helper)&#039;&#039; [!-- no longer a draft --]&lt;br /&gt;
* [[Setting up Streaming an Asterisk Channel]]&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039;&lt;br /&gt;
* [[Intrusion Detection using Snort]] &#039;&#039;(Installing and configuring Snort and related applications on Alpine 2.0.x)&#039;&#039;&lt;br /&gt;
* [[IP Accounting]] &#039;&#039;(Installing and configuring pmacct for IP Accounting, Netflow/sFlow collector)&#039;&#039;&lt;br /&gt;
* [[Disk Replication with DRBD]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_LVM_on_LUKS&amp;diff=9948</id>
		<title>Setting up LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_LVM_on_LUKS&amp;diff=9948"/>
		<updated>2014-05-01T20:50:58Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Itoffshore moved page New page to Setting up LVM on LUKS: renaming from &amp;quot;New Page&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[LVM on LUKS]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_LVM_on_LUKS&amp;diff=9947</id>
		<title>Setting up LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_LVM_on_LUKS&amp;diff=9947"/>
		<updated>2014-05-01T20:43:10Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Itoffshore moved page New page to LVM on LUKS: renaming from &amp;quot;New Page&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[LVM on LUKS]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9946</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9946"/>
		<updated>2014-05-01T20:43:10Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Itoffshore moved page New page to LVM on LUKS: renaming from &amp;quot;New Page&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid,mode=1777      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9945</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9945"/>
		<updated>2014-05-01T20:26:01Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
  apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
  dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
  fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with: &lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid,mode=1777      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9944</id>
		<title>LVM on LUKS</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LVM_on_LUKS&amp;diff=9944"/>
		<updated>2014-05-01T19:53:23Z</updated>

		<summary type="html">&lt;p&gt;Itoffshore: Created page with &amp;quot; == Configuring LVM on top of LUKS ==   The most common errors for failure to boot a LUKS installation can be fixed with &amp;#039;&amp;#039;&amp;#039;(1)&amp;#039;&amp;#039;&amp;#039; or all of the following:   &amp;#039;&amp;#039;&amp;#039;(1)&amp;#039;&amp;#039;&amp;#039; Mount p...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Configuring LVM on top of LUKS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most common errors for failure to boot a LUKS installation can be fixed with &#039;&#039;&#039;(1)&#039;&#039;&#039; or all of the following:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1)&#039;&#039;&#039; Mount partitions &amp;amp; rebuild initramfs to include LUKS support (ignore extlinux errors) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk fix --root $MNT linux-grsec&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;(2)&#039;&#039;&#039; Write MBR (also needed for LVM manual / custom installations)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;dd bs=440 count=1 conv=notrunc if=$MNT/usr/share/syslinux/mbr.bin of=/dev/vda&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3)&#039;&#039;&#039; Change partition system id (&#039;t&#039;) to &amp;quot;8e&amp;quot; with fdisk for partition type LVM  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;fdisk /dev/vda&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Additional Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before choosing a LUKS encryption scheme find the most efficient scheme for your processor / system with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(You may or may not be able to take advantage of AES hardware acceleration)&lt;br /&gt;
&lt;br /&gt;
[http://linux.die.net/man/8/haveged Haveged] can also be run as a daemon to add entropy to your system for better randomness (certificate generation for OpenSSL / OpenVPN etc....)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ALPINE KVM SETUP&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
setup-interfaces&lt;br /&gt;
&lt;br /&gt;
ifup eth0&lt;br /&gt;
&lt;br /&gt;
setup-apkrepos&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&lt;br /&gt;
apk add nano haveged lvm2 cryptsetup e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Partition disks (100meg boot / 2nd partition for LVM)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m &lt;br /&gt;
&lt;br /&gt;
n&lt;br /&gt;
&lt;br /&gt;
etc........  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Wipe partition with random data&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
haveged -n 0 | dd of=/dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Don&#039;t forget to run &#039;cryptsetup benchmark&#039; first to check the best scheme for your system&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup -v -c serpent-xts-plain64 -s 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/vda2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup open --type luks /dev/vda2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# The name used for the mapper must also be used for the &#039;cryptdm=&amp;quot; Default Kernel Option setting&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# shown further down in $MNT/etc/update-extlinux.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 1G vg0 -n root&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 256M vg0 -n swap&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 500M vg0 -n home&lt;br /&gt;
&lt;br /&gt;
lvcreate -L 50M vg0 -n tmp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# NOTE small &amp;quot;l&amp;quot; for 100% FREE allocation&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lvcreate -l 100%FREE vg0 -n var&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Create filesystems&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mkfs.ext2 /dev/vda1&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-root&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-home&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-tmp&lt;br /&gt;
&lt;br /&gt;
mkfs.ext4 /dev/mapper/vg0-var&lt;br /&gt;
&lt;br /&gt;
mkswap /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Open LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Mount Partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/root /mnt&lt;br /&gt;
&lt;br /&gt;
mkdir /mnt/boot /mnt/home /mnt/tmp /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/home /mnt/home&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/tmp /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
mount -t ext4 /dev/vg0/var /mnt/var&lt;br /&gt;
&lt;br /&gt;
mount -t ext2 /dev/vda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
swapon /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Install Alpine&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
setup-disk -m sys /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup crypttab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;lvm /dev/vda2 none luks&amp;quot; &amp;gt; /mnt/etc/crypttab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Setup fstab&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# You could also setup devices with uuid&#039;s by running &#039;blkid&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-root  /      ext4      defaults,errors=remount-ro   0   1&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-var   /var   ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-home  /home  ext4      defaults      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-tmp  /tmp    ext4      defaults,noexec,noatime,nodev,nosuid,mode=1777      0   2&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;/dev/mapper/vg0-swap  none   swap      sw            0   0&amp;quot; &amp;gt;&amp;gt; /mnt/etc/fstab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Make vda1 bootable&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot; includes cryptsetup (this field is space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot; contains cryptroot=/dev/vda2 and cryptdm=lvmcrypt&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# (this field is also space-separated and quoted)&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Also check the root= setting = /dev/mapper/vg0-root&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Rebuild initramfs (ignore extlinux errors)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
apk fix --root $MNT linux-grsec&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Write MBR (also needed for LVM manual / custom installations)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/vda&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Change partition type to &amp;quot;8e&amp;quot; with fdisk for the LVM partition&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&lt;br /&gt;
fdisk /dev/vda&lt;br /&gt;
&lt;br /&gt;
m&lt;br /&gt;
&lt;br /&gt;
t&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
8e&lt;br /&gt;
&lt;br /&gt;
w&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# See instructions below for unmounting LVM volumes &amp;amp; closing the LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following details for mounting your installation into a chroot may be helpful if you ever need to repair an installation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# CHROOT MOUNTS ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a y &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Follow instructions above for mounting LVM partitions&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd /mnt&lt;br /&gt;
&lt;br /&gt;
mount --bind /dev dev&lt;br /&gt;
&lt;br /&gt;
mount -t devpts devpts dev/pts&lt;br /&gt;
&lt;br /&gt;
mount -t tmpfs tmpfs dev/shm&lt;br /&gt;
&lt;br /&gt;
mount -t proc proc proc&lt;br /&gt;
&lt;br /&gt;
mount -t sysfs sysfs sys&lt;br /&gt;
&lt;br /&gt;
chroot /mnt /bin/ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# UNMOUNTING ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
umount dev/pts&lt;br /&gt;
&lt;br /&gt;
umount dev/shm&lt;br /&gt;
&lt;br /&gt;
umount dev&lt;br /&gt;
&lt;br /&gt;
umount /mnt/boot&lt;br /&gt;
&lt;br /&gt;
umount /mnt/var&lt;br /&gt;
&lt;br /&gt;
umount /mnt/home&lt;br /&gt;
&lt;br /&gt;
umount /mnt/tmp&lt;br /&gt;
&lt;br /&gt;
swapoff /dev/mapper/vg0-swap&lt;br /&gt;
&lt;br /&gt;
umount /mnt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Deactivate LVM volumes&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
vgchange -a n  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;# Close LUKS partition&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cryptsetup luksClose lvmcrypt    &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Itoffshore|Stuart Cardall]] ([[User talk:Itoffshore|talk]]) 19:53, 1 May 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Itoffshore</name></author>
	</entry>
</feed>