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 Oct 2014, 16:21
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: 281
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: 606

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: 281
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: 2257

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: 281
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: 2257

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 
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.0606s ][ Queries: 11 (0.0030s) ][ GZIP on ]