WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: resume= handling exits tc-config  (Read 4245 times)

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
resume= handling exits tc-config
« on: January 22, 2009, 07:32:54 AM »
If I boot with resume=, TC ignores some of my other kernel args (specifically tce= ). So I was reading tc-config.

tc-config exits if resume= doesn't come up with a valid $SWAP_SIZE. I think this is why my tce= arg gets ignored. I think it should read continue, instead ... that breaks the resume= handling without exiting.

Code: [Select]
--- tc-config.orig Thu Jan 22 04:28:24 2009
+++ tc-config.fix Thu Jan 22 04:27:38 2009
@@ -389,7 +389,7 @@
   RESUME=`basename $RESUME`
   SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
   [ -z "$SWAP_SIZE" ] && /sbin/swapon /dev/"$RESUME" &&  SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
-  [ -z "$SWAP_SIZE" ] && exit 1
+  [ -z "$SWAP_SIZE" ] && continue
   MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
   if [ $SWAP_SIZE -gt $MEM_SIZE ]; then
     grep -q disk /sys/power/state &&  echo "disk" > /etc/sysconfig/tc.resume

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: resume= handling exits tc-config
« Reply #1 on: January 22, 2009, 08:21:23 AM »
Thanks for noticing where the bug is.

Continue and break though have no effect in if-conditionals; to archieve needed results, another if would prob be better:
Quote
--- tc-config   2009-01-22 18:19:30.000000000 +0200
+++ tc-config.new       2009-01-22 18:20:02.000000000 +0200
@@ -378,11 +378,12 @@
   RESUME=`basename $RESUME`
   SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
   [ -z "$SWAP_SIZE" ] && /sbin/swapon /dev/"$RESUME" &&  SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
-  [ -z "$SWAP_SIZE" ] && exit 1
+ if [ -n "$SWAP_SIZE" ]; then
   MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
   if [ $SWAP_SIZE -gt $MEM_SIZE ]; then
     grep -q disk /sys/power/state &&  echo "disk" > /etc/sysconfig/tc.resume
   fi 
+ fi
 fi
 
 if [ -n "$SECURE" ]; then
The only barriers that can stop you are the ones you create yourself.

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: resume= handling exits tc-config
« Reply #2 on: January 22, 2009, 02:02:37 PM »
Thanks for the input. I had not put resume on the F2/F3 screens as it was untested.
Now that we have several users who can test, this section can be implemented. Will be in 1.1rc2.
10+ Years Contributing to Linux Open Source Projects.

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: resume= handling exits tc-config
« Reply #3 on: January 23, 2009, 12:18:30 AM »
Curaga - oops. Thanks for that.
Roberts - I'll be interested/happy to try it out and report back.
« Last Edit: January 23, 2009, 12:28:09 AM by dentonlt »

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: resume= handling exits tc-config
« Reply #4 on: February 07, 2009, 12:38:04 AM »
After much mucking about, I finally got s2disk/resume working. Summary at http://forum.tinycorelinux.net/index.php?topic=455.0

In addition to the change by curaga (thanks again for that), I needed to add a mkswap call to the 1.1rc2 tc-config:

Code: [Select]
--- /tmp/extract/etc/init.d/tc-config Sat Feb  7 19:26:57 2009
+++ /etc/init.d/tc-config Sat Feb  7 19:03:56 2009
@@ -388,12 +395,13 @@
   rm -f /etc/sysconfig/tc.resume 2>/dev/null
   RESUME=`basename $RESUME`
   SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
-  [ -z "$SWAP_SIZE" ] && /sbin/swapon /dev/"$RESUME" &&  SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
-  [ -z "$SWAP_SIZE" ] && exit 1
-  MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
+  [ -z "$SWAP_SIZE" ] && /sbin/mkswap /dev/"$RESUME" && /sbin/swapon /dev/"$RESUME" &&  SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
+  if [ -n "$SWAP_SIZE" ]; then
+ MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
   if [ $SWAP_SIZE -gt $MEM_SIZE ]; then
     grep -q disk /sys/power/state &&  echo "disk" > /etc/sysconfig/tc.resume
   fi 
+  fi
 fi
 
 if [ -n "$SECURE" ]; then

The kernel has what it needs for resume ... but tinycore.gz needs the resume binary and some config stuff (500k+). That's a pretty hefty addition, so I can't imagine this becoming a 'stock' feature beyond the resume arg handler.

Over at the wiki, I'll thoroughly document the initrd changes I made.