I'm back :-)
I've been using asterisk in my asus for sime time and I really want to do something about the disk spinning up, because it is affecting asterisk performance. Sometimes it is really a problem when there is an incoming call and asterisk needs to get some data from the suspended HDD...
So I came up with this solution
I have a USB flash drive, the first partition is just a copy of part1/2 on the HDD, the second partition is my /opt directory from KFurge firmware.
I run the following script at the bottom of /shares/MYSHARE1/opt/etc/rc.local script in case /dev/scsi/*/part2 is present at boot time
So far it seems to work well, at least events from asterisk don't seem to spin up the HDD, so there are no delays.
I have a problem with vsftpd however, I can't list the contents of the "shares" directory, but I can reach shares/MYSHARE1/ without problems. I don't know where the problem might be, as I don't understand where all the permissions for vsftpd are saved. Any suggestions?
Killing and re-running vsftpd won't help.
One last thing - I have to put the USB stick in the front port, because in the rear it gave me a bunch of I/O errors etc. I don't get it why, perhaps this is caused by a printer which is in the rear too. I suspect that the rear ports are either connected by a hub, or they are slower. Or could the rear port be damaged?
Code:
#!/bin/sh
PATH=/opt/bin:/opt/sbin:${PATH}
LD_LIBRARY_PATH=/opt/lib:${LD_LIBRARY_PATH}
/opt/bin/umount -l /mnt/
mount -o ro /dev/scsi/host1/bus0/target0/lun0/part1 /mnt
mount -o move /proc /mnt/proc
pivot_root /mnt /mnt/mnt
mount -o move /mnt/dev /dev
mount -o move /mnt/tmp /tmp
mount -o move /mnt/shares /shares
mount -o move /mnt/foreign_shares /foreign_shares
mkdir /foreign_shares/opt-usb
mount -t reiserfs /dev/scsi/host1/bus0/target0/lun0/part2 /foreign_shares/opt-usb/
mount -o bind /foreign_shares/opt-usb/ /opt/
umount -l /mnt/opt
umount -l /mnt/opt
umount -l /mnt
cp /shares/MYVOLUME1/opt/var/run/sshd.pid /opt/var/run/sshd.pid
/opt/etc/init.d/S40sshd
killall asterisk && asterisk
killall smbd nmbd
/usr/local/samba/sbin/smbd
/usr/local/samba/sbin/nmbd
swapoff /dev/md/0
# just for my convenience - after I reboot I usually want to tweak some stuff, so I want to have the USB flash in rw mode for a while
sh -c "sleep 300s; mount -o remount,ro /dev/scsi/host1/bus0/target0/lun0/part2"&