Author Topic: Moving to SD... again.  (Read 10527 times)

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« on: February 05, 2004, 09:48:29 am »
Well, I have a 256Mb SD card and use it with 2 partitions, /usr and /opt on each one. I prefer this to symlink to /mnt/card, since some packages delete the symlinks and create a dir in their place, and all gets broken.

I\'m using OZ 3.3.6-pre1, and already created the two partitions on the SD card and mounted them as /mnt/card1 and /mnt/card2.

My partitions divide the sd card in half.

I wrote a script to do the changes and altered /etc/sdcontrol and /etc/fstab to mount the two partitions as /usr and /opt.

The card partitions should be mounted as /mnt/card1 and /mnt/card2, and the new sdcontrol version should be in the same dir as the script.

sdcontrol:
Code: [Select]
#!/bin/sh

#

# sdcontrol 1.0 2001/8/8 21:33:19 (Hideki Hayami)

# edited 2004/02/05 13:43 (Bruno Santos)

# Initialize or shutdown a SD card device

#

# The first argument should be either \'insert\' of \'eject\'.

#

# NOTE: Since we use the SD card as /usr and /opt we can\'t eject it

# So, some of this script functions will be disabled.

ACTION=$1

DEVICE1=/etc/dev/mmcda1

MOUNT_POINT1=/opt

DEVICE2=/etc/dev/mmcda2

MOUNT_POINT2=/usr



case "$ACTION" in

\'insert\')

    fsck  $MOUNT_POINT1

    mount $MOUNT_POINT1

    fsck  $MOUNT_POINT2

    mount $MOUNT_POINT2

    MOUNT_RES = `mount | grep $DEVICE1`

    # If the mount via fstab fails, force it

    if [ "$MOUNT_RES" = "" ]; then

         mount $DEVICE1 $MOUNT_POINT1

    fi

    MOUNT_RES = `mount | grep $DEVICE2`

    if [ "$MOUNT_RES" = "" ]; then

         mount $DEVICE2 $MOUNT_POINT2

    fi

     ;;

\'eject\')

# Do nothing

      true

     ;;

\'compeject\')

# Do nothing

      true

     ;;

\'change\')

# Do nothing also

      true

     ;;

\'*\')

      exit 1

     ;;

esac



exit 0


sdcardstuff.sh:
Code: [Select]
#!/bin/sh

#

# Put together by bluey[at]netcabo[dot]pt

#

# Move /usr and /opt to SD card and make the sd card mount earlier.

# Based on daniel@steen-family.com script to boot from the sd card

# found in http://www.openzaurus.org/oz_website/faq/faq?id=192 and

# "Moving all of /usr to SD" from

# http://www.linux-migration.org/ch05s10s05s06.html



# Take care of busybox command links

echo -n "Creating some busybox command links in /bin: "

for cmd in [ tail cut test dc; do

 ln -s /bin/busybox /bin/$cmd

done

for cmd in /usr/bin/* /usr/sbin/*; do

 [ /bin/busybox -ef $cmd ] && ln -sf /bin/busybox $cmd

done

echo "done."



# Create the sd first partition device somewhere else

echo -n "Creating mmcda1 and mmcda2 in /etc/dev: "

mkdir /etc/dev

mknod /etc/dev/mmcda1 b 60 1

mknod /etc/dev/mmcda2 b 60 2

echo "done."



# Copy /opt/* to the first sd card partition

echo "Copying /opt/* to the first partition"

echo -n "of the sd card (this will take a while): "

cp -a /opt/* /mnt/card1/

echo "done."



# Copy /usr/* to the second sd card partition

echo "Copying /usr/* to the second partition"

echo -n "of the sd card (this will take a while): "

cp -a /usr/* /mnt/card2/

echo "done."



# Unmount the first sd card partition

echo -n "Unmouting the first sd card partition: "

umount /mnt/card1

echo "done."



# Unmount the second sd card partition

echo -n "Unmouting the second sd card partition: "

umount /mnt/card2

echo "done."



# Copy the new sdcontrol script to /etc

echo -n "Copying the new sdcontrol script to /etc: "

rm -f /etc/sdcontrol

cp sdcontrol /etc

echo "done."



# Change the sd card attributes, device and mount point in fstab

echo "Updating fstab with the new devices"

echo -n "and mount points for the sd card partitions: "

cat /etc/fstab | grep -v mmcda > /tmp/fstab

echo "/etc/dev/mmcda1 /opt auto defaults,noatime 0  0" >> /tmp/fstab

echo "/etc/dev/mmcda2 /usr auto defaults,noatime 0  0" >> /tmp/fstab

rm -f /etc/fstab

mv /tmp/fstab /etc

echo "done."



# Delete /opt contents

echo -n "Deleting /opt contents(may take a while): "

rm -rf /opt/*

echo "done."



# Delete /usr contents

echo -n "Deleting /usr contents(may take a while): "

rm -rf /usr/*

echo "done."



# Mount the sd card partitions in their new locations

echo -n "Mounting the first sd card partition in /opt: "

mount /opt

echo "done."

echo -n "Mounting the second sd card partition in /usr: "

mount /usr

echo "done."



# Make the sd card mount earlier

echo -n "Changing the sd boot order so the /usr is available at boot time: "

mv /etc/rcS.d/S01devices /etc/rcS.d/S04devices

ln -s /etc/init.d/sd /etc/rcS.d/S02sd

echo "done."



# Erase the sd card reference from the ipkg script

echo -n "Updating the ipkg configuration to not show the sd card: "

cat /etc/ipkg.conf | grep -v /mnt/card > /tmp/ipkg.conf

rm -f /etc/ipkg.conf

mv /tmp/ipkg.conf /etc

echo "done."



echo "Finished, you can now reboot your zaurus."



I\'m testing everything now, as for the sdcontrol, I believe a true call in the actions that won\'t be done should do the trick, but still haven\'t see if it works well like that.

I hope someone finds this useful.


Have a wonderful day!
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #1 on: February 06, 2004, 06:22:55 am »
I guess this has no interest...


Either way, here is a shorter version of the script which remakes everything without copying /usr and /opt all again. Easily deductable from the first

Code: [Select]
#!/bin/sh

#

# Put together by bluey[at]netcabo[dot]pt

#

# Move /usr and /opt to SD card and make the sd card mount earlier.

# Based on daniel@steen-family.com script to boot from the sd card

# found in http://www.openzaurus.org/oz_website/faq/faq?id=192 and

# "Moving all of /usr to SD" from

# http://www.linux-migration.org/ch05s10s05s06.html

 

# Take care of busybox command links

echo -n "Creating some busybox command links in /bin: "

for cmd in [ tail cut test dc; do

 ln -s /bin/busybox /bin/$cmd

done

for cmd in /usr/bin/* /usr/sbin/*; do

 [ /bin/busybox -ef $cmd ] && ln -sf /bin/busybox $cmd

done

echo "done."

 

# Create the sd first partition device somewhere else

echo -n "Creating mmcda1 and mmcda2 in /etc/dev: "

mkdir /etc/dev

mknod /etc/dev/mmcda1 b 60 1

mknod /etc/dev/mmcda2 b 60 2

echo "done."

 

# Copy the new sdcontrol script to /etc

echo -n "Copying the new sdcontrol script to /etc: "

rm -f /etc/sdcontrol

cp sdcontrol /etc

echo "done."

 

# Change the sd card attributes, device and mount point in fstab

echo "Updating fstab with the new devices"

echo -n "and mount points for the sd card partitions: "

cat /etc/fstab | grep -v mmcda > /tmp/fstab

echo "/etc/dev/mmcda1 /opt auto defaults,noatime 0  0" >> /tmp/fstab

echo "/etc/dev/mmcda2 /usr auto defaults,noatime 0  0" >> /tmp/fstab

rm -f /etc/fstab

mv /tmp/fstab /etc

echo "done."



 

# Delete /opt contents

echo -n "Deleting /opt contents(may take a while): "

rm -rf /opt/*

echo "done."

                                                                                                                                

# Delete /usr contents

echo -n "Deleting /usr contents(may take a while): "

rm -rf /usr/*

echo "done."

                                                                                                                                

# Mount the sd card partitions in their new locations

echo -n "Mounting the first sd card partition in /opt: "

mount /opt

echo "done."

echo -n "Mounting the second sd card partition in /usr: "

mount /usr

echo "done."

                                                                                                                                

# Make the sd card mount earlier

echo -n "Changing the sd boot order so the /usr is available at boot time: "

mv /etc/rcS.d/S01devices /etc/rcS.d/S04devices

ln -s /etc/init.d/sd /etc/rcS.d/S02sd

echo "done."

                                                                                                                                

# Erase the sd card reference from the ipkg script

echo -n "Updating the ipkg configuration to not show the sd card: "

cat /etc/ipkg.conf | grep -v /mnt/card > /tmp/ipkg.conf

rm -f /etc/ipkg.conf

mv /tmp/ipkg.conf /etc

echo "done."

                                                                                                                                

echo "Finished, you can now reboot your zaurus."


Whatever.


Have a wonderful day!
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Moving to SD... again.
« Reply #2 on: February 06, 2004, 06:55:55 am »
Quote
I guess this has no interest...

Not to me, but it does look useful for those who want to stick stuff on their SD cards. Don\'t become disheartened.


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

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #3 on: February 06, 2004, 07:11:26 am »
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

stormer

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • http://
Moving to SD... again.
« Reply #4 on: February 06, 2004, 12:56:18 pm »
You know when you run the SECOND smaller script after accidentally saving it over the first one, and when you reboot you can\'t login and have to reflash. Nobody round here would be that stupid  :oops:

Sigh - reflash 47 it is - same problem so maybe I didn\'t mix up the scripts earlier !
- looks like either the SD card is not being mounted early enough or that the data on it is corrupt.

A screen full of inode errors followed

- login prompt followed by SH -ERROR cannot find lib-curses when you try to log in.

This was on a freshly flashed 5600 with 3.3.6Pre-1, 256M sandisk SD partitioned half and half with /mnt card1 & /mnt/card2 created
C3100   - Cacko with PDAXRom and OZ pretensions !

5600 - 255, 256m & 1G Sandisk SD, Wizgo 802.11b, Pocketop irk, bluemonkey BT, Watapon, OZ 3.5.3 Henteges, with a sprinkling of pocketworkstation - depending on the weather !

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #5 on: February 06, 2004, 01:18:50 pm »
I\'m getting the same...

Have you already understand what could be wrong?

Where do we activate boot script \"debug\" mode? Is there a quiet trigger which can be changed? Pipes to /dev/null which can be removed? I can\'t seem to find where the init output is silenced...

Are you using bash? I get that by just adding bash to the current setup. I recover my last setup, then add bash, and get that problem... :
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #6 on: February 06, 2004, 01:59:28 pm »
I traced the problem to happen just by linking sh to bash... I believe that when scripts call /bin/sh they expect it to work, and it doesn\'t since bash need curses, so nothing works! Curses libs copied to /lib could do the trick.

Or using /usr/bin/bash as root\'s shell, that would make it as the default shell for root, and leave busybox\'s sh for the boot scripts.
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

genxweb

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • http://www.genxweb.net
Moving to SD... again.
« Reply #7 on: February 08, 2004, 10:11:46 pm »
hum anyone have issues using the open zaurus shell script to move the os to the sd card and run it from it. Mine seems never to boot after a full shutdown. DOes this script you write leave the main system on the zaurus and just use the sd card for the app folders ?

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #8 on: February 08, 2004, 10:46:39 pm »
Did you notice the bash issues? If you use bash as your shell, /bin/sh is a link to it, and it shouldn\'t, since if libncurses is not present, bash which needs it, won\'t work, and though the init scripts may use /bin/sh as their interpreter, they\'re trying to use bash which doesn\'t work due to the lack of libncurses. You can copy the libraries to /lib or mantain sh as a link to busybox and leave /bin/bash and use that in /etc/passwd as the root/user (whichever you use) shell.

If you try to login when it doesn\'t boot does it complain about missing libncurses?

I hope I could help you.

Have a nice day
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

Anonymous

  • Guest
Moving to SD... again.
« Reply #9 on: February 08, 2004, 11:08:49 pm »
just sites there syas booting but i think it is cause of something with knoquer browser. I installed just the os reboot 10 times no issues installed knoquer from feed reboot dead.

Is there a way to leave the whole os on the machine ram and just move the folder that I need to run and install apps to the sd card making the best use of system speed and storage

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #10 on: February 08, 2004, 11:52:00 pm »
Maybe the best way to do that could be installing the applications to the SD card. Did you tried to go that way? The application folder is where system applications also are, so you can\'t move only some folder to the SD as you say. Maybe if you transformed the all OS to separate the system from the applications, and you could define if an application is supposed to stay with the system or can go to another folder. With some tweaking that could be achieved. /usr for system /<put something logical here> as another /usr root dir for other applications...

But I can\'t look at that right now, I\'m doing a work for university, which I have to deliver tuesday, and it\'s 5 am.

I have the intention to look at the Z rootfs and see if I can make something better of it, it is too noodled to be easy to improve. /usr /opt, libs everywhere binaries too, argh...

Good luck to solve your problems!

Be well.
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

stormer

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • http://
Moving to SD... again.
« Reply #11 on: February 09, 2004, 08:36:13 am »
Which libaries would you recommend copying, just wondering if I just copy libncurses to /lib, would I get more errors for other libs, may as well get them all in one go !
C3100   - Cacko with PDAXRom and OZ pretensions !

5600 - 255, 256m & 1G Sandisk SD, Wizgo 802.11b, Pocketop irk, bluemonkey BT, Watapon, OZ 3.5.3 Henteges, with a sprinkling of pocketworkstation - depending on the weather !

Anonymous

  • Guest
Moving to SD... again.
« Reply #12 on: February 09, 2004, 09:07:14 am »
Thanks

stormer

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • http://
Moving to SD... again.
« Reply #13 on: February 09, 2004, 12:21:10 pm »
Copied the libncurses file from /usr/lib to /lib and recopied it to the name of the libncurses link on /usr/lib. Everything is working  - nice one Bluey, you hero of the Zaurus nation !

I almost miss all of those link errors when installing stuff  -NOT  :-D
C3100   - Cacko with PDAXRom and OZ pretensions !

5600 - 255, 256m & 1G Sandisk SD, Wizgo 802.11b, Pocketop irk, bluemonkey BT, Watapon, OZ 3.5.3 Henteges, with a sprinkling of pocketworkstation - depending on the weather !

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
Moving to SD... again.
« Reply #14 on: February 09, 2004, 12:27:24 pm »
I went the other way around, I unistalled bash, and copied the binary to /bin/bash, then edited /etc/passwd to use /bin/bash instead of /bin/sh. That way you still can use it as your shell, you can call it in your scripts (as long as /usr is already mounted) , and there would be no problems while booting.

Either way, I guess libncurses would be enough.


Good luck, and feel free to ask for help.

(/me is listening to Community Service from The Crystal Method, quite a nice set of TCM style remixes, would fit great on NFS Underground, good old Wipeout, or any other fast racing game.  )


Have a wonderful day, and have a lot of fun playin\' with your Z!
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...