site  contact  subhomenews

Do not delete /tmp/* at shutdown

April 09, 2012 — BarryK
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

Comments

/tmp


I use /sbin/init to mv /tmp
Username: K Godt
"I have been experimenting with this and came up with something like this in /sbin/init : [code]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[/code] 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

bootkernel.log
Username: stephen p
"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 [code] 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 [/code]


Tags: woof