LinHES Forums
http://forum.linhes.org/

ACPI Wake and fsck
http://forum.linhes.org/viewtopic.php?f=6&t=18224
Page 3 of 3

Author:  nicom [ Mon May 05, 2008 6:13 pm ]
Post subject: 

I think I see the problem. My current Command to Shutdown as defined in Mythwelcome --setup is "/sbin/shutdown -h now". What you are saying is I should replace this with a script which tests the mount count and then performs /sbin/shutdown with -r or -h depending on the outcome. Is that correct?

Author:  alien [ Tue May 06, 2008 2:36 am ]
Post subject: 

Correct. Note that you also need to set MythShutdownWakeupTime before a reboot to ensure the box shutdown down again (thanks to heilig for this finding).

BTW: I have managed to get this all working using daily wakeups. It worked flawlessly this morning. I have updated my script on page one of this thread. Similar code can be used at shutdown to cause a reboot/fsck/shutdown.

Allen

Author:  nicom [ Sun May 11, 2008 12:51 am ]
Post subject: 

I have finally had a chance to do some more experimentation with trying to get a fsck bootup triggered on shutdown. First I tried changing my setwakeup.sh so that rather than reboot I set /proc/acpi/alarm to wakeup 2 minutes later with
Code:
echo "+0000-00-00 00:02:00">/proc/acpi/alarm
and then go through the normal shutdown sequence. This should then eliminate any problem about when the mount count test is done. This works but with the same result as my previous attempt, that is it reboots to the Mythtv menu, not Mythwelcome.

My next experiment was to uncheck the option to start Mythtv if not woken for recording. Predictably this caused the box to wake up in Mythwelcome but with no countdown to automatic shutdown.

From this I have concluded the problem is that after either the reboot or my delayed wakeup, Mythwelcome determines that it was not woken for recording and immediately starts Mythtv (if the option is checked). Therefore to get it to start Mythwelcome and then shutdown on idle, it has to think it is recording. Is it possible to trick it that way?

If not then I guess it means doing by a cron job as suggested by alien or live with the box remaining on after the fsck boot.

Author:  mythman13 [ Tue Aug 19, 2008 10:45 am ]
Post subject:  thanks and idea for acpi

Thanks for this, especially to marc.aronson and tjc for the scripting advice. I've used this for my wake on lan automatic wakeup here: http://knoppmyth.net/phpBB2/viewtopic.php?t=18673

I reckon the script I've put together for this application can be easily adapted for your ACPI needs by simply removing the scp line and changing the location where the variable tw (containing the epoch wakeup time is written to). Although there would need to be some conversion from epoch time to 'human' time for the BIOS I guess! You would then call this script with the switch --settime %time_t (I think) in the mythtv-setup.

Hope this helps!
-Mythman

Author:  nmcaullay [ Mon Feb 15, 2010 7:09 pm ]
Post subject: 

Its been a while, wondering if anyone had made any inroads to this?

I was thinking that on the setwakeup.sh, i could do the following if there was a disk check on next boot
1) create a dummy file (/var/log/mythtv/diskcheck)
2) issue a reboot instead of a shutdown
3) alter the startup script to check for the /var/log/mythtv/diskcheck
a) if present call call setwakeup.sh, and shutdown
b) if not present, start mythwelcome

would this type of approach work?

as mythwelcome nortmally calls the setwakeup.sh with a time parameter, i'd have to figure out what the next show scheduled is.... but I can probably get that from a call to mythshutdown?

Thoughts?

Nathan

Author:  nicom [ Mon Feb 15, 2010 7:51 pm ]
Post subject: 

I did not get any further. In fact since then I have changed the file system of the /myth partition to xfs so it does not require fsck. It does however require regular defragmentation which is another annoyance.

Author:  alien [ Tue Feb 16, 2010 2:36 am ]
Post subject: 

This is my working script to do a fsck once a month. I run it from a cron job in the mythwelcome daily wakeup period. Note that sda1 is my backup disk which is not mounted so I can fsck it directly. sdb1/3 will be checked during the reboot. I also set the maximum mounts to 200 on all drives so that they don't fsck during the month.

I have also configured my system so /usr/bin/mail works. If you want notification, you will have to change the mail lines accordingly.

Code:
#!/usr/bin/perl

$day=`date '+%d'`;
chomp($day);
if($day eq "10") {
        $error=system("/sbin/fsck -p /dev/sda1 > /tmp/fsck.out 2>&1");
        if($error) {
                system("cat /tmp/fsck.out | /usr/bin/mail -s sda1_check mythtv");
        }
        system("date > /tmp/tune2fs.out");
        system("/sbin/tune2fs -l /dev/sdb1 | grep Mount >> /tmp/tune2fs.out");
        system("/sbin/tune2fs -l /dev/sdb3 | grep Mount >> /tmp/tune2fs.out");
        system("/sbin/tune2fs -l /dev/sda1 | grep Mount >> /tmp/tune2fs.out");
        system("cat /tmp/tune2fs.out | /usr/bin/mail -s MountCount mythtv");
        system("/sbin/tune2fs -C 250 /dev/sdb1");
        system("/sbin/tune2fs -C 250 /dev/sdb3");
        system("/sbin/tune2fs -C 0 /dev/sda1");
        $wakeup=`date '+%Y-%m-%dT%H:%M:%S' -d '+ 15 minutes'`;
        system("/usr/bin/mysql -u root mythconverg -e \"update settings set data='$wakeup' where value='MythShutdownWakeupTime'\"");
        system("/sbin/reboot");
        exit;
}

Page 3 of 3 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/