You are not logged in.
Yesterday I installed Arch Linux once again (Arch Linux 2009.02 Core Kernel 2.6.28.x X86-64). Installation und first bootups performed well.
A requirement for Arch Linux (and every other distribution) is that /var must be mounted as tmpfs into RAM because I use a SSD.
In order to achieve this I did the following. Because I am rather new to Arch Linux I made some mistakes maybe.
First of all I utilize a script called varsave:
#! /bin/bash
case "$1" in
start)
echo " * Restoring contents of /var"
cp -Rp /root/.varsave/* /var
chmod 0755 /var
;;
stop)
echo " * Saving contents of /var"
rm -rf /root/.varsave/*
# rm -f /var/run/klogd/kmsg
# rm -f /var/run/dbus/pid
cp -Rp /var/* /root/.varsave
;;
*)
echo "Usage: $0 start|stop"
exit 0
esac
In order to benefit from it I did the following:
- added two lines of additional code bellow #!/bin/bash (the original script was created for ubuntu):
. /etc/rc.conf
. /etc/rc.d/functions
- copied the script to /etc/rc.d (varsave -rwxr-xr-x)
- created directory /root/.varsave (drwx------)
- edited /etc/fstab (tmpfs /var tmpfs defaults 0 0)
Under Ubuntu I was able to use symlinks and therefore it was possible to predefine the exact time of execution during bootup as well as during shutdown.
Due to the missing symlinks in Arch Linux I tried the following:
- added varsave to /etc/rc.conf into the daemons section at first position (in front of syslog_ng)
- executed /etc/rc.d/varsave stop for backup purposes
- deleted contents of /var
- because I found out that the skript was executed at startup only I added "/etc/rc.d/varsave stop to /etc/rc.local.shutdown.
This procedure resulted in a (just one) successful bootup. I realized that the script was working as it should be.
From that time on I noticed an error message every two boots (Checking Filesystems [FAIL]) and it appears that the entire shutdown-scripts will not executed any longer (including unmount of filesystems what is the presumed trigger for the error). I do not see any shutdown-scripts anymore. The PC seems to just shutdown/ reboot abrupt (in a second) after issuing poweroff/ reboot.
I did not carry out any additional changes to the system. Help is much appreciated. It does not matter whether or not I have to perform a reinstallation of Arch Linux.
Essentially the varsave tweak must work.
Last edited by v1kin9 (2009-07-03 14:35:07)
Offline
1) I think you're better of by editing rc.sysinit and rc.shutdown and put the varsave hook at the right place (then you just need to be careful when you update the initscripts package, since then your changes get overwritten - so create a patch and apply it on every initscript update; or protect the files in pacman.conf)
2) you could improve the varsave script by using rsync (so that you don't copy over all the stuff again and again, just the ones that have changed)
-> btw, that's what I did on my eee (I don't have it anymore, but I could probably dig up the patches if you're interested).
Offline
Thanks for your reply!
1) I got my script updated from a guy at the german arch linux forum. I reinstalled the whole system and tested it with the updated script.
In order to use it during bootup and shutdown I only added it to /etc/rc.conf. It was working like a charm but again just for the 1st shutdown and reboot. Afterwards I got the same error with the filesystems as before.
I think that some file(s) in /var remain(s) in /root/.varsave that should be deleted during shutdown thus preventing the filesystems from mounting correctly. On one hand it doesn't sound very logical to me but on the other hand it has to have something to do with the contents of /var.
2) i already had the idea with rsync but i didn't carry it out because rsync isn't always available especially on fresh installed systems. i understand that you only swap cp with rsync. is that correct?
Offline
So here are the patches that I were using and were working fine:
rc.sysinit.patch:
--- rc.sysinit.old 2008-11-04 08:17:58.000000000 +0100
+++ rc.sysinit 2008-11-04 08:20:48.000000000 +0100
@@ -297,6 +297,11 @@ fi
/bin/mount -a -t $NETFS
stat_done
+# assuming that we mounted /var/ as tmpfs in the previous step
+stat_busy "Rsyncing /var-sync/ with /var/"
+/usr/bin/rsync -az /var-sync/ /var/
+stat_done
+
status "Activating Swap" /sbin/swapon -a
stat_busy "Configuring System Clock"
and rc.shutdown.patch:
--- rc.shutdown.old 2009-03-11 10:42:44.000000000 +0100
+++ rc.shutdown 2009-03-11 10:42:18.000000000 +0100
@@ -39,6 +39,11 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL"
fi
fi
+# want to remember the logs after the deamons are stopped
+stat_busy "Rsyncing /var/ with /var-sync/"
+/usr/bin/rsync -az --delete /var/ /var-sync/
+stat_done
+
# Terminate all processes
stat_busy "Sending SIGTERM To Processes"
/sbin/killall5 -15 &> /dev/null
Offline
Thank you! I will try your solution asap.
Offline
Finally I tried Arch Linux again and found a working solution for me. It's very similar to bender's and my first approach but this time it works very smooth.
I think bender's variant is working too but I did a little different. Chiefly I use cp instead of rsync. The boot/shutdown time is a little longer utilizing cp, but it's always available.
Solution:
- add this below mount fs/swap to /etc/rc.sysinit:
stat_busy "Restoring contents of /var"
cp -Rp /root/.varsave/* /var
chmod 0755 /var
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
- add this above umount swap/fs to /etc/rc.shutdown:
stat_busy "Saving contents of /var"
rm -rf /root/.varsave/*
rm -rf /var/lock/*
rm -rf /var/run/*
cp -Rp /var/* /root/.varsave
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
- create directory /root/.varsave and set permission to root:root 0700;
- in /etc/fstab set;
tmpfs /var tmpfs noatime 0 0
- delete contents of /var/run/* and /var/lock/* (this time only)
- copy /var/* to /root/.varsave (this time only)
- delete contents of /var/* (this time only)
- mount /var into RAM (this time only)
sudo mount -vt tmpfs tmpfs /var
- copy /root/.varsave/* to /var (this time only)
- set permissions of /var to root:root 0755 (this time only)
- continue working or reboot
Last edited by v1kin9 (2009-07-03 14:25:41)
Offline
would there be anything against using rsync to do the copying? like in rc.sysinit
# Restore copy of var
stat_busy "Restoring content of /var"
#cp -Rp /root/.varsave/* /var
/usr/bin/rsync --archive /root/.varsave/* /var/
chmod 0755 /var
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
and in rc.shutdown
# save a copy of /var to storage
stat_busy "Saving content of /var"
#rm -rf /root/.varsave/*
rm -rf /var/lock/*
rm -rf /var/run/*
#cp -Rp /var/* /root/.varsave
/usr/bin/rsync --archive --delete /var/* /root/.varsave/
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
archlinux on a Gigabyte C1037UN-EU, 16GiB
a Promise PDC40718 based ZFS set
root on a Samsung SSD PB22-J
running LogitechMediaServer(-git), Samba, MiniDLNA, TOR
Offline