Phone does not cleanly unmount ext partition?

Delphis

Well-known member
Mar 21, 2011
86
12
0
Visit site
I have noticed that even just booting the phone and then shutting it down will cause an ext filesystem to have errors. It's noticeable that I can put the card (via a USB adapter) in my laptop and have the filesystem checked and clean but do a boot and shutdown (with enough time to use apps etc.) and the filesystem is uncleanly unmounted. Anyone else experiencing this?

So, my question is.. what script(s) are run on shutdown and how do I go about putting a hook in to cleanly unmount the ext partition?

Thanks in advance
 
Last edited:

Delphis

Well-known member
Mar 21, 2011
86
12
0
Visit site
I've tried this on 2 different sd cards now and both are uncleanly unmounted. So, I guess it's time to move to ext3. I moved stuff over and while it is still uncleanly unmounted at least the journal guards against corruption. It'll wear on the sd card more, but at least it won't corrupt.
 

Delphis

Well-known member
Mar 21, 2011
86
12
0
Visit site
Does anyone know if the LG Optimus V stock rom runs a shutdown script at all? I'm trying to find where the filesystems are unmounted and not coming up with anything. Input from kernel/rom devs would be welcome!
 

picasticks

Well-known member
Feb 28, 2011
136
58
0
Visit site
I'll take a look ... I do know that the "init.d support" some ROMs have isn't fully baked like on a real Linux system, and doesn't have shutdown scripts.

One thing to do would be to watch logcat while doing a reboot. Android system doesn't seem to use same concept of runlevels as Linux, but you'd think it would be cleanly unmounting all filesystems at least. It must be doing that for the /sdcard mount since that's fat32, so there's a umount somewhere, just a matter of finding it. Anyway, I'll look. (my Android machine not around at the moment.)

A related issue is there's a Linux kernel option that adds a memory buffer for disk access. I experimented with it both on and off, to see how it improved sd/NAND read/write speed, and although there was possible improvement it wasn't significant and I opted to leave it out for precisely this reason ... unclean umounts (even if the system does a umount, there are other things like pulling battery to worry about). Anyway I know Xionia adds this buffer (it's not in the stock kernel). Off the top of my head, I think the kernel option is CONFIG_FSCACHE ... anyway that's something to check, whether your kernel is using it or not.
 

picasticks

Well-known member
Feb 28, 2011
136
58
0
Visit site
OK, so I have dug up a lot of info and am not sure where to start.

The first thing to understand is that Android system does not use a traditional UNIX rc.d init system where everything is in little scripts. If you have dug into Solaris svcadm or OS X launchd, it is more like that. (Why? it's better because it's more flexible and everything can run in parallel for speed.) Android now has a volume manager daemon called vold.

If you're familiar with the Observer pattern of object-oriented development, then what happens will make sense ... apps register as BroadcastReceivers with the system, and when the system broadcasts ACTION_SHUTDOWN, they can perform system shutdown actions.

So, one possibility is to make a tiny app that does nothing but umount your partition when this system event fires. But that seems like a lot of custom work for such a little thing ... better to try to get vold to do it.

Normally, /sdcard is the only partition managed by vold and the only one umounted before shutdown. All the yaffs2 partitions like /data and /system *aren't* cleanly umounted.

So, what you need to do is, rather than making your fs mount via the mount command (unmanaged by vold), get vold to manage the mount. Then, it *should* be cleanly unmounted automatically before shutdown. That is what I would try first.

How to do this? Well, as of froyo, the mounts are in an fstab-like file, /system/etc/vold.fstab, so hopefully it should just be a matter of adding a line to that file. Here's some info on that file (it's from Android x86, but still useful). If you look at vold.fstab on your phone, you will see it's pretty barebones. I've been building the froyo system (2.2.1) recently, so here is the friendly fully commented version:

Code:
## Vold 2.0 Generic fstab
## - San Mehat (san@android.com)
## 

#######################
## Regular device mount
##
## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...> 
## label        - Label for the volume
## mount_point  - Where the volume will be mounted
## part         - Partition # (1 based), or 'auto' for first usable partition.
## <sysfs_path> - List of sysfs paths to source devices
######################

## Example of a standard sdcard mount for the emulator / Dream
# Mounts the first usable partition of the specified device
dev_mount sdcard /mnt/sdcard auto /devices/platform/goldfish_mmc.0 /devices/platform/msm_sdcc.2/mmc_host/mmc1

## Example of a dual card setup
# dev_mount left_sdcard  /sdcard1  auto /devices/platform/goldfish_mmc.0 /devices/platform/msm_sdcc.2/mmc_host/mmc1
# dev_mount right_sdcard /sdcard2  auto /devices/platform/goldfish_mmc.1 /devices/platform/msm_sdcc.3/mmc_host/mmc1

## Example of specifying a specific partition for mounts
# dev_mount sdcard /sdcard 2 /devices/platform/goldfish_mmc.0 /devices/platform/msm_sdcc.2/mmc_host/mmc1

There is a command "vdc" which you can use to manage vold mounts at runtime. "vdc volume list" will print a list of mounted volumes. Here's a thread with a little more info. You can possibly use vdc to make/test your mount syntax before putting it into vold.fstab.

For a totally different, script-based approach, see this thread. To make it work you would need to do two things, first create an sh script to do your umounts (i.e. /system/bin/shutdown) in their example, and second register the script in one of the .rc files, like init.rc or init.thunderc.rc. (like anything in the root directory, these files live in the rootfs ramdisk which requires unpacking/repacking your boot partition image, so you will have to look that up if you haven't done it before).

vold is the new hotness, I would go with that.

worst-case, I guess you can stick with ext3/4 and let the journal sort it out.
 
  • Like
Reactions: Delphis

picasticks

Well-known member
Feb 28, 2011
136
58
0
Visit site
OK, let me know if I wasn't clear on anything. Hopefully once you get the vold.fstab syntax sorted out, the rest will automagically work.

P.S. I noticed your profile says you are running stock OS/ROM. In that case you might be interested in moving Dalvik cache from /data to /cache ... it will free up about 50 M on your /data partition.

I was actually thinking of writing up a little to tutorial to add this mod, since it's like a base feature on all the S ROMs, and I recently ported it to Harmonia for LeslieAnn so I already have the code/patch ready.

When I first joined the V forum (when I first compiled my kernel for V), I got all these questions about link2sd/app2sd, and I was like, these guys have froyo, wtf are they messing around with that old junk?

Well, I can only assume lack of this dalvik mod is the reason ... because with the mod I've got tons of apps installed (mostly natively "Moved to SD") and like 60 M still free on /data, and it never even occurred to me that /data could run out of space. But then I recently reflashed my phone to stock, and was shocked to discover I had to uninstall like half my apps to get the boot errors to stop.
 

overthinkingme

Well-known member
Feb 10, 2011
219
14
0
Visit site
OK, let me know if I wasn't clear on anything. Hopefully once you get the vold.fstab syntax sorted out, the rest will automagically work.

P.S. I noticed your profile says you are running stock OS/ROM. In that case you might be interested in moving Dalvik cache from /data to /cache ... it will free up about 50 M on your /data partition.

I was actually thinking of writing up a little to tutorial to add this mod, since it's like a base feature on all the S ROMs, and I recently ported it to Harmonia for LeslieAnn so I already have the code/patch ready.

When I first joined the V forum (when I first compiled my kernel for V), I got all these questions about link2sd/app2sd, and I was like, these guys have froyo, wtf are they messing around with that old junk?

Well, I can only assume lack of this dalvik mod is the reason ... because with the mod I've got tons of apps installed (mostly natively "Moved to SD") and like 60 M still free on /data, and it never even occurred to me that /data could run out of space. But then I recently reflashed my phone to stock, and was shocked to discover I had to uninstall like half my apps to get the boot errors to stop.

Please share? :D
I've always wondered how a2ext was not reintegrated to cm6 because of the native a2sd. Native always left me with a full data partition. Granted I have around 120 app but still.. if possible, I would like to simplify my setup.


Sent from my VM670 using Tapatalk
 

picasticks

Well-known member
Feb 28, 2011
136
58
0
Visit site
Please share? :D
I've always wondered how a2ext was not reintegrated to cm6 because of the native a2sd. Native always left me with a full data partition. Granted I have around 120 app but still.. if possible, I would like to simplify my setup.


Sent from my VM670 using Tapatalk
OK, I will write that up and top-post it.

Unfortunately, it requires editing one of the .rc files, which live in the boot partition, which means using the Linux command line to unpack and repack a boot image file. So, it will be a breeze for some people, but totally impenetrable nerd-speak for the rest.
 

Delphis

Well-known member
Mar 21, 2011
86
12
0
Visit site
OK, let me know if I wasn't clear on anything. Hopefully once you get the vold.fstab syntax sorted out, the rest will automagically work.

P.S. I noticed your profile says you are running stock OS/ROM. In that case you might be interested in moving Dalvik cache from /data to /cache ... it will free up about 50 M on your /data partition.

Well, I've been tinkering with my own script to link the dalvik cache entries to the ext partition on the SD card. I've been having some issues with it not booting up after installing some apps though. The script I'm using also symlinks the app and data directories in their entirety to directories on the ext partition as well. I'm just not sure what is happening that messes things up. It seems to be having problems with apps that like to install on the SD card the Froyo way that I then 'move to phone'. On reboot, bang, it just loops and the boot animation stops and restarts and the phone never starts up. I wish I knew what the phone was doing when it was doing that.