Multiple partitions on a CF / SD card

From OESF

Revision as of 13:11, 19 December 2007 by Meyer (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Setting up multiple partitions on a CF or SD card may be quite useful. For example, to flash a new ROM image to a 5000/5500 you need a FAT partition on your CF card. On the other hand, installing programs to a card often requires a partition with symbolic linking support (i.e. not FAT). With a multi-partition setup, you can have your cake and eat it too - provided your cake is big enough (at least 64 MB).

Here is a step-by-step guide for setting up two partitions on a CF or an SD card: a FAT one and an ext2 one. It is based on the excellent Step-by-step CF/SD fdisk/formatting for newbies Howto. See the bottom of this page for notes on differences in an SD setup. (Note: 3.5.3 calls the second SD partition "card1". The original instructions were for calling it "card2", so this becomes a problem when the system is rebooted. It's probably more complicated for CF cards because of the second CF that is included in the SL6000 hardware. If you know how it works, update this page.)

The 3.5.3 distribution includes the required programs fdisk and mkfs.ext2, but does not include mkfs.msdos. You can get that by installing the dosftools package.

Then, as root, type the following from the console:

   cd /root
   umount /dev/hda1  [or /dev/mmcda1 if using SD]
   fdisk /dev/hda    [or /dev/mmcda] (it will ask you for a command)
   d (this will delete a partition)
   1 (this will delete partition #1)
   n (this will create a new partition)
   p (this will create it as a Primary partition)
   1 (Choses partition 1; it will tell you the available cylinder range)
   Enter (to take default start cylinder)
   N (integer, determines partition size: 1 < N < number of cylinders on the card)
   Enter (to confirm N as end cylinder)
   v (this will verify that the partition has been created)
   t (to change partition type)
   1 (to select partition 1)
   6 (to select FAT-16)
   n (this will create a new partition)
   p (this will create it as a Primary partition)
   2 (Choses partition 2)
   Enter (to take default start cylinder which will be N + 1)
   Enter (to take default end cylinder)
   v (this will verify that the partition has been created)
   t (to change partition type)
   2 (to select partition 2)
   83 (to select ext2)
   w (this will save the table and exit the fdisk program)

When you're done with fdisk, enter one of these sets of commands depending on which card you are using:

   mkfs.msdos /dev/hda1 (this will format the 1st partition with the FAT-16 file system)
   mkfs.ext2 /dev/hda2 (this will format the 2nd partition with the ext2 file system)
   mkdir /mnt/cf2 (this will create the directory where the 2nd partition will be mounted)
   ...or... (if SD)
   mkfs.msdos /dev/mmcda1 (this will format the 1st partition with the FAT-16 file system)
   mkfs.ext2 /dev/mmcdda2 (this will format the 2nd partition with the ext2 file system)
   mkdir /mnt/card2 (this will create the directory where the 2nd partition will be mounted)

Now you need to edit /etc/fstab to associate the 2nd partition with its mount point. The /etc/fstab file should already contain a line for the first partition and it should look something like this:

   /dev/hda1     /mnt/cf   auto   defaults,noauto,noatime,user,exec,suid   0 0
   ...or... (if SD)
   /dev/mmcda1   /mnt/card   auto   defaults,noauto,noatime,user,exec,suid   0 0

Use your favorite text editor to copy and tweak that line; you should end up with:

   /dev/hda1      /mnt/cf    auto   defaults,noauto,noatime,user,exec,suid   0 0
   /dev/hda2      /mnt/cf2   auto   defaults,noauto,noatime,user,exec,suid   0 0
   ...or... (if SD)
   /dev/mmcda1    /mnt/card  auto   defaults,noauto,noatime,user,exec,suid   0 0
   /dev/mmcda2    /mnt/card1 auto   defaults,noauto,noatime,user,exec,suid   0 0

If you want programs installed to the CF card to go to the ext2 partition rather than to the FAT one (and you do want that), you need to edit /etc/ipkg.conf, changing the line

   dest cf /mnt/cf      to    dest cf /mnt/cf2
   ...or... (if SD)
   dest cf /mnt/card    to    dest cf /mnt/card2

Now the instructions get entirely different for CF and SD cards.

Here's the CF version:

Finally, you want to __ensure that both partitions get auto-mounted__ when you reboot your Zaurus or eject / re-insert the CF card. For that, you need to edit /etc/pcmcia/ide.opts. This is not the place to explain how the file works (it contains explanatory comments if you care). I'll just list what you should end up with, omitting comments for brevity:

   case "$ADDRESS" in
   *,*,*,1)
      DO_FSCK="y"
      DO_MOUNT="y"
      ;;
   *,*,*,2)
      DO_FSCK="y"
      DO_MOUNT="y"
      ;;
   *,*,*)
      PARTS="1 2"
      NO_CHECK=n
      NO_FUSER=n
      ;;
   esac

The easiest way to apply all these changes is to restart your Zaurus whichever way your ROM allows. That's that.

Here's the SD version:

   (Log in as root)
   mount -n -o remount,rw / (make the file system writable)
   cp /etc/sdcontrol /etc/sdcontrol2 (make a control file for the new partition)

Edit the file /etc/sdcontrol2 and change three adjacent lines

   DEVICE=/dev/mmcda1             to   DEVICE=/dev/mmcda2
   MOUNT_POINT=/mnt/card          to   MOUNT_POINT=/mnt/card1
   SMB_MOUNT=/home/samba/SD_Card  to   SMB_MOUNT=/home/samba/SD_Card1


Take your sd card out and then put it back in and both partitions should now mount.

Personal tools