site  contact  subhomenews

Booting from a Flash drive

April 12, 2009 — BarryK
There have been various reports that when Puppy is booted off a USB hard drive or a solid-state hard drive, PUPMODE gets set to 12, meaning that there is no tmpfs layer in the layered filesystem, which in turn means that all file read/write is direct to the USB media.

When Puppy is running with a tmpfs top layer, that is, in RAM, PUPMODE is 13.

The solution for this has been there all along, just set the boot parameter "pmedia=usbflash". This will cause the 'init' boot script to treat the boot media as a Flash drive, rather than a "usbhd".

However, there is a problem with internal Flash drives. Puppy has been running these in PUPMODE 12. One step that I took in Puppy 4.1.2 was to mount a tmpfs on /tmp, but you might want the writes to be further constrained to the Flash drive to prolong its life.

I have modified the 'init' script so that if you have an explicit boot parameter "pmedia=ataflash" then Puppy will run in PUPMODE 13. If you don't have any boot parameter for "pmedia" then the default behaviour of the 'init' script will be to detect the boot media as a normal hard drive and run in PUPMODE 12.

Here are the overrides in the 'init' script in the case of PUPMODE=12:

 12) #4=${DISTRO_FILE_PREFIX}-xxx.sfs found, 8=${DISTRO_FILE_PREFIX}save.2fs found.  total=12

DRVSAVE="`echo -n "$PUPSAVE" | cut -b 1-3`"
REMOVABLEDRVSAVE="`cat /sys/block/$DRVSAVE/removable`"
[ "$REMOVABLEDRVSAVE" = "1" ] && PUPMODE=13 #`expr $PUPMODE + 1`
[ "$PMEDIA" = "usbflash" ] && PUPMODE=13
[ "$PMEDIA" = "ataflash" -o "$PMEDIA" = "ideflash" ] && PUPMODE=13 #w019 constrain writes to internal flash drv.

There are three overrides. Note that the kernel will detect a USB Flash drive as removable, but not a USB hard drive. So any USB drive that behaves just like a hard drive will not have the 'removable' flag set.

Note also, the early Intel Classmate baby laptops have an internal USB Flash drive. It is actually a USB drive, just happens to be on the motherboard. In that case it would be appropriate to use "pmedia=usbflash".


Username: dogone
This comes as very good news, as we are bound to see more eSATA drives and hybrid USB/eSATA "sticks". USB3 is also out there somewhere. I wonder if the improved handling of SSDs in latest kernels suggests that flash appropriate PMODE setting could be automated.

Tags: woof