Use PC with frequent power outages & withstand corruption

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
wert
Posts: 258
Joined: Tue 31 Mar 2015, 21:40
Location: USA

Use PC with frequent power outages & withstand corruption

#1 Post by wert »

The normal filesystem in a partition setup of most PC's will get corrupt easily if the host is improperly powerred off and you might face many problems that are subtle to understand and/or to establish their causes. This can contribute to hours of time wasted on fixing attempts so you can get back to work. This is very inefficient whether you are a student, business person or even if you use your PC for amusement. Some modern filesystems such as NTFS can withstand frequent power outages, but not for long as eventually the system files will be lost and the PC's OS will no longer boot up. Whereas additional gear to your hardware setup such as an Uninterruptible Power Supply or can be a permanent solution to your power outages issues, puppy has a solution to this.

If you experience frequent power outages where your PC powers off unexpectedly and incorrectly here's a setup that withstands it.
1. Download puppy linux if you don't have it and install it to your PC
I've found that older puppies like lucid don't work out of the box with this so use something like xenial,slacko,tahr etc. precise may work but I've not tested
2. Here's the solution:
2.1 Format the partition you will install puppy files to as ext3. If no partition exists yet, first use the Windows partition manager program on windows to create a new one. Alternatively use gparted, gdisk(if your PC is EFI e.g. windows 8 and above), fdisk etc. on linux. If using linux OS Note that you may have to install and use gdisk to create the partition if your PC is EFI.
2.2 Format the new partition as Ext3. For this use gparted or just use /bin/sh and issue

Code: Select all

mkfs -t ext3 /dev/sdN
here N is your partition's number.
2.3 Install puppy and run it. When creating your first save, choose filesystem in a file and choose ext2 filesystem. Mak your you choose the partition you had created in step 2.1.
You can enable heavy encryption of you want.

Now your PC will never have any problems no matter how many power outages you experience. Unless you attempt to service it as an unqualified hardware expert and play with the HDD power cable; that's sure to do damage.

NOTE: This will not work if the bootloader code for your puppy does not have the @pfix=fsck@ argument
Older puppies like Lucid out of the box aren't able to check filesystem on encrypted saves so if you'll need take the following steps to manually do it frequently:
NOTE:
Replace N with the partition number your puppy files are located. They're numbered from 1.
Replace /dev/loop6 with any number e.g. /dev/loop10 if number 6 is in use
  1. At grub bootloader's screen, edit the line with pfix=..., adding without quotes the "pfix=ram".
    1. Once puppy has started, open urxvt or other terminal and if your partition is ext2, then issue

      Code: Select all

      e2fsck -y /dev/sdaN
      . Remember to replace N with the partition your puppy files e.g. MD5SUMS
      README.diskdefines
      adrv_xenialpup_7.5.sfs
      boot.catalog
      efi.img
      fsckme.flg
      grldr
      grub
      grub.cfg
      help
      initrd.gz
      isolinux.bin
      isolinux.cfg
      menu-2019-08-12-131631.lst
      menu-advanced.lst
      menu.lst
      puppy_xenialpup_7.5.sfs
      sda_mbr.bak
      zdrv_xenialpup_7.5.sfs

      are located on.
    1. After that is done, mount that partition in urxvt with commands:

      Code: Select all

      mkdir /mnt/sdaN
      mount /dev/sdaN /mnt/sdaN
    1. cd to your save file's directory i.e where the file that ends with .2fs, 3fs, 4fs is located.

      Code: Select all

      cd /mnt/sdaN/my_save_file_folder/
    1. Code: Select all

      modprobe cryptoloop (ignore any warning messages)
    1. Code: Select all

      modprobe aes
    1. if using heavy encryption,

      Code: Select all

      losetup-FULL -e aes /dev/loop6 yourpupsavefilename.Nfs
      , if using light encryption,

      Code: Select all

      losetup-FULL -e 1 /dev/loop6 yourpupsavefilename.Nfs
      . Then type in your savefile's password.
      If no encryption,

      Code: Select all

      losetup-FULL /dev/loop6 yourpupsavefilename.Nfs
    1. Code: Select all

      e2fsck -y /dev/loop6
    1. After the filesystem check(fsck) completes,then press F12 key, Exit reboot or click Menu, then Exit, then reboot.
Last edited by wert on Thu 21 Nov 2019, 11:48, edited 16 times in total.

User avatar
mikeslr
Posts: 3890
Joined: Mon 16 Jun 2008, 21:20
Location: 500 seconds from Sol

Alternative -- can work with Any Puppy, Any File-System

#2 Post by mikeslr »

Turn off the Automatic Save. See this thread, http://www.murga-linux.com/puppy/viewto ... 326#662326. For Older Puppies (and perhaps new builds of Older Puppies) follow the instructions at the beginning of the thread. But try this first. If on shutdown/reboot Puppy doesn't automatically Save the following is all that is needed. For Puppies first published since about 2014, the procedure is simple: (1) If your Puppy is NOT on USB-Stick edit grub4dos's menu.list Kernel line pmedia argument from pmedia=atahd to pmedia=ataflash; example, change

kernel /slacko572ce/vmlinuz psubdir=slacko572ce pmedia=atahd pfix=fsck

to

kernel /slacko572ce/vmlinuz psubdir=slacko572ce pmedia=ataflash pfix=fsck

Bolding for emphasis only.

The same change of argument can be employed under grub2.

Reboot.

That edit is not necessary if Puppy is on a USB-Stick as it's purpose is to "trick" Puppy into "thinking" it is.

(2) Open Menu>System>Puppy Event Manager. Click the Save Session Tab. Change the Save Session Interval to Zero (0). Optionally check the "Ask at Shutdown" box.

Reboot. A "Save" icon will appear on your Desktop to be used when you want to Save. Alternative, type save2flash in a terminal at any time.

With Puppy configured to never automatically Save you can, literally, pull the plug at any time without corrupting your SaveFile/Folder. So a power outage will have no adverse effect.

oui

#3 Post by oui »

mikeslr wrote:Turn off the Automatic Save. See this thread, http://www.murga-linux.com/puppy/viewto ... 326#662326. For Older Puppies (and perhaps new builds of Older Puppies) follow the instructions at the beginning of the thread. But try this first. If on shutdown/reboot Puppy doesn't automatically Save the following is all that is needed. For Puppies first published since about 2014, the procedure is simple: (1) If your Puppy is NOT on USB-Stick edit grub4dos's menu.list Kernel line pmedia argument from pmedia=atahd to pmedia=ataflash; example, change

kernel /slacko572ce/vmlinuz psubdir=slacko572ce pmedia=atahd pfix=fsck

to

kernel /slacko572ce/vmlinuz psubdir=slacko572ce pmedia=ataflash pfix=fsck

Bolding for emphasis only.

The same change of argument can be employed under grub2.

Reboot.

That edit is not necessary if Puppy is on a USB-Stick as it's purpose is to "trick" Puppy into "thinking" it is.

(2) Open Menu>System>Puppy Event Manager. Click the Save Session Tab. Change the Save Session Interval to Zero (0). Optionally check the "Ask at Shutdown" box.

Reboot. A "Save" icon will appear on your Desktop to be used when you want to Save. Alternative, type save2flash in a terminal at any time.

With Puppy configured to never automatically Save you can, literally, pull the plug at any time without corrupting your SaveFile/Folder. So a power outage will have no adverse effect.
I never have such problems any more since Im always use ext4...

unfortunate is that some old Puppy's do not support ext4

linuxcbon
Posts: 1312
Joined: Thu 09 Aug 2007, 22:54

#4 Post by linuxcbon »

oui wrote:I never have such problems any more since Im always use ext4...

unfortunate is that some old Puppy's do not support ext4
which ones ?

User avatar
8Geee
Posts: 2181
Joined: Mon 12 May 2008, 11:29
Location: N.E. USA

#5 Post by 8Geee »

To really solve the problem buy an Uninterruptable Power Supply for about 50 bucks, and run the desktop power supply off that. All you have time to do is shutdown a desktop (5-10 minutes) but a lappy can go on batteries, with the modem/router running off the UPS device for quite a while.

And of course one can charge a smartphone or three.

Regards
8Geee
Linux user #498913 "Some people need to reimagine their thinking."
"Zuckerberg: a large city inhabited by mentally challenged people."

wert
Posts: 258
Joined: Tue 31 Mar 2015, 21:40
Location: USA

#6 Post by wert »

8Geee wrote:To really solve the problem buy an Uninterruptable Power Supply for about 50 bucks, and run the desktop power supply off that. All you have time to do is shutdown a desktop (5-10 minutes) but a lappy can go on batteries, with the modem/router running off the UPS device for quite a while.

And of course one can charge a smartphone or three.

Regards
8Geee
Laptops aren't durable. As for smartphones, working on small screens is ineffecient for uses such as social media and other serious business. A large screen tablet should be a good replacement for your cpu monitor setup. Just make sure the RAM is enough i.e. 2Gb+. Tablets can go days without recharging

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#7 Post by Burn_IT »

Ext2 is no more resilient to power outages than any other file system.
"Just think of it as leaving early to avoid the rush" - T Pratchett

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#8 Post by Mike Walsh »

Burn_IT wrote:Ext2 is no more resilient to power outages than any other file system.
I tend to agree, actually. From all the accumulated practical wisdom on the Forum, the general view is that, if anything, ext2 will corrupt more easily, since it doesn't possess journalling capabilities.

I still reckon the best answer is regular backups every few days.....which is far simpler with the frugal Puppy.


Mike. :wink:

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

#9 Post by gyro »

The most important thing to minimise the corruption of ext filesystems is to 'fsck' them on every boot, before their first mount. The puppy "init" script can do this.
"pfix=fsck", causes "init" to fsck any "savefile" before mounting it.
"pfix=fsckp", causes "init" to fsck any ext partition before it's first mount.
If you are using a "savefolder" make susre you specify "pfix=fsckp".
To be sure, to be sure, use "pfix=fsck,fsckp"

Note: Because ext2 has no journal, every so often it will do a full check, which is very very slow.
I always use ext4 because it's fsck is fast, even on large partitions.

gyro

wert
Posts: 258
Joined: Tue 31 Mar 2015, 21:40
Location: USA

#10 Post by wert »

I recommend you use ext2 if you have low storage space e.g. small data partition or sd card with 6gb or less. Ext4 will eat alot of space and has no benefit for a random user. It's rare for a filesystem to get damaged unless it's hardware damage e.g. bad sectors on the HDD.

In my experience with real work day to day experience with the prescribed setup using a heavy encrypted ext2 filesystem, it never broke to this day. I've used it on a day to day basis for three years nonstop and it still boots my tahrpup602 in perfect condition. Also used was previously to tahrpup602 was lucid 528(make sure it's the updated one) with the same configuration. Sometimes surges occurred very frequently like 20 times per hour resulting in many poweroffs but it never broke except or lucid's pinboard getting corrupt which you can backup /root/Choices/ROX-Filer/PuppyPin and then restore if it breaks.
Unless you do stupid things like atttempting to service your desktop and then you short-circuit your HDD, my recommendation is very good.

User avatar
Ananda98
Posts: 56
Joined: Mon 03 Jul 2017, 10:04
Location: Bali, Indonesia

#11 Post by Ananda98 »

Interesting. But, will my computer stay fine, if I use ext2 partition, then load some files from hard disk (from same or another partition), or have another kind of partition mounted, then I got electricity loss?

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#12 Post by Burn_IT »

As I said,a power loss will affect any file system.
Using a mixture will not change anything for the better or worse.
If you absolutely do need a very slightly more resilient file system, then choose a journaling one, but be aware that even those will lose any data actually being transferred and will shorten the life of older flash drives and take more space.
"Just think of it as leaving early to avoid the rush" - T Pratchett

wert
Posts: 258
Joined: Tue 31 Mar 2015, 21:40
Location: USA

#13 Post by wert »

Ananda98 wrote:Interesting. But, will my computer stay fine, if I use ext2 partition, then load some files from hard disk (from same or another partition), or have another kind of partition mounted, then I got electricity loss?
Unless the other partition is NTFS type, you will not have problems. In fact, my traditional setup is to have two or three other separate partitions for storing data such as email client, browser profiles and corresponding data in ~/,cache and local backups like savefiles and pets which is easy to setup with a couple of symlinks from your other partition to the save file FS. They can be any filesystem but I love FAT32. If the other partition is NTFS, it cannot work because it will be a counter productive setup. :)

wert
Posts: 258
Joined: Tue 31 Mar 2015, 21:40
Location: USA

#14 Post by wert »

The very rare phenomena I can think of is that your save file itself gets removed by a dos.fsck filesystem check if the partition that's holding it is not a linux e.g. ext2 and doesn't have sufficient space to copy it to i.e. the free space on the filesystem is insufficient for a savefile's copy. This can occur if the filesystem is FAT. Make sure it is a linux filesystem. By the way my technique doesn't use external pen drives or sd cards. ONLY Hard Disk Drive e.g SATA, IDE etc. :twisted:

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#15 Post by Burn_IT »

I will REPEAT FOR HOPEFULLY THE LAST TIME.

A POWER OUTAGE WILL LIKELY AFFECT ALL FILE SYSTEMS.

All you can do is choose one that will be easier to recover.
"Just think of it as leaving early to avoid the rush" - T Pratchett

Gordie
Posts: 153
Joined: Tue 23 Aug 2016, 15:26
Location: Nolalu, Ontario, Canada

#16 Post by Gordie »

We live rural and experience frequent power outages. We use laptops and have the chargers plugged in so when the power fails the laptop never notices because it runs on the battery.
No corruption
--
Cheers
Gordie
Slackware64-Current, Thinkpad W510, Intel i7, 8G/500G, Lilo / Legacy.
Fatdog64 + 6 Puppies on USB flash drives.
Windows 10 / Slackware64-Current, HP desktop, Intel Core2 Duo, 4G/500G/250G, Lilo / Legacy.

wert
Posts: 258
Joined: Tue 31 Mar 2015, 21:40
Location: USA

#17 Post by wert »

Burn_IT wrote:I will REPEAT FOR HOPEFULLY THE LAST TIME.

A POWER OUTAGE WILL LIKELY AFFECT ALL FILE SYSTEMS.

All you can do is choose one that will be easier to recover.
My setup is practical. I've used my desktop for business on a day to day basis for 3 years now on an ext2 partition and the savefile being ext2 also with heavy encryption. I've never had any problem. No issues at all. Annually, the machine was used for work from 5:20am to 9:30 daily, using libreoffice, running a local xampp web server, doing bulk image processing and has hundreds non-sfs software(debs, pets, tar.gz etc.) installed such as a image magick with all librarires, codeblocks, wine, you name it.. It has never failed to boot, nor have I experienced any losses related to a powercut. In fact I've never cared to get a UPS. My bios has power management featured, allowing me to configure the desktop to power on at a set time automatically and have enabled power recovery so I no longer need to use the power button on the CPU.

Post Reply