Do not delete /tmp/* at shutdown

I was experimenting with 'minit' a simple alternative to the 'init' process-1 startup service manager. Note, we currently use the Busybox 'init' system.

I noticed something rather odd. I found that when /etc/rc.d/rc.shutdown executes, it somehow kills 'mingetty', which promptly restarts.

With the Busybox init system, /etc/inittab specifies the start of mingetty, which performs a login on /dev/tty1, and thus we have our console. Then X can be launched from the console.
Here is the content of /etc/inittab, as we currently use in all puppies:

::sysinit:/etc/rc.d/rc.sysinit

tty1::respawn:/sbin/mingetty --autologin root tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
::ctrlaltdel:/sbin/reboot


The "respawn" means that if mingetty gets killed for whatever reason, the 'init' daemon (that runs from start to shutdown in the background) will restart it.

I do not really understand why we need "respawn", as we only kill mingetty once, at shutdown. Anyway, my discovery, while testing minit (which does not use /etc/inittab, but does something equivalent to run mingetty), was that rc.shutdown was killing mingetty and then the 'minit' daemon immediately restarted it.

I have not yet confirmed whether this happens with Busybox init, but it would go toward explaining why I have sometimes been very confused by some of the stuff appearing on the console while shutting down.

Anyway, I isolated the offending line in rc.shutdown:

rm -rf /tmp/*

...but I still haven't determined just what inside /tmp causes mingetty to be killed.

I have commented this line out. Some PUPMODEs run a tmpfs mounted on /tmp, so the contents of /tmp get automatically removed at shutdown, so the above line makes no difference. However, some PUPMODEs, such as 2 (full hd installation) and 13 (booting off flash drive) do not mount a tmpfs on /tmp -- in the latter case, the 'init' script in the initrd.gz wipes /tmp, so again no need for that line in rc.shutdown.

However, PUPMODE=2, a full hd installation, does require /tmp to be wiped, and I have put that into /etc/rc.d/rc.sysinit -- though, I should probably think about putting a tmpfs for that as well.

Although this might seem like a small change, one never knows what odd repercussions there might be, hence I have announced it here and done a Woof commit:
http://bkhome.org/fossil/woof2.cgi/info/cb5ec7d978


Posted on 9 Apr 2012, 19:50


Comments:

Posted on 9 Apr 2012, 21:58 by Dougal
/tmp
/tmp is, by definition, things that shouldn't survive a shutdown. /var/tmp is for whatever needs to survive a reboot.


Posted on 10 Apr 2012, 22:36 by K Godt
I use /sbin/init to mv /tmp
I have been experimenting with this and came up with something like this in /sbin/init :
if [ ! -d /initrd -o "`busybox df | grep 'initrd'`" = "" ] ; then #frugal or full

busybox mount -o remount,rw /
###+++2011-11-10
if [ -d /tmp ] ; then
#rm -rf /tmp/* ; rm -rf /tmp/.[a-zA-Z0-9]* ##2011-11-25 added rm of hidden temp files
rm -rf /var/tmp/ ##2012-02-08
mkdir -p /var/tmp/ ##2012-02-06
mv /tmp/* /var/tmp/ ##2012-01-08
else
mkdir /tmp
fi
chmod 1777 /tmp
###+++2011-11-10
else
STATUS=0
status_func $STATUS
fi #frugal or full

And it worked for me so far without problems .
The wiping at boot is therefore necessary, for hard poweroffs would also leave /tmp existent .

See my complain here :
Shutdownconfig: GUI shutdown
http://murga-linux.com/puppy/viewtopic.php?p=577627&search_id=962897822#577627


Posted on 21 Apr 2012, 18:48 by stephen p
related problem ?
Um do I have a similar problem? I notice at shut-down the system reboots back into the OS without going past the bios stage hmm I want a shut-down not a reboot so have to force shut downs with a hold down the power button for 20 seconds um this obviously isn't right i am running slack puppy with a sd flash card. it goes through this cycle . you start shut-down then it closes x11 and comes up with "saving data to sdb1' then some mysterious power management API messages come up and then X11 starts again?@@!!


Posted on 21 Apr 2012, 20:18 by stephen p
bootkernel.log
sorry they were acpi messages from dual processor
stuff so thats ok and some more info i am on a LENOVO s10-3 notebook booting slacko from a SD card

um also how to stop asking for save file on boot as i deleted the save files using fileroller.... here is my boot log

 2 high edge)


usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning

sd 6:0:0:0: [sdb] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
sd 6:0:0:0: [sdb] Write Protect is off
sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 6:0:0:0: [sdb] Assuming drive cache: write through
usb-storage: device scan complete
sd 6:0:0:0: [sdb] Assuming drive cache: write through
sdb: sdb1
sd 6:0:0:0: [sdb] Assuming drive cache: write through
sd 6:0:0:0: [sdb] Attached SCSI removable disk
scsi 9:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
sr0: scsi-1 drive
cdrom: Uniform CD-ROM driver Revision: 3.20
sr 9:0:0:0: Attached scsi CD-ROM sr0
usb-storage: device scan complete
EXT3-fs: barriers not enabled
kjournald starting. Commit interval 5 seconds
EXT3-fs (sdb1): warning: maximal mount count reached, running e2fsck is recommended
EXT3-fs (sdb1): using internal journal
EXT3-fs (sdb1): recovery complete
EXT3-fs (sdb1): mounted filesystem with writeback data mode
EXT3-fs: barriers not enabled
kjournald starting. Commit interval 5 seconds
EXT3-fs (sdb1): warning: maximal mount count reached, running e2fsck is recommended
EXT3-fs (sdb1): using internal journal
EXT3-fs (sdb1): mounted filesystem with writeback data mode
SQUASHFS error: squashfs_read_data failed to read block 0x7e9bef6
SQUASHFS error: Unable to read metadata cache entry [7e9bef6]

/device:00/PNP0C0D:00/input/input3
ACPI: Lid Switch [LID]
input: Sleep Button as /devices/LNXSYSTM:00