Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 28 Nov 2014, 22:28
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to auto-check filesystem at startup?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
SilverPuppy


Joined: 28 May 2009
Posts: 143

PostPosted: Thu 08 Oct 2009, 13:57    Post subject:  How to auto-check filesystem at startup?
Subject description: Improper shutdowns causing problems
 

Hello,

I use full HD installation to create basic computers for elderly, etc. out of older computers. I have discovered that EXT2 is very fussy, and will really mess itself up if shutdown improperly, but even EXT3 can self-destruct if shutdown improperly enough times with no intervention.

SO.......rather than just booting to a bash shell after an improper shutdown, I need to have it behave like Windows 98 and do an fsck -f -y and then reboot itself. Upon reboot, I believe it will automatically go to the xwin "wait 30 seconds or select ignore" screen, which is fine.

Sooooooo.......I know the commands IIRC:

fsck -f -y /dev/hda1
reboot

..................but where do I put them so they get run after an improper shutdown instead of just dumping to a # prompt?
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8715

PostPosted: Thu 08 Oct 2009, 14:10    Post subject:  

at the top of /etc/rc.d/rc.sysinit before the remount r/w

you also need this otherwise you get a full check every boot...
http://www.murga-linux.com/puppy/viewtopic.php?t=45992

And check if this is included
http://www.murga-linux.com/puppy/viewtopic.php?t=36944

then relax Very Happy

mike
Back to top
View user's profile Send private message 
SilverPuppy


Joined: 28 May 2009
Posts: 143

PostPosted: Fri 09 Oct 2009, 04:44    Post subject: Thanks!  

Wow, what a wealth of information. I'm going to have a much more dependable puppy that I send to keep old people company. That's good, because the elderly don't exactly enjoy cleaning up digital crap...... Very Happy

And THIS is the beauty of OSS. Collectively, we can do so much more than M$ ever will. Just you wait, Bill! We're coming after your empire!
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8715

PostPosted: Fri 09 Oct 2009, 12:41    Post subject:  

Not as daunting as it sounds...just a few lines of script in the right places Smile .

Actually the other reason for posting is that I'm not getting every notification from the forum ..

regards

mike
Back to top
View user's profile Send private message 
SilverPuppy


Joined: 28 May 2009
Posts: 143

PostPosted: Fri 09 Oct 2009, 21:46    Post subject: Ummm.....yoikes!  

Well, I have achieved partial success. I have reengineered the startup and shutdown scripts with the help of the OSS Community so that now it will detect and automatically recover from the most common improper shutdowns (turning power off without selecting power off on the menu.) I will link the files I modified later.

I have NOT however succeeded in getting fsck to run in the startup script. If I put it between loading kernel modules and swap activation, fsck says the partition is mounted. If I add a umount first it gripes that's not possible and then fsck still says it's mounted. If I put it before "making filesystem usable" fsck says that it can't access the device, probably because /dev hasn't been properly populated yet.

While it seems very solid the way I have it, and booting from a CD and fsck-ing the hard drive found no serious errors after about a dozen nasty shutoffs, I would feel better if cleanup was being done along the way after an unclean shutdown. I have heard that ext3 checks itself at mount, but fsck said it had been mounted 24 times without an fsck. I tried the /forcefsck trick, which did nothing.

I read something about Barry disabling automatic fsck to improve boot times. How can I selectively re-enable it without (for example) adding one-time options to grub's menu.lst boot line and then yanking them back out?
Back to top
View user's profile Send private message 
SilverPuppy


Joined: 28 May 2009
Posts: 143

PostPosted: Sat 10 Oct 2009, 00:15    Post subject: Files and such  

Here's the files I created (with help from you, of course....)

I strongly recommend using these or an improved version of these with EXT3 if you are using Puppy as a full install for a non-computer-person (such as an elderly person) as they greatly reduce the amount of fiddling required to clean up after things we wish they wouldn't do.......or power loss, etc.

This was very educational, to say the least. Maybe one day I'll upload an improved Puppy Package Manager that makes uninstall archives with the files which would have otherwise been overwritten and then puts them back upon uninstall. That project needs to be tackled, and it sounds like fun. I have a feeling someone more sage will beat me to it, though.......

[EDIT] One other thing I've learned in screwing around with this Puppy-----when fsck warns that fsck-ing a mounted partition is dangerous, they're NOT KIDDING! I've completely destroyed 2 or 3 installations that way. The first couple of times I thought that they must have been severely damaged anyway, and would have self-destructed sooner or later without my intervention. The third time it dawned on me......I'll bet something happened in the background that caused fsck to royally screw up the FS.....because it could, because it was mounted! So from now on, as much as it pains me to wait for a CD bootup, I'll be doing all future fsck-ing from a liveCD.

On an unrelated quirky note, "fsck-ing" just looks kinda......ummmmm........wrong??? Laughing

[EDIT AGAIN] I thought I should explain what these files do and what they're based on. This script is from the 4.1.2 RETRO kernel, so you might have to just find my insertions and put them in the appropriate places in your files. This version creates a flag file /tmp/RUNNING in the bootup process, then removes it during shutdown. If the file is PRESENT at bootup, then it knows that Puppy was not properly shut down, and performs a little file cleanup and reboots. This allows the services to all start correctly after the automatic reboot and X will also start with just the warning screen, rather than dumping to a bash prompt and waiting for startx. This version does NOT perform fsck on the hard drive; the version below does.
rc.files.tar.gz
Description 
gz

 Download 
Filename  rc.files.tar.gz 
Filesize  18.23 KB 
Downloaded  375 Time(s) 

Last edited by SilverPuppy on Sat 10 Oct 2009, 14:05; edited 1 time in total
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8715

PostPosted: Sat 10 Oct 2009, 07:45    Post subject:  

Oops my description was too vague....in puppy 2
Code:
e2fsck -p /dev/hda3
echo -n "Making the filesystem usable..."

this works but for puppy 4 the check needed to be inserted between these two lines...
Code:
busybox mount -t proc none /proc ;STATUS=$((STATUS+$?))
[ ! -d /initrd ] && busybox mount -o remount,rw,noatime /

but...I'm not 100% sure cos I'm not using it on my puppy4 install (ext3) but I did try it...I may also have moved
Code:
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab
or
Code:
busybox mount /dev/pts ;STATUS=$((STATUS+$?))
mkdir /sys 2>/dev/null
busybox mount -t sysfs none /sys ;STATUS=$((STATUS+$?))

earlier ....basically to make the partition device visable....as long as the check is whilst / is read only..it was a case of trial and error but definately done in rc.sysinit....teach me to keep notes.

The reason puppy does not fsck everytime is that with a frugal install there is no way (as far as I know) to unmount dev_save cos its in the union....so there would be a full check forced every boot. With a clean partition it only takes a fraction of a second.

mike

mike
Back to top
View user's profile Send private message 
SilverPuppy


Joined: 28 May 2009
Posts: 143

PostPosted: Sat 10 Oct 2009, 12:17    Post subject: Ah, victory!  

OK, then! Thanks to Mr. mikeb, I now have it exactly as I want it. I struggled briefly with creating a flag that rc.sysinit could see so early in the boot process, but putting it in / worked. Initially I tried to put it in /tmp to be tidy, as I did with RUNNING (I thought it looks messy in /) but it was not visible in /tmp at that point in the script. That's OK, as messy is not significant, since that flag only exists between the time of first phase cleanup and reboot to fsck and reload properly. The only way someone would ever see the flag file /fsckme would be to boot from a liveCD on the reboot and look at the hard drive. NOT something that most people will be doing. It'll be fine.

So.....here's the updated scripts. I really like these, and I highly recommend them for full HD installs. I see a few of you downloaded my original ones, but trust me, these are BETTER.

On a side note, I found a bug in PupZip........it added the one script to the file listing twice...... Rolling Eyes

[EDIT] Need to clarify again what this file is. This is the version that DOES perform fsck on the hard drive after an improper shutdown. Remember, this is from a RETRO kernel, so if you are using a newer one you will have to change the e2fsck line to reflect the correct nomenclature for your hard drive. Also, if your Puppy is not installed on the first partition, likewise, changing the nomenclature will be necessary. I don't see anything risky about what I've added; if you don't fix it right, it just won't work.
fsck-rc.sysinit.tar.gz
Description 
gz

 Download 
Filename  fsck-rc.sysinit.tar.gz 
Filesize  29.49 KB 
Downloaded  396 Time(s) 

Last edited by SilverPuppy on Sat 10 Oct 2009, 14:12; edited 1 time in total
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8715

PostPosted: Sat 10 Oct 2009, 12:54    Post subject:  

Quote:
On a side note, I found a bug in PupZip........it added the one script to the file listing twice......

it tends to do that if you open with more than one file/folder to create a new archive.

your flag could have a . in front of it to keep it hidden.

I assume my description from memory of the location of e2fsck is correct.?
Also just running fsck tries to check all partitions but then sometimes it does not...would be handy if it did

You might like to add a summary of this to the HOW TO section once you are fully happy with it..keeps it from being lost so easily.
mike
Back to top
View user's profile Send private message 
SilverPuppy


Joined: 28 May 2009
Posts: 143

PostPosted: Sat 10 Oct 2009, 13:58    Post subject: True.....  

I forgot about hidden files, so yes, that would be possible, but like I said, that flag file only exists during the reboot to finish the cleanup........so no end user (in my case) would ever see it anyway.

Yes, your memory was good. I added the creation of a flag file /fsckme after removing the temporary files but before the reboot, and added an if trigger that notices /fsckme and runs e2fsck on the hard drive if it exists. There's another if trigger deeper into the boot cycle that removes the /fsckme flag afterward. This if trigger is after the reboot in the initial cleanup if trigger, so it doesn't get removed if it is needed.

I wouldn't know how to add this to the HOWTO section, but maybe I can figure it out. Just this discussion in the forums will help a great deal. If I were looking to do this and someone else had had this discussion first, I'm sure I'd have found this, with tips and theoretically ready-to-implement files. (Although, I did just think of a few disclaimers I should put with my files above......)

Thinking about this now, I should state that it is theoretically possible to do this in one pass without a reboot, but I think with a reboot is best because that cleans up the files, flags for fsck, reboots, fscks, and then boots normally. I could move the RUNNING flag file back out of the /tmp folder and make the fsck if trigger look for that as well, which would eliminate the need for a reboot........but that wouldn't fix the fact that a reboot is still required after an improper shutdown to restore proper USB function, and I think something else as well, so rebooting is best. This automates the whole process of recovering from an improper shutdown, rather than leaving my non-computer-literate end-users wondering why their printer doesn't work anymore............rather than wasting their time and mine figuring out that they need to reboot again to finish the cleanup, it's best to just let Puppy take care of it.

Wow, a Puppy that does his own Poop-scoop Boogie! Laughing
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8715

PostPosted: Sat 10 Oct 2009, 14:51    Post subject:  

Nice one.....just post in the HOW TO section...title of what its for ,summerise its function, include files and instructions to implement. Another reason is that a post like this includes the learning bit that can be confusing to a user.

mike
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3524
Location: West Lothian, Scotland, UK

PostPosted: Sat 10 Oct 2009, 17:18    Post subject:  

Sorry, posted in error.

Is there a way to delete a post?
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0917s ][ Queries: 13 (0.0084s) ][ GZIP on ]