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 Tue 21 Apr 2015, 17:09
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
how to check and repair a 2fs filesystem-in-a-file
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
miriam


Joined: 06 Dec 2006
Posts: 282
Location: Queensland, Australia

PostPosted: Wed 03 Sep 2014, 05:39    Post_subject:  how to check and repair a 2fs filesystem-in-a-file
Sub_title: use fsck to check and repair a damaged 2fs file
 

I spent much of today working on a Puppy installation on a thumbdrive. Everything was going great until something went wrong and it was damaged somehow. I couldn't reboot into it and I was looking at many hours of work wasted.

After unsuccessfully spending a while looking around on the net for a solution, I started writing out a plea for help on this forum, but halfway through writing I realised the ridiculously simple solution. There may be an even easier solution, but here is what I came up with. If you know of an easier way please let me (and everyone else) know.

The problem with using fsck to check an sfs file is that until the sfs file is mounted it is just a file on some other filesystem. But you can't mount it because fsck requires the device name and that the device not be mounted. Unfortunately I couldn't work out how to give an sfs file a device name without mounting it.

And then it hit me...

Go to your /etc/fstab file and enter something like this into it:
Code:
/mnt/sdh1/pupsave.2fs   /mnt/sdh1/pupsave  ext2  defaults 0 0

In this instance my thumbdrive is mounted on /mnt/sdh1 and the sfs file I want to repair is called pupsave.2fs.

Save the fstab file. Puppy will notice and now think that there is a device /mnt/sdh1/pupsave.2fs that is mounted as /mnt/sdh1/pupsave which is type ext2.
NOTE: I previously made the type "squashfs", and that worked, but after reading and considering Amigo's comments below and researching more on the web, I think it is safer for the type to be ext2.

Now open a terminal and use fsck to repair it like this:
Code:
e2fsck /mnt/sdh1/pupsave.2fs

I used e2fsck because this sfs is ext2 internally.

If it refuses to do anything, and says the filesystem is clean, you can force it using the -f option:
Code:
e2fsck -f /mnt/sdh1/pupsave.2fs


Read the manual to find out what other options there are.

When you're done, delete or comment out the line in your fstab. I commented out mine by putting a # character at the beginning of the line. Then if calamity befalls me again, all I need do is edit the relevant parts of the line and re-use it.

I only use ext2 filesystem inside an sfs file because journals add many more writes, shortening the lifespan of a flash memory device. Also I never use encryption because I have a crap memory for passwords. Smile
NOTE: DO NOT do this with an encrypted sfs filesystem. I expect it will totally screw it.

But as watchdog mentions below there is a way to handle encryption. It is arguably simpler than my way of working on the 2fs file:
Code:
losetup-FULL -E 1 /dev/loop2 /mnt/sdh1/pupsave.2fs

or for normal, unencrypted 2fs files:
Code:
losetup-FULL /dev/loop2 /mnt/sdh1/pupsave.2fs

In this case the device is obviously /dev/loop2 which, although unlikely, it would probably be smart to ensure is not already being used by something (use the df command to see which are in use. And after you no longer need it you can remove the loop setup with:
Code:
losetup-FULL -d /dev/loop2

_________________
A life! Cool! Where can I download one of those from?

Edited_times_total
Back to top
View user's profile Send_private_message Visit_website 
watchdog

Joined: 28 Sep 2012
Posts: 753

PostPosted: Wed 03 Sep 2014, 06:18    Post_subject:  

I think the following commands could also work:

Code:
losetup-FULL /dev/loop2 /mnt/sdh1/pupsave.2fs
e2fsck /dev/loop2
losetup-FULL -d /dev/loop2


If the pupsave.2fs is lightencrypted than:

Code:
losetup-FULL -E 1 /dev/loop2 /mnt/sdh1/pupsave.2fs
e2fsck /dev/loop2
losetup-FULL -d /dev/loop2


If the pupsave.2fs is heavily encrypted than:

Code:
losetup-FULL -e aes /dev/loop2 /mnt/sdh1/pupsave.2fs
e2fsck /dev/loop2
losetup-FULL -d /dev/loop2


Be careful testing.

EDIT: read the following warning for old puppies:

http://www.murga-linux.com/puppy/viewtopic.php?p=798187#798187

Edited_times_total
Back to top
View user's profile Send_private_message 
miriam


Joined: 06 Dec 2006
Posts: 282
Location: Queensland, Australia

PostPosted: Wed 03 Sep 2014, 06:28    Post_subject:  

Very cool, watchdog! I hadn't heard of the losetup command before. That does seem to be an easy way to do it. Bonus that it's able to handle encryption as well. Neat!
_________________
A life! Cool! Where can I download one of those from?
Back to top
View user's profile Send_private_message Visit_website 
amigo

Joined: 02 Apr 2007
Posts: 2340

PostPosted: Wed 03 Sep 2014, 13:41    Post_subject:  

Uh, your thread title is misleading, because a *.2fs is not the same as a *.sfs file(system). There is no repair tool for squashfs (sfs) as it is only available as an image -it's not a normal block-based file system.
Back to top
View user's profile Send_private_message 
miriam


Joined: 06 Dec 2006
Posts: 282
Location: Queensland, Australia

PostPosted: Wed 03 Sep 2014, 19:20    Post_subject:  

Thanks Amigo. I didn't realise the difference until your comment prompted me to look further into it.

I've altered the subject title accordingly and have added a note that perhaps the type in my fstab entry should have been ext2 rather than squashfs... though squashfs did seem to work. Perhaps 2fs files might be better seen as a special variant of squashfs? Are 2fs files compressed internally? I need to learn more and experiment more with this.

_________________
A life! Cool! Where can I download one of those from?
Back to top
View user's profile Send_private_message Visit_website 
amigo

Joined: 02 Apr 2007
Posts: 2340

PostPosted: Thu 04 Sep 2014, 04:49    Post_subject:  

No, 2fs files are ext2 filesystem which do not feature compression -they are a 'normal' file system image. That is, ext2 is a normal block-based filesystem which can be written to or deleted from and can be repaired with fsck. Normally such FS's are used on a partition, but can also be used as a mountable FS image.
squashsfs can only be used as an FS image -you can't format a partition with squashfs and a squashfs image can't be altered or damaged since they are read-only.
Back to top
View user's profile Send_private_message 
Mayou


Joined: 17 Apr 2014
Posts: 22

PostPosted: Thu 22 Jan 2015, 00:49    Post_subject: Test  

# losetup-FULL /dev/loop2 /mnt/home/slackosave-bugGens.2fs
losetup-FULL: /dev/loop2: device is busy
# e2fsck /dev/loop2
e2fsck 1.41.14 (22-Dec-2010)
/dev/loop2 has gone 427 days without being checked, check forced.
Pass 1: Checking inodes, blocks, and sizes
Deleted inode 8348 has zero dtime. Fix<y>? yes

Deleted inode 8349 has zero dtime. Fix<y>? yes

Deleted inode 8353 has zero dtime. Fix<y>?

An what does that mean ? pleeease...
Back to top
View user's profile Send_private_message 
watchdog

Joined: 28 Sep 2012
Posts: 753

PostPosted: Thu 22 Jan 2015, 01:05    Post_subject: Re: Test  

Mayou wrote:
# losetup-FULL /dev/loop2 /mnt/home/slackosave-bugGens.2fs
losetup-FULL: /dev/loop2: device is busy


Your /dev/loop2 is occupied. Type in console:

Code:
losetup


to search for a free loop device (one not listed 0-9). Say it is /dev/loop9; then change the command:

Code:
losetup-FULL /dev/loop9 /mnt/home/slackosave-bugGens.2fs


Code:
e2fsck /dev/loop9
losetup-FULL -d /dev/loop9


If you are using slacko 5.7 then you should alternatively consider to boot your slackosave with boot option "pfix=fsck".
Back to top
View user's profile Send_private_message 
Mayou


Joined: 17 Apr 2014
Posts: 22

PostPosted: Thu 22 Jan 2015, 04:16    Post_subject: Pmount  

Thanks sir. I just come back from my breakfast.
I was testing with pmount , that is new. But it's only one pupsave which has problems.
So i will go further using your method.

Nevertheless here are the results with pmount
pmount.jpg
 Description   
 Filesize   50.93 KB
 Viewed   159 Time(s)

pmount.jpg

Back to top
View user's profile Send_private_message 
Mayou


Joined: 17 Apr 2014
Posts: 22

PostPosted: Thu 22 Jan 2015, 04:23    Post_subject: I suppose my pupsave must be in unmounted partition  

# losetup
/dev/loop0: 0 /mnt/tmpfs/puppy_slacko_5.3.2.9.sfs
/dev/loop1: 0 /mnt/dev_save/slackosave-bugGens.2fs
# losetup-FULL /dev/loop9 /mnt/home/slackosave-bugGens.2fs
# e2fsck /dev/loop9
e2fsck 1.41.14 (22-Dec-2010)
/dev/loop9 was not cleanly unmounted, check forced.

I suppose my pupsave must be in unmounted partition ? In that case i have to copy it on another pendrive... One second; I reboot on the second pupsave....

Edited_time_total
Back to top
View user's profile Send_private_message 
Mayou


Joined: 17 Apr 2014
Posts: 22

PostPosted: Thu 22 Jan 2015, 04:36    Post_subject: It's and old pendrive  

# losetup-FULL /dev/loop9 /mnt/home/slackosave-bugGens.2fs
# e2fsck /dev/loop9
e2fsck 1.41.14 (22-Dec-2010)
/dev/loop9 has gone 427 days without being checked, check forced.
Pass 1: Checking inodes, blocks, and sizes
Deleted inode 8353 has zero dtime. Fix<y>? yes

In fact, i can redo a pupsave. MY doubt was about the health of this usb stick.
What is your opinion ?

# losetup
/dev/loop0: 0 /mnt/tmpfs/puppy_slacko_5.3.2.9.sfs
/dev/loop1: 0 /mnt/dev_save/slackosave-LotusNotes.2fs
/dev/loop9: 0 /initrd/mnt/dev_save/slackosave-bugGens.2fs
# losetup-FULL /dev/loop9 /mnt/home/slackosave-bugGens.2fs
losetup-FULL: /dev/loop9: device is busy
#
I am on slackosave_LotusNotes.2fs !
loop.png
 Description   
 Filesize   72.36 KB
 Viewed   143 Time(s)

loop.png

Back to top
View user's profile Send_private_message 
watchdog

Joined: 28 Sep 2012
Posts: 753

PostPosted: Thu 22 Jan 2015, 05:56    Post_subject:  

You can't check a pupsave in use. Use this method from a live session or another pupsave. The pupsave to be checked must be in a mounted partition. Don't forget to free the loop device after check:

Code:
losetup_FULL -d /dev/loopx


In my opinion you are doing your job in a complicated manner. This method is obsolete for recent puppies which check the pupsave booting with option "pfix=fsck" even when the pupsave is an encrypted one.
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2340

PostPosted: Thu 22 Jan 2015, 11:01    Post_subject:  

Actually, you should be able to run fsck on the filesystem image and/or the partition it resides on -as long as they are mounted *read-only* during the operation. You can achieve that by using the command 'mount -o remount ...' -I guess on Puppy that menas the real command would be mount-FULL .... or something like that.
You can run 'mount' without any options to see the mount information and figure out the full remount command based on that. Here's an example:
Code:
# mount
/dev/sda2 on / type ext3 (rw,relatime,errors=continue,barrier=1,data=ordered)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/sda5 on /usr/src type ext3 (rw)

Say I want to check /dev/sda5, but it needs to remain mounted because some program is running from there. As you can see it is mounted read-write, but I can change that like this:
'mount -o remount,ro /dev/sda5'
Now I could run fsck on that partition even while mounted. Nearly all Linux systems boot with the root partition mounted read-only at first. Then, they are able to check the root partition before later using the remount option to make it writable for the later init processes.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0989s ][ Queries: 12 (0.0083s) ][ GZIP on ]