Converting To Ext2 Sd Cards


TerryH

Still Fresh
Joined
Dec 12, 2006
Messages
8
I got quite frustrated with using a msdos/FAT filesystem on the SD card (mainly because the 8.3 filenames limit screws with directory trees created on my host machine, and in upstream packages I'm working with), so I'm trying to get my GP2X to play nicely with ext2 (that is, "Linux") filesystems.

So far, I've done the following:

1) Revised /etc/fstab to use "auto" instead of "vfat" as the filesystem type for the SD card

2) Eliminated troublesome options in fstab (something was messing it up so that "mount /mnt/sd" didn't work (I'm not quite sure what the offending option was, because I just switched to "defaults". I'll narrow it down later.)

However, it still won't automatically mount the SD card after this.

Now, I can manually mount it, using the sterm.gpu terminal utility (which I copied onto /mnt/nand so I could use it when the SD isn't mounted), by just typing:

# mount /mnt/sd

which means the fstab entry must be good. After that step, everything works as I expect it too. But of course, I don't want to have to do that every boot!

I've hitherto been assuming that the SD drive gets mounted as a result of a "mount -a" during the boot process, but it doesn't seem to come up at boot, so that must not be how it works. (?)

What am I missing?

TIA!
 
the sd getsmountet in some startup script, that probably overrides the fstab entry.
Check usr/profiles or something similar.
 
Thanks for the reply, Vimacs, though still no joy as yet.

There is an /etc/profile, which presumeably is supposed to run whenever a shell is started, but it doesn't have anything to do with mounting drives.

After a bit of grepping, I have found one explicit mount command for the SD drive, which is in the file:

/usr/gp2x/usbdisconnect.sh

Anyway, for some reason, this script uses an explicit, fully-qualified mount command instead of relying on the fstab settings (which mount should look up in /etc/fstab). I will try changing this file and re-starting.

...a half-hour later...

Okay, I've tried it. Still no joy. No detectable effects (I don't use the USB networking, so maybe that's not surprising). Still don't know what determines the automatic mounting of the SD drive.
 
Well, there's an explicit mount command for the SD drive is hard-coded in a string within the gp2xmenu binary file.

The reason for doing this appears to be to provide the "remount" option, but I couldn't be sure without seeing the source code.

However, I've fixed this by patching the binary, but it still doesn't recognize the SD drive on menu startup, so I guess I'm back to square one again.

Sigh.

It seems like this ought to be really simple: conventional distributions do this sort of thing all the time, and if the GP2X worked the same way, I'd have already set it up right (at this point, a "mount -a" command does what I want done).

gp32_console <_<
 
how about making a ext2 image file (dd if=/dev/zero of=/mnt/sd/bla.ext2 bs=1M count=%number-of-megabytes-for-filesystem%) && (mkext2fs bla.ext2) and mounting it on /mnt/ext instead?

If you wanna take the whole space in your sd, it's up to you, as soon as someone delete that file all your partition is gone, indeed...
 
It does appear that the actual mounting of the SD card is normally done by the gp2xmenu binary.

I can replace /usr/gp2x/gp2xmenu with a shell script which mounts the drive and then launches the original binary, renamed to /usr/gp2x/gp2xmenu_bin. However, that's really a kludge, so I don't really like it.

It did make me think that I should look into how /usr/gp2x/gp2xmenu gets launched.

This is actually scripted in /etc/rc.d/rc.sysinit, which does a number of maintenance tasks, then checks for various cases (I think these include at least: low battery, the presence of a firmware upgrade on the SD card) to decide if and how to launch /usr/gp2x/gp2xmenu (there are some commandline switches, including "--disable-autorun" (not sure what that controls)).

ISTM that the right way to accomplish what I want is to modify this /etc/rc.d/rc.sysinit script. Though I may also need to consider the double-partition or container-file approach mentioned above.
 
No, it isn't handled by the menu (it still works even after the menu has been killed). I have actually just discovered how to enable ext2 automounting today :)
In root's home directory there is a single shell script (start.sh?) and one of the early bits has a section on mounting a vfat type SD card. Copy this section just below it and remove the utf8 rubbish and change vfat to ext2. This will now mount an ext2 card if it is inserted upon bootup.

Now edit fstab to use the type 'auto' and again, get rid of the utf8 stuff. Now ext2 cards can be mounted on the fly, just like FAT :)

EDIT: the --disable-autorun option for the menu just prevents it running the autorun.gpu file in the root of the SD card or the root of the NAND (if such a file exists)
 
Thanks, Orkie, that's a huge help, and you've answered one of my other questions too, which was how to make a card that automatically executes. I've been wanting to set things up so I can create a "cartridge-like" experience, similar to Nintendo GameBoy or DS . I think that would be a big improvement for younger players who might find the menus and browsing the FS frustrating.

I notice that the --disable-autorun option appears to depend on battery status. In rc.sysinit, it runs a utility called "irqbattery" and decides to disable autorun if it exits with a return value of 1. I'm guessing that's probably a low-battery warning. I'm not sure I understand the reasoning for that: if it can't play the program on the SD card, is there really a lot of use in running the menu application? In my experience, when the battery is low, the system just hangs up when the menu is loading anyway.
 
If you do a true 8.3 file system you get limited to 8 character file names with 3 character extensions. I have not seen anything from a windows box do this in a long time but it is possible to do this from other systems.

TerryH: How were you formating the SD card before? With all of the work you have done the 'ext2" stuff I would not want to impair your progress because I plan to use it for some stuff I wanted to do as well. Just curious.
 
I got ext2 to mount before. I think I had to change some of the startup scripts to mount it explicitly. I think you could also try to put the mount command in autorun.gpu but on the nand
 
Oh, I imagine it's possible to format the SD with a Windows 95+ F/S that allows long filenames, though in fact, I was using a plain VFAT16 "msdos" format (which does have the 8.3 filename limit). However, even the long filename VFAT systems have unpleasant limitations, such as case insensitivity and no support for symlinks.

Since I'm targetting Linux from Linux, I don't really see why I should have to work around Windows-centric design faults. It's just simpler if the F/S I use for development matches the one on the target system. I'm working on a general system for creating Python/PyGame software for the GP2X, and I want to try to eliminate anything that might complicate things more than necessary.

OTOH, since there is apparently already an autorun system, which will work on an unmodified GP2X, I'll probably go for a dual-partition with a small VFAT partition bootstrapping a larger EXT2 system with the actual software on it. Seems simple enough, though I think it'll be a little challenging to package it so that recipients can easily create the SD card from the package (need to see if fdisk can be scripted safely, I guess).

I feel more comfortable the more I understand the system, though. Thanks for all the replies.
 
Just a warning... a lot of stuff for gp2x that reads data files from dos games expect a vfat partition, since in that mode it correctly reads everything if the filename is presented in all lowercase. I know my clonekeen doesn't work unless the data files are all lowercase, so you may have to rename files to get some things to work. Also, when making an app to distribute, make sure that all filenames are in all lowercase, else it won't work right for anyone using vfat on their sd cards.
 
another thing to be careful of is the permissions. Some files which you download may not have the execute flag set on the executable files. you have to set it otherwise the files won't run on ext2 formatted sd card
Also there is problem of unmounting cleanly on gp2x. you need o run a scrip before switching off.
 
Well, both problems can be addressed by passing mount options, I think...

I don't recall exactly, and my computer's broken so I cannot check this out, but there are some options to mount to use relaxed filesystem permissions, so filesystem will allow open A.out when there's only a.out file on that dir

Also, you can force file's permissions on a mounted filesystem, I'm quite afraid that it only applies to msdos/vfat filesystems, but I'm not sure about that and you can always chmod as you please

Both filesystems do need a clean unmount, not just ext2, but since 99% of the time gp2x's filesystems are opened on a read-only fashion (altough mounted rw) the chances of losing data is very, very little... even more if you mount it as a sync fs
 
Back
Top