<?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=Belousa</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=Belousa"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Belousa"/>
	<updated>2026-04-28T13:22:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_/var_partition_on_software_IDE_raid1&amp;diff=2934</id>
		<title>Setting up a /var partition on software IDE raid1</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_/var_partition_on_software_IDE_raid1&amp;diff=2934"/>
		<updated>2009-07-31T13:51:24Z</updated>

		<summary type="html">&lt;p&gt;Belousa: /* Create filesystem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document wil show how to create harddisk mirroring using cheap IDE disks.&lt;br /&gt;
&lt;br /&gt;
This document was written for alpine-1.3.8&lt;br /&gt;
&lt;br /&gt;
I will setup swap on a raid1 for maximum reliability. If you prefer maximum speed, you don&#039;t need configure any raid devces for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically.&lt;br /&gt;
&lt;br /&gt;
The downside is that at the moment one disk fails, the system will go down. Thats why I choose to put the swap on raid1.&lt;br /&gt;
&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;
It is generally a good idea to use LVM so you are able to easily extend your data storage in future. LVM is not discussed here.&lt;br /&gt;
&lt;br /&gt;
== Create filesystem ==&lt;br /&gt;
Now we can creat swapspace and the filesystem for /var.&lt;br /&gt;
 mkswap /dev/md0&lt;br /&gt;
 swapon /dev/md0&lt;br /&gt;
&lt;br /&gt;
You can verify that swap was really activated with &#039;&#039;free&#039;&#039;. It should display how much swapspace you have.&lt;br /&gt;
 free&lt;br /&gt;
&lt;br /&gt;
We need to install the software to create the filesystem (&amp;quot;format&amp;quot; the partition). I will use &#039;&#039;&#039;ext3&#039;&#039;&#039; here so I install &#039;&#039;e2fsprogs&#039;&#039;. If you prefer reiserfs or xfs you will have to install &#039;&#039;xfsprogs&#039;&#039; or &#039;&#039;reiserfsprogs&#039;&#039; instead.&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 manuall 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 everyting 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 the /home be permantent 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 director /home. 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 remeber 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 sould 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;/div&gt;</summary>
		<author><name>Belousa</name></author>
	</entry>
</feed>