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 Wed 04 Mar 2015, 14:54
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
ext4 partitions - always fsck before first mount
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [14 Posts]  
Author Message
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Fri 09 Jan 2015, 03:43    Post subject:  ext4 partitions - always fsck before first mount
Subject description: turn on with "pfix=fsck4"
 

To get frugal installs of puppy to fsck ext4 partitions before mounting them, apply the following patch to the "init" script in "initrd.gz":
Code:
--- init.orig   2015-02-02 18:42:51.556031450 +1000
+++ init   2015-02-02 18:38:55.299044496 +1000
@@ -370,11 +370,13 @@
   fi
   
   #v403 nasty bug: usb optical drive showing as /sys/block/sr0, but won't mount, needs more delay...
+  [ "$PFSCK4" = "yes" ] && [ "$ONEFS" = "ext4" ] && echo "" > /dev/console && e2fsck -y /dev/$ONEDEV > /dev/console 2>&1
   mntfunc $ONEFS /dev/$ONEDEV /mnt/data #-t $ONEFS /dev/$ONEDEV /mnt/data
   if [ $? -ne 0 ];then
    echo "PAUSE 5SEC: tried to mount /dev/${ONEDEV}, ${ONEFS} f.s." #101005 boot param loglevel=7 will show this.
    echo -e -n " \\033[1;31mpausing\\033[0;39m" > /dev/console #31=red
    sleep 5 #2 wasn't enough.
+   [ "$PFSCK4" = "yes" ] && [ "$ONEFS" = "ext4" ] && echo "" > /dev/console && e2fsck -y /dev/$ONEDEV > /dev/console 2>&1
    mntfunc $ONEFS /dev/$ONEDEV /mnt/data
    if [ $? -ne 0 ];then
     echo "RETRY FAILED: mounting /dev/${ONEDEV}, ${ONEFS} f.s." #101005
@@ -623,6 +625,7 @@
    copy)    PCOPY="yes";;         #copy .sfs files into ram.
    nocopy)  PNOCOPY="yes";;        #do not copy .sfs files into ram (default is copy if enough ram).
    fsck)    PFSCK="yes";;         #do a fsck of ${DISTRO_FILE_PREFIX}save file.
+   fsck4)   PFSCK4="yes";;        #do a fsck of ext4 partition before mounting.
    [0-9]*)  PIGNORELAST=$ONEFIX;; #blacklist last $ONEFIX folders (multisession).
   esac
  done
Historically, puppy has avoided fsck like it was the plague. Because fsck would sometimes take a long time to check a file system, even if it was clean.
The "fsckme.flg" file and it's associated code , is an attempt to run fsck only when it is absolutely necessary.

It seems that ext4 keeps track of it's integrity so that fsck only does things if they are necessary.
If an ext4 file system has been cleanly unmounted, then fsck does very little and is extremely fast.
If an ext4 file system has not been cleanly unmounted, for any reason, then fsck is just fast.
So, if an fsck of an ext4 file system is taking significant time, then most likely the filesystem needs fixing.

I've been running my puppies with an earlier version of the above patch applied for some time now, and it has very little impact on boot time when the file system is clean.

Note: Yes, it does muck-up the prettiness of the boot messages on the console a bit.

Edit: The code here has been updated, see later posts.
(And updated again.)

Edit2: Changed "fsckp" to "fsck4" in updated code.

gyro

Last edited by gyro on Tue 03 Feb 2015, 02:39; edited 8 times in total
Back to top
View user's profile Send private message 
mavrothal


Joined: 24 Aug 2009
Posts: 2127

PostPosted: Fri 09 Jan 2015, 05:47    Post subject:  

You do not need to mess up with the init.You can easily do it from user-space
Just comment out the rc.shutdown line that reads
Code:
[ -f /initrd${PUP_HOME}/fsckme.flg ] && rm -f /initrd${PUP_HOME}/fsckme.flg

Puppy will see the flag on next boot, consider it an improper shutdown and run fsck Wink

_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Fri 09 Jan 2015, 08:01    Post subject:  

mavrothal wrote:
Puppy will see the flag on next boot, consider it an improper shutdown and run fsck Wink
Yes, but there's just 1 little downside. Doing this will result in the following line in "init" being executed:
Code:
e2fsck -y -f /dev/$1 >/tmp/chkret &
The downside is the "-f". This forces a full check, no matter what the state of the file system. Kind of defeats the fsck advantages of ext4.

gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Wed 21 Jan 2015, 01:32    Post subject: Updated version  

Here is an updated version of the patch:

Code removed, please use first post for current code.

Just adds a newline to tidy up the console output a bit.

gyro

Last edited by gyro on Mon 26 Jan 2015, 21:57; edited 2 times in total
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Mon 26 Jan 2015, 21:49    Post subject: Update to provide user control, "pfix=fsckp"  

Yet another update to the patch.
Now it is inactive by default, but can be activated by adding "pfix=fsckp" as a boot parameter.
Please see first post for updated code.

Tahrpup 6.0.1 "initrd.gz" files can be downloaded from here:
noPAE: http://www.fishprogs.info/puppy/tahr601nopae/initrd.gz
PAE: http://www.fishprogs.info/puppy/tahr601pae/initrd.gz
They implement this option to fsck the partition and remove the fscking of the partition when a savefolder is used in conjunction with "pfix=fsck".

gyro
Back to top
View user's profile Send private message 
gcmartin


Joined: 14 Oct 2005
Posts: 4808
Location: Earth

PostPosted: Tue 27 Jan 2015, 01:06    Post subject: Re: Update to provide user control, "pfix=fsckp"  

Hello @Gyro
gyro wrote:
Yet another update to the patch.
Now it is inactive by default, but can be activated by adding "pfix=fsckp" as a boot parameter. ...

Tahrpup 6.0.1 "initrd.gz" files can be downloaded from here:
noPAE: http://www.fishprogs.info/puppy/tahr601nopae/initrd.gz
PAE: http://www.fishprogs.info/puppy/tahr601pae/initrd.gz
They implement this option to fsck the partition and remove the fscking of the partition when a savefolder is used in conjunction with "pfix=fsck".

gyro
Would this also apply to @BarryK's April64? Would one just add the init file's changes? Would the boot parm prevail? As you may know, @BarryK's is a "full" install without save-sessions.

Thanks in advance

_________________
Get ACTIVE Create Circles; Do those good things which benefit people's needs!
We are all related ... Its time to show that we know this!
3 Different Puppy Search Engine or use DogPile
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Tue 27 Jan 2015, 01:16    Post subject: Re: Update to provide user control, "pfix=fsckp"  

gcmartin wrote:
Would this also apply to @BarryK's April64? Would one just add the init file's changes? Would the boot parm prevail? As you may know, @BarryK's is a "full" install without save-sessions
I don't think a full install has an "initrd.gz", so no.
gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Tue 27 Jan 2015, 01:31    Post subject: Update - move to better place, extend to ext3 and ext2  

Yet another update to the patch:
1) Moves the change to a better place in "init" so that the fsck is done on the first mount and only on the first mount.
2) Now works for ext3 and ext2 as well.
3) Uses a case statement to make it easy to modify the code to support other file systems.

For code, see first post.

Notes:
Since the facility can be turned on and off with a boot parameter, it has been extended to ext3 and ext2. But I don't recommend leaving the facility on for ext3 or ext2 partitions, their fsck can sometimes take a long time.
It's probably a good idea to provide a "pdev1" boot parameter when this facility is enabled. This limits "init"s searching to just the partition defined in the "pdev1" parameter and hence only that partition will be fscked.

The "initrd.gz" files for tahrpup 6.0.1 have been updated to this version.

gyro
Back to top
View user's profile Send private message 
mavrothal


Joined: 24 Aug 2009
Posts: 2127

PostPosted: Thu 29 Jan 2015, 05:44    Post subject:  

I was playing with something similar but when I moved to a machine with many partitions it became both slow and annoying.
I think it may be better to couple this to pdev1 rather than all ext partitions, with something like
Code:
[ "$ONEDEV" = "$PDEV1" ] && [ "$(echo $ONEFS| cut -c 1-3)" = "ext" ] \
 && fsckme_func $ONEDEV $ONEFS

Maybe follow psavemark too but not everything. ( I remember that we added code to puppy so when booting from a CD with pmedia=cd pfix=ram to not check/mount the partitions at all, because or relevant requests)

_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Thu 29 Jan 2015, 11:05    Post subject:  

mavrothal wrote:
I was playing with something similar but when I moved to a machine with many partitions it became both slow and annoying.
I think it may be better to couple this to pdev1 rather than all ext partitions
No change is needed.
1) If you specify pdev1, then current puppy "init' only mounts the partition specified by pdev1, so only fscks that single partition. I have 2 ext4 partitions, but it only fscks the one I boot off.
2) If use with ext4 as recommended it's not slow, unless there's a problem.

gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Thu 29 Jan 2015, 23:23    Post subject: updated again - remove support for ext2 and ext3  

I have reassessed what I am trying to do here.
Principles:
1) fsck of ext4 partition is a whole lot faster than ext2 or ext3, this is what it's all about.
2) The facility is mean to be always activated.
3) The ability to activate via boot parameter is meant to provide a single "initrd.gz" that can be used by those who want to fsck ext4 and those who don't want to fsck ext4 partitions.

So, I have removed support for ext3 and ext2, and simplified the code to the insertion of 2 lines.

pdev1:
If your puppy.sfs and your savefile or savefolder are both in the same directory, I recommend that you specify "pdev1" as a boot parameter. This limits the searching done by "init" to just that partition, which also limits any partition fscking to just that partition.

psavemark:
If psavemark is specified, either as a boot parameter, or with a SAVEMARK file, it's probably not a good idea to specify "pdev1". You want "init" to search the partition you booted from and the partition where the savefile or savefolder is. If both these partitions are ext4, then this will result in both being fscked,
But an fsck of ext4 is very fast compared to an fsck of ext2 or ext3.
And in most situations, I would think that only the partition containing the savefile or savefolder would be ext4.

The "initrd.gz" files mentioned above have been updated to this new version.

Sorry for all the chopping and changing.

See first post for current version of the code.

gyro

Last edited by gyro on Tue 03 Feb 2015, 02:34; edited 3 times in total
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Mon 02 Feb 2015, 08:50    Post subject: Hopefully last update - Also fsck slow to start devices  

If a device is slow to startup, it still needs to be fscked.
See first post for current version of the code.
gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Tue 03 Feb 2015, 02:36    Post subject: Update - cosmetic change, "fsckp" -> "fsck4"  

Cosmetic change, "fsckp" -> "fsck4", it's just a little more obvious.
See first post for current version of the code.
Udated tahrpup 6.0.1 "initrd.gz" files uploaded.
gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 664
Location: Brisbane, Australia

PostPosted: Mon 09 Feb 2015, 01:17    Post subject: Re: Update to initrd.gz files for Tahrpup 6.0.2  

Tahrpup 6.0.2 "initrd.gz" files can be downloaded from here:
noPAE: http://www.fishprogs.info/puppy/tahr602nopae/initrd.gz
PAE: http://www.fishprogs.info/puppy/tahr602pae/initrd.gz
1) Add the facility to always fsck an ext4 partition.
2) Remove code that does an fsck of the partition when a savefolder is used in conjunction with "pfix=fsck". (It's the wrong code, in the wrong place.)

gyro
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [14 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
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.0901s ][ Queries: 11 (0.0034s) ][ GZIP on ]