How to manually fsck an encrypted pupsave
How to manually fsck an encrypted pupsave
As of Puppy 4.1.2, "puppy pfix=fsck" does not work. This is a manual alternative:
Boot "puppy pfix=ram"
In a console window, mount the volume containing your pupsave. Then "cd" there.
modprobe cryptoloop
modprobe aes
losetup-FULL -e aes /dev/loop6 pup_save_crypta.2fs
e2fsck /dev/loop6
This procedure assumes heavy encryption and will need modification for light encryption (perhaps someone else can contribute that recipe). It also assumes your pupsave is named "pup_save_crypta.2fs", of course.
Boot "puppy pfix=ram"
In a console window, mount the volume containing your pupsave. Then "cd" there.
modprobe cryptoloop
modprobe aes
losetup-FULL -e aes /dev/loop6 pup_save_crypta.2fs
e2fsck /dev/loop6
This procedure assumes heavy encryption and will need modification for light encryption (perhaps someone else can contribute that recipe). It also assumes your pupsave is named "pup_save_crypta.2fs", of course.
I'm in hurry, so just a quick guess:
losetup-FULL -e xor /dev/loop6 pup_save_crypta.2fs
e2fsck /dev/loop6
http://noforum.de/man2html.php?page=losetup
Mark
losetup-FULL -e xor /dev/loop6 pup_save_crypta.2fs
e2fsck /dev/loop6
http://noforum.de/man2html.php?page=losetup
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
According to the comments in the scripts in Puppy 4.2, that xor is a different one from the xor used for the encryption. According to the scripts it works like this:
I don't have one handy to test with though.
Also, if you have a bunch of filesystem images mounted, /dev/loop6 might already be in use. Running losetup-FULL -f will tell you the name of a free loopback device. And if you screw up while doing this, the loopback device you use might be left in-use. In that case, you can free it with losetup-FULL -d /dev/loop6
Just doing losetup-FULL /dev/loop6 will tell you information about the device.
REFERENCE: 683-687 of init from initrd.gz of Puppy 4.2.1:
EDITED 2009.07.05: Changed 'losetup' to 'losetup-FULL' because it's more reliable across multiple versions of Puppy.
Code: Select all
modprobe cryptoloop
losetup-FULL -E 1 /dev/loop6 pup_save_cryptx.2fs
e2fsck /dev/loop6
Also, if you have a bunch of filesystem images mounted, /dev/loop6 might already be in use. Running losetup-FULL -f will tell you the name of a free loopback device. And if you screw up while doing this, the loopback device you use might be left in-use. In that case, you can free it with losetup-FULL -d /dev/loop6
Just doing losetup-FULL /dev/loop6 will tell you information about the device.
REFERENCE: 683-687 of init from initrd.gz of Puppy 4.2.1:
Code: Select all
case $PUPSAVEFILE in
*cryptx*) #see /etc/rc.d/rc.shutdown.
CRYPTO='-E 1' #v2.16final '-e xor' --bug, loads xor.ko which is something else.
modprobe cryptoloop
;;
EDITED 2009.07.05: Changed 'losetup' to 'losetup-FULL' because it's more reliable across multiple versions of Puppy.
Last edited by Pizzasgood on Sun 05 Jul 2009, 19:22, edited 2 times in total.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
Thanks Mu and pizzasgood-
I'm using 4.1.2, not 4.2 -- but that didn't make a difference, pizzasgood solution worked.
I did try Mu's suggetsion first but I got an error message after entering the password. Thanks Mu for giving it a shot that quickly!
Thanks pizzasgood once again for the massive amount of help you give people here.
To clarify for others the steps that worked for me:
In my case my savefile was on sda6/puppy412/ and was named pup_save_cryptx.2fs, change that if your setup is different (marked in blue below). So:
1.) Boot puppy CD w/ puppy pfix=ram option
2.) Mount sda6
3.) open terminal
4.) type and enter modprobe cryptoloop
5.) type and enter losetup -E 1 /dev/loop6 /mnt/sda6/puppy412/pup_save_cryptx.2fs
6.) answer the password prompt
7.) type and enter e2fsck /dev/loop6
8.) you may be asked if you want to correct specific problems -- I answered yes to all, however it's possible not to if you feel something shouldn't be changed.
Thanks once again Pizzasgood, Mu, and PaulBx1 for this. You guys are great!
Makes me wonder if there's a simple bugfix in 4.1.2's code so that you can do an fsck as you are supposed to at the bootup password prompt. Functionality is supposed to be: hit ENTER instead of password, then in answer to the red prompt, hit any other letter.
I'd really like to do a routine fsck every month or so using the normal bootup method.
I'm using 4.1.2, not 4.2 -- but that didn't make a difference, pizzasgood solution worked.
I did try Mu's suggetsion first but I got an error message after entering the password. Thanks Mu for giving it a shot that quickly!
Thanks pizzasgood once again for the massive amount of help you give people here.
To clarify for others the steps that worked for me:
In my case my savefile was on sda6/puppy412/ and was named pup_save_cryptx.2fs, change that if your setup is different (marked in blue below). So:
1.) Boot puppy CD w/ puppy pfix=ram option
2.) Mount sda6
3.) open terminal
4.) type and enter modprobe cryptoloop
5.) type and enter losetup -E 1 /dev/loop6 /mnt/sda6/puppy412/pup_save_cryptx.2fs
6.) answer the password prompt
7.) type and enter e2fsck /dev/loop6
8.) you may be asked if you want to correct specific problems -- I answered yes to all, however it's possible not to if you feel something shouldn't be changed.
Thanks once again Pizzasgood, Mu, and PaulBx1 for this. You guys are great!
Makes me wonder if there's a simple bugfix in 4.1.2's code so that you can do an fsck as you are supposed to at the bootup password prompt. Functionality is supposed to be: hit ENTER instead of password, then in answer to the red prompt, hit any other letter.
I'd really like to do a routine fsck every month or so using the normal bootup method.
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
I'll take a look later tonight and see if it's still a problem in 4.2.1. If it isn't, I can throw together a 4.1.2 frugal really quick and test with that. Can't be too hard to fix.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
Well, in the init script from 4.2.1 I found this at lines 742-753:
The line we're interested in is 747:
#fsck_func loop1 ext2 $PUPSAVEFILE #v3.01. no, removed, takes ages, and won't mount afterward.
The fsck_func function automatically checks whether the pfix=fsck option has been given, and immediately returns unless it has. Otherwise it runs a scan. Except that this line was commented out, apparently because it wasn't working properly in 3.01. I'm not sure what that was about. I remember that there some issues with encryption back around that time, so maybe it was some 3.01 specific problem.
Anyways, I uncommented that line, rebuilt my initrd.gz file, and rebooted with pfix=fsck. As far as I can tell it worked. I got a message saying it was checking the file, and then after a short pause things continued as usual. After booting I looked in /initrd/tmp/ and found the file chret, which is where the fsck_func function stores the output from e2fsck. It listed a number of issues that it fixed automatically. Nothing seemed out of order.
I'm not going to post a bunch of initrd.gz files for the different versions of Puppy 4.x because I probably should have gone to bed half an hour ago. If anybody needs them and isn't willing to do it themselves, let me know and I can make them another night. But it's only a minor change to init - extract the initrd.gz file, open the 'init' script as text, and uncomment that line. It's line 747 in 4.2.1, but it will be at other places in other Puppies. Just paste the line into the find bar and it will come up. After uncommenting it (simply remove the #) rebuild and replace the initrd.gz file.
For those who need instructions on editing initrd.gz: How to edit initrd.gz (for Puppy 3.x and newer)
Code: Select all
losetup $CRYPTO /dev/loop1 /mnt/dev_save$PUPSAVEFILE
fi
fi
echo "/dev/loop1 $CREATEPUPSAVE2FS ext2 defaults 1 1" >> /etc/fstab #v2.21
#fsck_func loop1 ext2 $PUPSAVEFILE #v3.01. no, removed, takes ages, and won't mount afterward.
mount -t ext2 -o noatime,rw /dev/loop1 $CREATEPUPSAVE2FS
MNTSTAT=$?
if [ "$MNTSTAT" = "0" ] ; then
echo -n "...successfully mounted" >/dev/console
break
else
#fsck_func loop1 ext2 $PUPSAVEFILE #v3.01. no, removed, takes ages, and won't mount afterward.
The fsck_func function automatically checks whether the pfix=fsck option has been given, and immediately returns unless it has. Otherwise it runs a scan. Except that this line was commented out, apparently because it wasn't working properly in 3.01. I'm not sure what that was about. I remember that there some issues with encryption back around that time, so maybe it was some 3.01 specific problem.
Anyways, I uncommented that line, rebuilt my initrd.gz file, and rebooted with pfix=fsck. As far as I can tell it worked. I got a message saying it was checking the file, and then after a short pause things continued as usual. After booting I looked in /initrd/tmp/ and found the file chret, which is where the fsck_func function stores the output from e2fsck. It listed a number of issues that it fixed automatically. Nothing seemed out of order.
I'm not going to post a bunch of initrd.gz files for the different versions of Puppy 4.x because I probably should have gone to bed half an hour ago. If anybody needs them and isn't willing to do it themselves, let me know and I can make them another night. But it's only a minor change to init - extract the initrd.gz file, open the 'init' script as text, and uncomment that line. It's line 747 in 4.2.1, but it will be at other places in other Puppies. Just paste the line into the find bar and it will come up. After uncommenting it (simply remove the #) rebuild and replace the initrd.gz file.
For those who need instructions on editing initrd.gz: How to edit initrd.gz (for Puppy 3.x and newer)
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
Thanks for that Pizzasgood, I will try it later tonight.
I'm wondering if the reason for long delay, and/or reason it wouldn't mount is that the fsck process is throwing a Y/N question for the user, but possibly the user doesn't see or answer it? Maybe a subsequent silent abort leaves things mixed up. I don't know just throwing out a possibility since the code I used earlier definitely requires sitting by the keyboard. I had to hold down the Y key for autorepeat to get through all of the Y/N queries. Guess I had a lot of errors.
Is the fsck in initrd set to auto-fix errors, or does it still query?
Thanks again, and happy 4th of july (assuming you're in the states)!
I'm wondering if the reason for long delay, and/or reason it wouldn't mount is that the fsck process is throwing a Y/N question for the user, but possibly the user doesn't see or answer it? Maybe a subsequent silent abort leaves things mixed up. I don't know just throwing out a possibility since the code I used earlier definitely requires sitting by the keyboard. I had to hold down the Y key for autorepeat to get through all of the Y/N queries. Guess I had a lot of errors.
Is the fsck in initrd set to auto-fix errors, or does it still query?
Thanks again, and happy 4th of july (assuming you're in the states)!
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
This is the code for fsk_func in Puppy 4.2.1 (Lines 56-85 of init):
In particular, line 64:
e2fsck -y /dev/$1 >/tmp/chkret &
So it's assuming yes, at least in 4.2.1.
Yeah, I'm in TN right now, in a house sticking off the side of some mountain (Mom just moved here three weeks ago). Went to see Transformers yesterday, and played some Nethack. Then I forgot which day it was and thought the neighbors were shooting at something for a couple moments before I realized it was just fireworks.
Code: Select all
#v3.01 fsck for ext2/3 prior to mounting...
fsck_func() { #passed params: partition filesystem [filename]
[ "$PFSCK" != "yes" ] && return 0 #v404 default is not do any checking.
#v3.93 restrict to ext2 only...
#[ "$2" != "ext2" -a "$2" != "ext3" ] && return 0 #precaution.
[ "$2" != "ext2" ] && return 0 #precaution.
CHKDEV=$1
#[ $3 ] && CHKDEV="`basename $3`"
e2fsck -y /dev/$1 >/tmp/chkret &
#sleep 1
#if [ "`grep ': clean, ' /tmp/chkret`" = "" ];then
# echo -e "\\033[1;35m" >/dev/console #35=purple
# echo -n "Performing filesystem check on ${CHKDEV}, please wait" >/dev/console
# echo -en "\\033[0;39m" >/dev/console
#fi
echo -en "\\033[1;35m" >/dev/console #35=purple
MSGFSCK=" ${1} filesystem check, please wait..............."
MSGFSCNT=1
while [ "`pidof e2fsck`" != "" ];do
if [ "${1}" = "loop1" ];then
[ $MSGFSCNT -eq 1 ] && echo -n "filesystem check..." >/dev/console
else
[ $MSGFSCNT -lt 47 ] && MSGCHAR="`echo -n "$MSGFSCK" | cut -b $MSGFSCNT`"
echo -n "$MSGCHAR" >/dev/console
fi
sleep 1
MSGFSCNT=`expr $MSGFSCNT + 1`
done
echo -en "\\033[0;39m" >/dev/console
}
e2fsck -y /dev/$1 >/tmp/chkret &
So it's assuming yes, at least in 4.2.1.
Yeah, I'm in TN right now, in a house sticking off the side of some mountain (Mom just moved here three weeks ago). Went to see Transformers yesterday, and played some Nethack. Then I forgot which day it was and thought the neighbors were shooting at something for a couple moments before I realized it was just fireworks.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
It's Line #726 in Puppy 4.1.2, for anyone interested.Pizzasgood wrote:.... It's line 747 in 4.2.1, but it will be at other places in other Puppies. Just paste the line into the find bar and it will come up. After uncommenting it (simply remove the #) rebuild and replace the initrd.gz file.
For those who need instructions on editing initrd.gz: How to edit initrd.gz (for Puppy 3.x and newer)
Man the 4th of july came and went, along with 3 more months. Sorry about the slow reply. On a mountain myself hanging off it in a cabin.
Hi Paul BX, I've had trouble with my heavy encrypted savefile, documented here:
http://www.murga-linux.com/puppy/viewtopic.php?t=72236
I used the code you provided above but it doesn't seem to work due to some block issue, have you seen this before?
http://www.murga-linux.com/puppy/viewtopic.php?t=72236
I used the code you provided above but it doesn't seem to work due to some block issue, have you seen this before?
Buy silver, crash JPMorgan
In wary 5.3 with lightencrypted savefile:
worked for me.
Code: Select all
modprobe cryptoloop
losetup-FULL -E 1 /dev/loop2 warysave_cryptx-w53.2fs
e2fsck /dev/loop2
losetup-FULL -d /dev/loop2