Multiple partitions on a CF / SD card

From OESF

(Difference between revisions)
Jump to: navigation, search
Current revision (13:11, 19 December 2007) (edit) (undo)
m (fix wiki link syntax)
 

(12 intermediate revisions not shown.)

Line 1:

Line 1:

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).
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 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.
+
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.)
-
First download fdisk from http://www.killefiz.de/zaurus/showdetail.php?app=205 and install it. Try not to install it to the card you want to work with :-) Then, '''as root, type the following from the terminal''':
+
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
cd /root
-
umount /dev/hda1
+
umount /dev/hda1 [or /dev/mmcda1 if using SD]
-
fdisk /dev/hda (it will ask you for a command)
+
fdisk /dev/hda [or /dev/mmcda] (it will ask you for a command)
d (this will delete a partition)
d (this will delete a partition)
1 (this will delete partition #1)
1 (this will delete partition #1)
n (this will create a new partition)
n (this will create a new partition)
p (this will create it as a Primary partition)
p (this will create it as a Primary partition)
-
1 (Choses partition 1)
+
1 (Choses partition 1; it will tell you the available cylinder range)
Enter (to take default start cylinder)
Enter (to take default start cylinder)
N (integer, determines partition size: 1 < N < number of cylinders on the card)
N (integer, determines partition size: 1 < N < number of cylinders on the card)

Line 31:

Line 33:

w (this will save the table and exit the fdisk program)
w (this will save the table and exit the fdisk program)
-
When you're done with fdisk, enter:
+
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.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)
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)
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''' (/mnt/cf2). The /etc/fstab file should already contain a line for the first partition and it should look something like this:
+
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
/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:
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/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
+
/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
'''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
+
dest cf /mnt/cf to dest cf /mnt/cf2
 +
...or... (if SD)
 +
dest cf /mnt/card to dest cf /mnt/card2
-
to
+
Now the instructions get entirely different for CF and SD cards.
-
dest cf /mnt/cf2
+
'''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:
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:

Line 74:

Line 87:

The easiest way to apply all these changes is to restart your Zaurus whichever way your ROM allows. That's that.
The easiest way to apply all these changes is to restart your Zaurus whichever way your ROM allows. That's that.
-
'''The routine for SD cards''' is very much the same as far as I'm aware (I don't actually have an SD card so feel free to supply any practical experience). Simply replace /dev/hda1 with /dev/mmcda1, /dev/hda2 with /dev/mmcda2, /mnt/cf2 with /mnt/card2 and "dest cf" with "dest sd". Otherwise follow the instructions as outlined above.
+
'''Here's the SD version:'''
-
 
+
-
Corrections are welcome.
+
-
 
+
-
When doing this on a sd card everything is about the same but the last part. I found it easier to do this.
+
-
Log in as root.
+
-
su
+
-
make the file system writable
+
-
mount -n -o remount,rw /
+
-
copy a file and rename it
+
-
cp /etc/sdcontrol /etc/sdcontrol2
+
-
I then had to edit the first file at the end.
+
-
 
+
-
. /etc/sdcontrol2
+
-
exit 0
+
-
 
+
-
 
+
-
open the file /etc/sdcontrol2 and change two values.
+
-
 
+
-
original
+
-
/etc/sdcontrol
+
-
DEVICE=/dev/mmcda1
+
(Log in as root)
-
MOUNT_POINT=/mnt/card
+
mount -n -o remount,rw / (make the file system writable)
-
SMB_MOUNT=/home/samba/SD_Card
+
cp /etc/sdcontrol /etc/sdcontrol2 (make a control file for the new partition)
-
/etc/sdcontrol2
+
Edit the file /etc/sdcontrol2 and change three adjacent lines
-
DEVICE=/dev/mmcda2
+
DEVICE=/dev/mmcda1 to DEVICE=/dev/mmcda2
-
MOUNT_POINT=/mnt/card2
+
MOUNT_POINT=/mnt/card to MOUNT_POINT=/mnt/card1
-
SMB_MOUNT=/home/samba/SD_Card
+
SMB_MOUNT=/home/samba/SD_Card to SMB_MOUNT=/home/samba/SD_Card1
-
I
+
-
Pop your sd card out and then back in and both partitions should now mount.
+
Take your sd card out and then put it back in and both partitions should now mount.

Current revision

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