Remove some inappropriate code from the 'init' script

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Remove some inappropriate code from the 'init' script

#1 Post by gyro »

Here is a patch to the 'init' script in 'initrd.gz':

Code: Select all

--- init.orig	2015-02-08 22:04:18.591866000 +1000
+++ init	2015-03-18 07:01:59.074300604 +1000
@@ -1022,17 +1025,6 @@
    esac
   fi
   if [ -d /mnt/dev_save$PUPSAVEFILE ]; then
-   # Check partition if user calls for savefile check
-   if [ "$PFSCK" = "yes" ]; then
-    umount /mnt/dev_save
-    MOUNTED=$(cat /proc/mounts | grep $PUPSAVEDEV |cut -f 2 -d ' ')
-    MNTOPT=$(cat /proc/mounts | grep $PUPSAVEDEV |cut -f 4 -d ' ')
-    umount  $MOUNTED
-    FSCKME="$(echo $PUPSAVE | tr ',' ' ')"
-    fsckme_func $FSCKME
-    mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV $MOUNTED $MNTOPT
-    mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV /mnt/dev_save noatime
-   fi
    rm -r -f $CREATEPUPSAVE2FS
    ln -s /mnt/dev_save${PUPSAVEFILE} $CREATEPUPSAVE2FS
   elif [ "$CRYPTO" != "" ] ; then
It removes some code that in my view is the wrong code in the wrong place.
This code is now in woof-ce and hence Tahrpup 6.0.2 and similar puppies.

Reasoning:

From the source code:

Code: Select all

   fsck)    PFSCK="yes";;         #do a fsck of ${DISTRO_FILE_PREFIX}save file.
I interpret this to mean "fsck the filesystem that is contained within the savefile" on every boot.
Some of us use this facility for savefiles since it doesn't take long, (savefiles are usually not very big compared to the size of partitions). And puppy has a history of not cleanly unmounting savefiles.
With the installed code, if you convert your savefile to a savefolder, suddenly "pfix=fsck" means fsck the whole partition on every boot.
Applying the patch reverts the meaning of "pfix=fsck" to it's original meaning.

With a savefile there are 2 appropriate filesystems, the filesystem in the partition and the filesystem in the savefile.
With a savefolder there is only 1 appropriate filesystem, the filesystem in the partition. The savefolder is just another directory in the partition.
So if we assume that the "fsckme.flg" mechanism provides integretity to the filesystem in the partition, then with a savefolder there is no filesystem for "pfix=fsck" to fsck.

if we don't assume that the "fsckme.flg" mechanism is adaquate, then we need to provide the best possible facility to fsck the partition on every boot.
I suggest that http://www.murga-linux.com/puppy/viewtopic.php?t=97235 is a more appropriate base for providing such a facility.
Any facility to fsck the partition should be independent of "pfix=fsck", so it is available to all puppies not just those that use savefolder.

Note1: I run my puppies on an ext4 partition with a "pfix=fsck4,fsck" boot parameter, so that if I am using a savefile both filesystems get fscked, and if I'm using a savefolder then the partition is fscked.

Note2: The 'init' script can only fsck ext2, ext3 and ext4 filesystems, since 'initrd.gz' contains only 'e2fsck'.

To use the patch:
Cut and paste the patch into a text editor and save it as 'init.diff'
Uncompress the current 'initrd.gz'
Patch the 'init' file with the saved 'init.diff' file.
Compress a new 'initrd.gz' file.

Tahrpup 6.0.2 "initrd.gz" files that contain both tihs and the 'always fsck ext4' patch, can be downloaded from here:
noPAE: http://www.fishprogs.info/puppy/tahr602nopae/initrd.gz
PAE: http://www.fishprogs.info/puppy/tahr602pae/initrd.gz

gyro
Last edited by gyro on Sun 17 May 2015, 04:28, edited 1 time in total.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#2 Post by mavrothal »

I do not want to argue the logic or anything, just to point out that what is in woof-CE is a bit different.
If interested see commits f6702f4, 5f56e6e and 37c1b46.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#3 Post by Karl Godt »

Instead of commenting code or removing code , I would suggest to wrap that code into an unused function.

This looks nicer and code logic does not get lost .

Like so :

Code: Select all

   esac
   fi
   if [ -d /mnt/dev_save$PUPSAVEFILE ]; then
  
  #====================
  # REM : wrap code into function .
  # TODO : remove that function if confirmed unneeded in 1-5 years
  # DRAWBACKS : compatibility problems with older Puppies 
   __unused_fsckme_function_old__(){
   # Check partition if user calls for savefile check
   if [ "$PFSCK" = "yes" ]; then
    umount /mnt/dev_save
    MOUNTED=$(cat /proc/mounts | grep $PUPSAVEDEV |cut -f 2 -d ' ')
    MNTOPT=$(cat /proc/mounts | grep $PUPSAVEDEV |cut -f 4 -d ' ')
    umount  $MOUNTED
    FSCKME="$(echo $PUPSAVE | tr ',' ' ')"
    fsckme_func $FSCKME
    mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV $MOUNTED $MNTOPT
    mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV /mnt/dev_save noatime
   fi
   }
  #==================

    rm -r -f $CREATEPUPSAVE2FS
    ln -s /mnt/dev_save${PUPSAVEFILE} $CREATEPUPSAVE2FS
   elif [ "$CRYPTO" != "" ] ; then 
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#4 Post by gyro »

In relation to mavrothal's comment:
Yes, the code in the testing branch has changed.
But that just means the patch as is won't apply, but the code should still be deactivated. My reasoning for deactivating this code still apply.

@Karl Godt,
Doesn't matter how it's done, just ensure that this code is not active.

gyro

Post Reply