Creating a Debian Root Filesystem on a Compact Flash


The following contains the steps required to build a Debian root filesystem for the BEE2 or for other Virtex2 Pro boards such as the ML300 or XUP. The following assumes that you have a machine that is running Linux, although Cygwin might work (although this has not been tested). Many of the details were taken from work done at UIUC and BYU. You may refer to these pages for more details, and we thank them for their excellent work.

Partition the Compact Flash/Microdrive

You will need a fairly large CF or Microdrive to hold the root filesystem. The standard 1GB IBM Microdrive will work fine, and for CF you should have at least a 512MB card. The first task is to partition the CF. We need at least three partitions:

The easiest way to partition the CF is to simply use a USB to CF reader. I believe that the PCMCIA based readers that come with the IBM microdrives are a bit faster, but we find the USB readers to be more flexible. When you insert the USB reader into your linux machine you should see something like the following if you run dmesg:

scsi29 : SCSI emulation for USB Mass Storage devices
  Vendor: General   Model: Flash Disk Drive  Rev: 2.05
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sda: 2104704 512-byte hdwr sectors (1078 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
 /dev/scsi/host29/bus0/target0/lun0: p1
Attached scsi removable disk sda at scsi29, channel 0, id 0, lun 0
USB Mass Storage device found at 35

The key line is SCSI device sda: 2104704 512-byte hdwr sectors (1078 MB) which tells us that the device is /dev/sda. Now we can partition the disk by running fdisk:

# fdisk /dev/sda

Next delete any existing partitions (follow the prompts given by fdisk). Now we can create the three partitions. The first one should be a FAT16 partitions whose size should be anywhere from 20MB to 100MB, basically the size you think you'll need to hold all your ACE files. Most people will simply have a small 20-30MB partition large enough to hold one configuration:

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-522, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): +20M

Follow the same example for the next two partitions. Make the second partition (the swap) between 64-128MB and make the root partition take up the rest of the drive. Now that the partitions are created we need to change the type on them. The first partition must be made type FAT16:

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 6
Changed system type of partition 1 to 6 (FAT16)

Change the second partition in a similar fashion to swap (type 82). Now save the new partition table by entering w.

Format the Partitions

The SystemACE chip that is used on the BEE2 requires special formatting options to properly read the files on the FAT16 partition. Once you have acquired a CF card you need to format it using the following command (assuming you are in Linux):

mkdosfs -s 2 -F 16 -R 1 /dev/sda1  (16MB CF)
mkdosfs -s 8 -F 16 -R 1 /dev/sda1  (128MB CF)
mkdosfs -s 16 -F 16 -R 1 /dev/sda1 (256MB/512MB CF)
mkdosfs -s 64 -F 16 -R 1 /dev/sda1 (1GB CF)

We have tested all of these parameters on CFs at Berkeley, however they may not be right for your particular CF. More information can be found in the XUP documentation (search for "mkdosfs"). You can also download "mkdosfs" for Windows which should be run with the same options (the only difference is "/dev/sda1" would be replaced with "DRV:/" where DRV is the driver letter of the CF). Next setup the swap partition by running:

# mkswap /dev/sda2

Finally create the root file system by running:

# mkfs.ext3 /dev/sda3

We use the EXT3 journalled file system because it is more robust than EXT2, especially since there is a propensity to reboot the board running Linux without a proper shutdown. You can use EXT2 or any other file system you like as well. You might also want to change the default fschk behavior for the partition, as it will often force a check when you boot due to time discrepancies. Be warned that this is generally not advised as it will prevent automatic filesystem checks and could lead to corruption. To change the check behavior run:

# tune2fs -i 0 -c 0 /dev/sda3

Fast Root Installation

The fastest way to get a root filesystem on your CF is to simply download a copy of our pre-generated base system found rootfs.tar.gz (careful, its about 75MB). We also describe how to generate this image by hand, however this currently requires a PowerPC running Debian (we use a Mini). Unless you are doing something special, the prebuilt image should be fine.

Once you have downloaded the image somewhere convenient, mount the CF by executing:

# mount /dev/sda3 /mount/point/

Then untar the root file system by doing:

# tar -C /mount/point/ -zxvf rootfs.tar.gz

You should now run sync and be prepared to wait as the files are actually sync'd to disk. If you don't want to do any more customization on the root you can unmount:

# umount /mount/point/

Root Customization

It is a good idea to add any packages you may need and edit the configuration files before you try to boot a V2P system. The first step is to chroot the file system and then mount proc:

:/mount/point# chroot /mount/point
:/# mount -t proc proc /proc
:/# umount /proc
:/# exit

The only package installed in our pre-built base system is the devfsd package required to properly mount devfs. The pre-built system uses a Berkeley mirror for APT, which you might want to change to a closer one. Do this by running base-config or editing /etc/apt/sources.list. Some good things to install include ssh (apt-get install ssh), ntpdate (apt-get install ntpdate), and gcc (apt-get install gcc).

Installing System ACE files

The final step before you can boot your new system is to install a System ACE file on the FAT16 partition so the board can boot. You can find a set of example bitstreams with standard, failsafe, and test suite for the BEE2 in To put the bitstreams on the CF you need to run the following:

# mount -t vfat /dev/sda1 /mount/point
# unzip -d /mount/point
# sync
# umount /mount/point

The sync above is not strictly necessary, but remember, to wait for umount to return before taking the CF out or you will have corrupted data. Alternatively in Windows simply open the mounted CF (it will only mount the FAT16 partition which holds the configuration bitstreams) and copy the contents of the zip file to the CF. Remember to properly unmount the card before removing or you may loose some of the bits.

You are now ready to boot Debian.

Bee2DebianRootFs (last edited 2006-06-26 16:21:27 by alschult)