Author Topic: Different Filesystems On Same Sd Card  (Read 3366 times)

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« on: January 07, 2005, 10:09:45 pm »
Hi all. I saw a thread recently where a poster mentioned that he/she had two diferent partitions on his/her sd card, one fat & one ext2/3. I want to keep my card 'doze read/writeable to make copying files easier, but I'd love to be able to have part of it's 1GB of space available to install programs. and if 'doze can't touch the program part, all the better.

So I'm thinking of have two partitions, one 200MB ext2/3 & one 800MB FAT for mp3's, etc. Good idea? How? What tools do I use to partition & format (never done that under linux before)? Any better ideas?

thanks
GROG!

MrSquishy

  • Full Member
  • ***
  • Posts: 159
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #1 on: January 07, 2005, 10:35:15 pm »
Fdisk should help you out.
A real Fdisk, not a windows one.

Download yourself a copy of Knoppix if you dont have a linux box.
It'll come in handy for other stuff too.

You should be able to drop your card in a card reader and run
fdisk /dev/sda
on it.

There was some info a while back (Maybe on oz.org?) about doing some freaky voodoo to get windows to see the whole disk with an EXT2 partition on it.


I PMed you with some other info.

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Different Filesystems On Same Sd Card
« Reply #2 on: January 08, 2005, 06:51:25 am »
fdisk is in the OZ feed so you can do it all from your Z.


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #3 on: January 08, 2005, 11:35:02 am »
Quote
Fdisk should help you out. A real Fdisk, not a windows one.
Thanks for the extra tips. You are correct that I have a card reader (a jumpdrive, kinda handy), but I'd prefer to learn how to do it from linux, though. One of these days I'll get around to partitioning my xp pc so I can spend some time with linux again. It's been a while.

Quote
fdisk is in the OZ feed so you can do it all from your Z.i
Thanks you two. I should have thought of that. It's just another type of disk, after all.  For some reason I was thinking it would be harder than that.

And afer I get the partitions set up, what next? IIRC it's mkfs, right? In another thread here if found the e2fsprogs-mke2fs & dosfstools packages, so now I have mkfs.ext[23] & mkfs.vfat. That should be all I need, right?

So now the last question (that I can think of right now :^>). EXT2 or EXT3? Which should it be? I've heard that 2 is less overhead, but 3 has better error handling. If I'm right, which is better for the Z?

thanks
GROG!

MrSquishy

  • Full Member
  • ***
  • Posts: 159
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #4 on: January 08, 2005, 04:27:41 pm »
Ext3 is a journalling file system, which is usually better because it keeps things tidy if you lose power or your computer goes down.

However, that journal will tear through your SD cards maximum read/writes much faster than an ext2 system.

I use ext2 on my SD cards and havent had (m)any problems.

You may want to check your /etc/fstab to make sure it is mounting the file system that you want.

/dev/mmcda1 vs /dev/mmcda2

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #5 on: January 08, 2005, 05:22:00 pm »
Quote
I use ext2 on my SD cards and havent had (m)any problems.

You may want to check your /etc/fstab to make sure it is mounting the file system that you want.

/dev/mmcda1 vs /dev/mmcda2
Good enough for me. Thanks again.
GROG!

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #6 on: February 05, 2005, 12:39:45 pm »
Hi all. I finally got back around to setting my card up & now I have an 800M fat partition & a 200M ext2. Pretty cool. But the only thing is that even though I put an entry into /etc/fstab the second partition isn't mounted automatically when I (re)insert the card.

Code: [Select]
root@grond:~# cat /etc/fstab
/dev/mtdblock2  /       jffs2   rw,noatime      1  1
/dev/mtdblock3  /home   jffs2   defaults,noatime        1  2
proc            /proc   proc    defaults        0  0
/dev/hda1       /mnt/cf auto    defaults,sync,noauto    0  0
/dev/mmcda1     /mnt/card       auto    defaults,sync,noauto    0  0
/dev/mmcda2     /mnt/card1      auto    defaults,sync,noauto    0  0
tmpfs           /var    tmpfs   defaults        0  0
# tmpfs         /mnt/ram        tmpfs   defaults        0  0
I know that the 'noauto' options are what's preventing it from being on boot. But I figured out that the /etc/sdcontrol script is what controls the mounting of the card, right? But before I go ahead & edit this script, is there a better way to go about this? thks
GROG!

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #7 on: February 09, 2005, 08:39:54 pm »
In case anybody else is interested, here's my hack of the /etc/sdcontrol script to allow mounting of multiple partitions on a sd card. Just add the entries to the /etc/fstab. Seems to work for me. Comments? HTH

Code: [Select]
#!/bin/sh
#
# sdcontrol 1.0 2001/8/8 21:33:19 (Hideki Hayami)
#
# Initialize or shutdown a SD card device
#
# The first argument should be either 'insert' of 'eject'.
#
# 2005-02-09 GROG! (grog@paunix.org) Mount all sd card filesystems listed in /etc/fstab unless specified otherwise

# set -x # TESTING

ACTION=$1
[ $# -gt 0 ] && shift

DEVICE=/dev/mmcda1
MOUNT_POINT=/mnt/card
SMB_MOUNT=/home/samba/SD_Card
INSTALL_DIR=Documents/Install_Files
#FSTYPE="-t vfat"
FATOPTS="-o noatime,quiet,umask=000,iocharset=utf8"
EXT2OPTS="-o noatime"

###### for QPE ######
get_pid()
{
    echo $1

}

wait_release()
{
    MOUNT_POINT_WAIT=$MOUNT_POINT
    count=1
    while true
    do
        umount $MOUNT_POINT_WAIT
        if [ $? = 0 ]; then
            #echo umount >> /tmp/sd
            return
        fi
        echo count=$count >> /tmp/sd
        if [ `expr $count \>= 500` = 1 ]; then
            #echo time out >> /tmp/sd
            return
        fi
        count=`expr $count + 1`
        usleep 200000
    done
}

kill_task()
{
    DEVICE_KILL=$DEVICE
    ps_line=`ps ax | grep 'qpe$'` # no -w on busybox
    qpe_pid=`get_pid $ps_line`
    #echo qpe_pid = $qpe_pid >> /tmp/sd
    target_pids=`fuser -m $DEVICE_KILL | cut -d : -f2`
    #echo $target_pids >> /tmp/sd
    if [ "$target_pids" = "" ]; then
        return
    fi
    is_exist_qpe=`echo $target_pids | grep $qpe_pid` # no -w on busybox
    if [ "$is_exist_qpe" = "" ]; then
        kill -9 $target_pids
        #echo kill -9 $target_pids >> /tmp/sd
    else
        #echo "found qpe!!!" >> /tmp/sd
        target_pids=`echo $target_pids | sed -e "s/$qpe_pid//"`
        if [ "$target_pids" != "" ]; then
            kill -9 $target_pids
            #echo kill -9 $target_pids >> /tmp/sd
        fi
        wait_release
        exit 0
    fi
}
###### for QPE ######

mount_card_func() {

# set -x

    case "$ACTION" in
    'insert')
            mount $FSTYPE $FATOPTS $DEVICE $MOUNT_POINT
        MOUNT_RES=`mount | grep $DEVICE`
        if [ "$MOUNT_RES" = "" ]; then
                mount $FSTYPE $EXT2OPTS $DEVICE $MOUNT_POINT
        fi
        MOUNT_RES=`mount | grep $DEVICE`

        if [ "$MOUNT_RES" = "" ]; then
                mount $FSTYPE $DEVICE $MOUNT_POINT
        fi
        chkmntsh ${MOUNT_POINT}
        if [ -d $SMB_MOUNT ]; then
                rm -rf $SMB_MOUNT
        fi
        ln -s $MOUNT_POINT $SMB_MOUNT
        mkdir -p $MOUNT_POINT/$INSTALL_DIR
            #echo mount $? >> /tmp/sd
          ;;
    'eject')
            umount $MOUNT_POINT
            if [ $? -eq 0 ]; then
                rm $SMB_MOUNT
            else
                exit 1
            fi
          ;;
    'compeject')
            is_mount=`mount | grep $DEVICE`
            if [ "$is_mount" = "" ]; then
                    exit 0
            fi
            kill_task       # for QPE
            #fuser -k -m $DEVICE > /dev/null
            umount $MOUNT_POINT
            if [ $? != 0 ]; then
                    usleep 500000
                    umount $MOUNT_POINT
                    #echo umount $? >> /tmp/sd
            #else
            #        echo umount >> /tmp/sd
            fi
                rm $SMB_MOUNT
          ;;
    'change')
            $0 compeject
            $0 insert
          ;;
    '*')
            exit 1
          ;;
    esac

} # mount_card_func


if [ $# -eq 0 ]; then
    # mount all filesystems from /etc/fstab
    while read fstab_line; do
        set -- $fstab_line
        case $1 in *mmcda*)
            DEVICE=$1
            MOUNT_POINT=$2
            FATOPTS="-o $4"
            mount_card_func
        esac
    done < /etc/fstab
else
    DEVICE=$1
    MOUNT_POINT=$2
    mount_card_func
fi

exit 0

And here's a copy of my /etc/fstab

Code: [Select]
/dev/mtdblock2  /       jffs2   rw,noatime      1  1
/dev/mtdblock3  /home   jffs2   defaults,noatime        1  2
proc            /proc   proc    defaults        0  0
/dev/hda1       /mnt/cf auto    defaults,sync,noauto,noatime    0  0
/dev/mmcda1     /mnt/card       auto    defaults,sync,noauto,noatime    0  0
/dev/mmcda2     /usr/local      auto    defaults,sync,noauto,noatime    0  0
tmpfs           /var    tmpfs   defaults        0  0
# tmpfs         /mnt/ram        tmpfs   defaults        0  0
« Last Edit: February 09, 2005, 08:40:22 pm by grog »
GROG!

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Different Filesystems On Same Sd Card
« Reply #8 on: February 10, 2005, 06:22:52 am »
FWIW I had to add 'umask=000' options to both of the card filesystems lines in my /etc/fstab to allow non-root users write access.
GROG!