Cacko HDD fix (v0.1) -- for SL-C3100 and SL-C3200 only

Created by: zdevil (dvmDOTzaurusATgmailDOTcom)
Last updated: 2008-03-28

Content:
I.   What this scriptpack does
II.  Source
III. How to use
IV.  How to restore the factory HDD partitions
V.   Appendix


=============================
I. What this scriptpack does
=============================
This scriptpack changes the booting process of Cacko ROM
by removing the requirement of the presence of hdd1 (ext3), 
hdd2 (ext3) and hdd3 (FAT32) on the internal disk, such
that the internal disk is freed to run other distros (e.g.
Debian, OpenBSD, pdaXrom/pdaXii, Angstrom, Android, etc.)
in any partition. 

Note: This install.sh is safe to run repeatably. Each time 
the system files will be backed up with a timestamp
attached to the end of the ".bak" extension and will be 
saved in the "backups/" directory.


==========
II. Source
==========
This hack is based on the "Cacko Patch" for OpenBSD/Zaurus 
done by mathemajikian, which can be found at 

http://mersenne.homeunix.net/zaurusforums/viewtopic.php?p=7#7

I make use of the procedure and the modified system files
there and incorporate them into an automatized script, 
with some minor changes (mainly removing the BSD bits and
adding backups).


===============
III. How to use
=============== 
Step 1 Boot the Zaurus into the "Linux Emergency" console.
  a) Remove all power sources and flip the battery lock to
     the left;
  b) Wait about 10 seconds; 
  c) Press and don't release the [D] and [B] keys; 
  d) Put back the battery and flip the battery lock back to 
     the right; 
  e) Power on (with [D] and [B] still being pressed);
  f) When the prompt shows up, login in as "root". 

Step 2 Copy and extract the script pack to the root
of a SD/CF card.

Step 3 Insert the card to the card slot and it will be
mounted automatically.

Step 4 Type "cd /mnt/card/cackofix" (SD) or 
"cd /mnt/cf/cackofix" (CF) and 
hit [Enter].

Step 5 Type "./install.sh" and hit [Enter].

Step 6 Wait until the process finishes. Then reboot. 

That's it.


=============================================
IV. How to restore the factory HDD partitions
=============================================
Both Sharp ROM and Cacko ROM for the C3x00 series 
have the requirement that the internal disk have at least 
these three partitions:

/dev/hda1 (ext3, at least 9.5M)
/dev/hda2 (ext3, at least 9.5M)
/dev/hda3 (FAT32, using the rest of the disk space)

Note: More paritions can follow /dev/hda3

If you really want to restore the disk to this factory 
state, please follow this procedure:

Step 1:
Use a disk partition tool, preferably fdisk or parted 
(commandline) or gparted (GUI) to create partition as 
described above. See the Appendix for the commands used.

Step 2:
Create the necessary directories on hdd1 and hdd2

# mkdir /mnt/hdd1
# mkdir /mnt/hdd2
# mount /dev/hda1 /mnt/hdd1
# mount /dev/hda2 /mnt/hdd2
# mkdir /mnt/hdd1/lost+found
# mkdir /mnt/hdd1/.sys
# mkdir /mnt/hdd2/lost+found
# mkdir /mnt/hdd2/.sys

Step 3:
Copy the files in "cackofix/hdd_tool" as follows:
 
# cd /mnt/card/cackofix/hdd_tool 
(or /mnt/cf/cackofix/hdd_tool) 
# cp -r hdd1sys/* /mnt/hdd1/.sys/
# cp -r hdd2sys/* /mnt/hdd2/.sys/

Step 4:
# umount /mnt/hdd1
# umount /mnt/hdd2
# rmdir /mnt/hdd1
# rmdir /mnt/hdd2

That's it. Reflash Sharp ROM or Cacko ROM and things 
will revert back to the original state.


Side dish :-)
-------------
A "tune2fs" binary is included in "hdd_tool/". 

You can use it to convert an existing ext2 partition to 
an ext3 one, while keeping the data in the partition intact. 
The conversion process is simply a matter of creating/adding 
a journal to an existing ext2 partition.  

You can also run this binary as a standalone rescue tool 
in the "Linux Emergency" console.

To convert from ext2 to ext3 on /dev/hda (for example),
simply run this command:

# tune2fs -c 0 -i 30 -j /dev/hda1


==================================================
V. Appendix: Commands for restoring the partitions
==================================================
To create entirely new partitions on the disk, which 
WILL WIPE OUT ALL THE DATA, run the following commands 
(hit [Enter] after each line; ignore the "#" symbol).

# umount /mnt/cf
# fdisk /dev/hda
# d
# 1
# d
# 2
# d
# 3
# n
# p
# 1
# (hit [Enter] once)
# +9.5M
# n
# p
# 2
# (hit [Enter] once)
# +9.5M
# n 
# p
# 3
# (hit [Enter] once)
# (enter any appropriate value/size and hit [Enter])
# t
# 1
# 83
# t
# 2
# 83
# t
# 3
# b
# p (double check the partition info)
# w
# mke2fs -j /dev/hda1
# mke2fs -j /dev/hda2
# mkfs.vfat -F 32 /dev/hda3


For questions, discussions, corrections, please
post in http://www.oesf.org/forum .

Have fun!

zdevil

