Skip to content

Commit

Permalink
Update the work of scripts to interact with the systemd, improve the …
Browse files Browse the repository at this point in the history
…boot process, fix bugs.
  • Loading branch information
master committed Sep 5, 2018
1 parent 423790b commit c29c2db
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 286 deletions.
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PROJECT ZRAM-RAID
# PROJECT ZRAMRAID

Description<br>
This project is a derivative of all the experiments using virtualization XEN \ KVM, which we started in 2012. Then we did not like the speed of the disk subsystem in HVM mode for WINDOWS 2003-2012 servers.<br>
Expand All @@ -9,29 +9,29 @@ The code is distributed under the GNU Public License.<br>
<br>
BASH language code consists of 3 scripts:<br>
1. install - installer script installer supports OS Debian<br>
2. zraid-config - script for configuration zraid media management<br>
3. zraid-maker - starting and stopping control script zraid media<br>
2. zramraid-config - script for configuration zraid media management<br>
3. zramraid-maker - starting and stopping control script zraid media<br>

# How to use:
zraid-install --install<br>
zramraid-install --install<br>
and..<br>
<hr>
1. Create an image of the required size, consider the size of allocated RAM to mirror your image!<br>
example:<br>
cat /proc/meminfo |grep MemAvailable<br>
MemAvailable: 6638832 kB<br>
or:<br>
zraid-config --list<br>
zramraid-config --list<br>
2. Create image:<br>
fallocate -l 3G /home/kvm/disk0.img<br>
3. Create zram-raid:<br>
zraid-config --add md0:/home/kvm/disk0.img<br>
3. Create zramraid:<br>
zramraid-config --add md0:/home/kvm/disk0.img<br>
4. Check the configuration:<br>
zraid-config --list<br>
5. Start or restart zram-raid:<br>
/etc/init.d/zraid-manager restart<br>
zramraid-config --list<br>
5. Start or restart zramraid:<br>
/etc/init.d/zramraid-manager restart<br>
or:<br>
systemctl restart zraid-manager<br>
systemctl restart zramraid-manager<br>
6. Result:<br>
cat /proc/mdstat<br>
Personalities : [raid1]<br>
Expand All @@ -41,25 +41,27 @@ or:<br>
unused devices: <none><br>
To automatically start the system, you must correct the configuration file:<br>

editor /etc/defaults/zraid<br>
editor /etc/defaults/zramraid<br>
...<br>
mode="auto";<br>
<br>
Now, when you start, ZRAM-RAID will start automatically.<br>
Now, when you start, zramraid will start automatically.<br>
<hr>
Additional control parameters can be found from the parameter --help<br>
example:<br>
zraid-config --help<br>
zraid-maker --help<br>
zraid-install --help<br>
zramraid-config --help<br>
zramraid-maker --help<br>
zramraid-install --help<br>

# Recommendations:
If you plan to use zram-raid together with KVM then we recommend making a change for the systemd:<br>
If you plan to use zramraid together with KVM then we recommend making a change for the systemd:<br>
editor /lib/systemd/system/libvirt-guests.service<br>
...<br>
After=network.target libvirtd.service time-sync.target zraid-start.service<br>
Requires=zramraid.service<br>
...<br>

* see example files from /lib/systemd/system
<hr>
version - 10.09.18
version - 27.06.18
<hr>
License: GPLv3
5 changes: 0 additions & 5 deletions zraid.deb/etc/default/zraid

This file was deleted.

69 changes: 0 additions & 69 deletions zraid.deb/etc/init.d/zraid-manager

This file was deleted.

18 changes: 0 additions & 18 deletions zraid.deb/lib/systemd/system/libvirt-guests.service

This file was deleted.

16 changes: 0 additions & 16 deletions zraid.deb/lib/systemd/system/zraid-monitor.service

This file was deleted.

14 changes: 0 additions & 14 deletions zraid.deb/lib/systemd/system/zraid-start.service

This file was deleted.

5 changes: 5 additions & 0 deletions zramraid.deb/etc/default/zramraid
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## service start
# mode - startup parameter zramraid system in manual or automatic mode, examples: mode="auto" or mode="manual"
# if "manual" zramraid does not start automatically at startup, dafult - "manual"
#
mode="manual";
77 changes: 77 additions & 0 deletions zramraid.deb/etc/init.d/zramraid-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: zramraid-manager
# Required-Start: udev $local_fs $remote_fs $time
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start the zraid
# Description: starts zraid using start-stop-daemon
### END INIT INFO
## version =25.06.18
PARMS=$1
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/zramraid";
DESC="Zram Raid"
NAME="zramraid"
SCRIPTNAME="zramraid-maker";
ZPATH="/etc/zramraid"
MODE="/etc/default/zramraid";
##

if [[ "$PARMS" = '' ]];
then
echo "/etc/init.d/zramraid-manager {start|stop|restart|status}"
exit 0
fi

function zRun() {
if [ ! $(echo $USER|grep root|wc -m) = 0 ]
then
if [ $(cat $MODE |grep mode|grep -v '#'|sed 's/\mode=//g'|sed 's/\"//g;s/\;//g'|grep auto|wc -m) == 0 ]
then
echo "$(date) $NAME: no autostart from boot! mode=manual - /etc/defaults/zramraid">>/var/log/zramraid.log
exit 0;
else
$ZPATH/$SCRIPTNAME --on
fi
exit 0;
fi
echo "$NAME:Sorry.. The only root privileges!"
exit 0;
}

### begin
case "$PARMS" in
"start" | "start" )
zRun;
exit 0
;;

"stop" | "stop" )
$ZPATH/$SCRIPTNAME --off
exit 0
;;

"restart" | "restart" )
$ZPATH/$SCRIPTNAME --off
sleep 3
zRun;
exit 0
;;

"status" | "status" )
$ZPATH/$SCRIPTNAME --status
exit 0
;;

"boot" | "boot" )
zBoot;
exit 0
;;

* )
echo
echo "no input parameters."
exit 1
;;
esac
Loading

0 comments on commit c29c2db

Please sign in to comment.