Anyone has success with installing raspbx on a readonly file system?
To reduce SD card tear/minimize writes after configuring the raspbx, i d like to be able to put it on a readonly filesystem so that the damage from blackouts/power outages(if any) is minimal. I can always mount filesystem in RW and update packages etc, if needed.
so far,
1) I have been able to move the /var/log to tmpfs using fs2ram package
2) remove journaling on rootfs (ext4)
3) Make /boot partition as RO in /etc/fstab
4) when i tried converting / (root) to RO, mysql, apache and asterisk/freepbx fail to start.
Anyway I can get these packages to work in RO mode?
I do not intend to change any configurations so far as freepbx/asterisk go - Plan to install raspbx at a remote location as a gsm gateway (with 1 gms dongle connected to it) and 1 SIP extension.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Copying the same content from there, just in case that content is lost:
To get this done, following are my tweaks:
1) Install 0.3.12 version of fs2ram (manually via its deb).
2) create a dir called 'astb-sqlite' folder under /var/lib/asterisk and move astdb* files (2 of them) to this new folder from /var/lib/asterisk; do a chown on this new folder and its contents for asterisk;open /etc/asterisk/astrisk.conf and point astbdir parameter to this new folder and remove the (!) from the first line of this file.
3) open /etc/fs2ram/fs2ram.conf file and mount as follows:
4) change /boot to readonly in /etc/fstab (leave / as-is in that file)
5) open /etc/init.d/fs2ram and added two lines for mount as follows:
..
...
start)
log_action_begin_msg "fs2ram: mount and execute the mount script for each handled mountpoints"
fs2ram mount -a -q
log_action_end_msg $? mount / -o remount,ro
;;
stop)
log_action_begin_msg "fs2ram: execute the unmount script and unmount for each handled mountpoints" mount / -o remount,rw
....
...
6) disable swap completely
mount output:
/dev/root on / type ext4 (ro,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=240512k,nr_inodes=60128,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=49756k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=99500k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=ascii,shortname=mixed,errors=remount-ro)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=99500k)
tmpfs on /var/cache type tmpfs (rw,relatime)
tmpfs on /var/log type tmpfs (rw,relatime)
tmpfs on /var/tmp type tmpfs (rw,relatime)
tmpfs on /var/lib/mysql type tmpfs (rw,relatime)
tmpfs on /var/lib/asterisk/astdb-sqlite type tmpfs (rw,relatime)
tmpfs on /var/spool type tmpfs (rw,relatime)
tmpfs on /var/lib/php5 type tmpfs (rw,relatime)
At this point, I guess my raspbx is near bullet proof
ps: Had to do other tweaks to reduce the memory footprint. (disabling apache/samba dameons at startup, remove ttys 2-9 etc)
since my goal is to have this gsm gateway at a remote location/country where power outages/blackouts are common and that I will have only 1 SIP extension (client) and 1 gsm dongle, am very satisfied with this config. I really do not need to worry about the logs/cdrs/voicemail etc..
and by the way i created a 2nd 'custom' extension so that all my incoming calls are routed to callcentric sip broker and i can receive them here in the USA via my obi.. the good thing about CC is that i can do further call treatment logic at CC itself (incl voicemails).
I am using Pi 2 model B with the 22-02-2015 image. I had setup just two extensions and it was all fully functional. To overcome unreliable power issues, I tried following your tweaks to create a read-only file system.
I followed the steps #1 to #6 as provided above but was not able to register any of the handsets on reboot.
I am suspecting that I must have done something wrong but it also seems that step #2 above could be misleading for I could not identify the 'astbdir' parameter in /etc/asterisk/asterisk.conf nor could I find the (!) to remove from the first line.
Clarifications and possible update of the tweaks shall be much appreciated.
Please note that to completely disable the swap, I had set vm.swappiness=0 in /etc/sysctl.conf. All other settings were as provided in this thread.
Thank you in anticipation
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your detailed write-up, very interesting!
However, when running in read-only mode FreePBX is not functional and no configuration changes can be made. You would always have to switch to read/write then make changes then switch back.
It might also be a good idea to limit the amount of ram used by the different tmpfs. Otherwise if the filesystems fill up, too much ram could be consumed leaving the kernel with no choice than to kill processes to get more ram. In this situation the system will usually not crash or reboot but stays in a non-operational state with one or more services no longer running.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes... FreePBX changes cannot be made - I have disabled apache2 to get some more memory..
As for tmpfs, I see your point... I need to come up with a way to freeup tmpfs on a regular basis.. Any ideas/tips to 'rotate' things around in tmpfs..?
Thanks a ton, @Gernot for the work you did on raspx. Really appreciate it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anyone has success with installing raspbx on a readonly file system?
To reduce SD card tear/minimize writes after configuring the raspbx, i d like to be able to put it on a readonly filesystem so that the damage from blackouts/power outages(if any) is minimal. I can always mount filesystem in RW and update packages etc, if needed.
so far,
1) I have been able to move the /var/log to tmpfs using fs2ram package
2) remove journaling on rootfs (ext4)
3) Make /boot partition as RO in /etc/fstab
4) when i tried converting / (root) to RO, mysql, apache and asterisk/freepbx fail to start.
Anyway I can get these packages to work in RO mode?
I do not intend to change any configurations so far as freepbx/asterisk go - Plan to install raspbx at a remote location as a gsm gateway (with 1 gms dongle connected to it) and 1 SIP extension.
Thanks!
A breakthrough: I can receive/make calls on a completely ReadOnly raspbx rootfs. Here is what I had to do to do this - http://www.dslreports.com/forum/r29190917-
Copying the same content from there, just in case that content is lost:
To get this done, following are my tweaks:
1) Install 0.3.12 version of fs2ram (manually via its deb).
2) create a dir called 'astb-sqlite' folder under /var/lib/asterisk and move astdb* files (2 of them) to this new folder from /var/lib/asterisk; do a chown on this new folder and its contents for asterisk;open /etc/asterisk/astrisk.conf and point astbdir parameter to this new folder and remove the (!) from the first line of this file.
3) open /etc/fs2ram/fs2ram.conf file and mount as follows:
tmpfs /var/cache keep_folder_structure - tmpfs
tmpfs /var/log keep_file_structure - tmpfs
tmpfs /var/tmp - - tmpfs
tmpfs /var/lib/mysql keep_file_content - tmpfs
tmpfs /var/lib/asterisk/astdb-sqlite keep_file_content - tmpfs
tmpfs /var/spool keep_file_content - tmpfs
tmpfs /var/lib/php5 - - tmpfs
4) change /boot to readonly in /etc/fstab (leave / as-is in that file)
5) open /etc/init.d/fs2ram and added two lines for mount as follows:
..
...
start)
log_action_begin_msg "fs2ram: mount and execute the mount script for each handled mountpoints"
fs2ram mount -a -q
log_action_end_msg $?
mount / -o remount,ro
;;
stop)
log_action_begin_msg "fs2ram: execute the unmount script and unmount for each handled mountpoints"
mount / -o remount,rw
....
...
6) disable swap completely
mount output:
/dev/root on / type ext4 (ro,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=240512k,nr_inodes=60128,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=49756k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=99500k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=ascii,shortname=mixed,errors=remount-ro)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=99500k)
tmpfs on /var/cache type tmpfs (rw,relatime)
tmpfs on /var/log type tmpfs (rw,relatime)
tmpfs on /var/tmp type tmpfs (rw,relatime)
tmpfs on /var/lib/mysql type tmpfs (rw,relatime)
tmpfs on /var/lib/asterisk/astdb-sqlite type tmpfs (rw,relatime)
tmpfs on /var/spool type tmpfs (rw,relatime)
tmpfs on /var/lib/php5 type tmpfs (rw,relatime)
At this point, I guess my raspbx is near bullet proof
ps: Had to do other tweaks to reduce the memory footprint. (disabling apache/samba dameons at startup, remove ttys 2-9 etc)
since my goal is to have this gsm gateway at a remote location/country where power outages/blackouts are common and that I will have only 1 SIP extension (client) and 1 gsm dongle, am very satisfied with this config. I really do not need to worry about the logs/cdrs/voicemail etc..
and by the way i created a 2nd 'custom' extension so that all my incoming calls are routed to callcentric sip broker and i can receive them here in the USA via my obi.. the good thing about CC is that i can do further call treatment logic at CC itself (incl voicemails).
free -h now shows:
total used free shared buffers cached
Mem: 485M 178M 306M 0B 10M 95M
-/+ buffers/cache: 73M 412M
Swap: 0B 0B 0B
I am using Pi 2 model B with the 22-02-2015 image. I had setup just two extensions and it was all fully functional. To overcome unreliable power issues, I tried following your tweaks to create a read-only file system.
I followed the steps #1 to #6 as provided above but was not able to register any of the handsets on reboot.
I am suspecting that I must have done something wrong but it also seems that step #2 above could be misleading for I could not identify the 'astbdir' parameter in /etc/asterisk/asterisk.conf nor could I find the (!) to remove from the first line.
Clarifications and possible update of the tweaks shall be much appreciated.
Please note that to completely disable the swap, I had set vm.swappiness=0 in /etc/sysctl.conf. All other settings were as provided in this thread.
Thank you in anticipation
Thank you for your detailed write-up, very interesting!
However, when running in read-only mode FreePBX is not functional and no configuration changes can be made. You would always have to switch to read/write then make changes then switch back.
It might also be a good idea to limit the amount of ram used by the different tmpfs. Otherwise if the filesystems fill up, too much ram could be consumed leaving the kernel with no choice than to kill processes to get more ram. In this situation the system will usually not crash or reboot but stays in a non-operational state with one or more services no longer running.
Yes... FreePBX changes cannot be made - I have disabled apache2 to get some more memory..
As for tmpfs, I see your point... I need to come up with a way to freeup tmpfs on a regular basis.. Any ideas/tips to 'rotate' things around in tmpfs..?
Thanks a ton, @Gernot for the work you did on raspx. Really appreciate it.