Using the Block Device

For development and testing purposes it may be useful to use the underlying block front-end device driver in order to read data from, or write data to an external disk image file. This documentation provides clear instructions on how to configure Stardust to be compiled with support for a rudimentary file system that uses the block device.

Creating the disk image

The first step is to create an adequate disk image file that can be used by Stardust. Please follow these instructions:

Create a file which is occupied with zeros

$ dd if=/dev/zero of=disk.img count=512 bs=1M
This will create a disk image file, but you can change the configuration to alter the size as needed.

Create a partition

$ fdisk disk.img
By executing the above command, a number of questions will be presented in your terminal and the following example shows how to typically answer these questions:
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognised partition table.
Created a new DOS disklabel with disk identifier 0x71862b73.
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x4573e6f5.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-1048575, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-1048575, default 1048575):
Created a new partition 1 of type 'Linux' and of size 511 MiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): b
Changed type of partition 'AIX bootable' to 'W95 FAT32'.
Command (m for help): w
The partition table has been altered.
Synching disks.

Create the file system disk image

$ mkfs.vfat disk.img
Following the execution of the above command, the disk image file will be ready for use.

Populating the disk image with some data

If you would like to populate the disk image with some data, you can simply mount the disk image in a local directory, insert data into it and then demount it. In order to mount the disk image you need to execute the following steps for example:
$ mkdir mnt
$ sudo mount disk.img mnt
Now you can create or copy files in the location where the disk image has been mounted.
Similarly you can demount the disk image using the following command:
$ sudo umount mnt

Configuring and building Stardust

In order to configure Stardust's build system to compile the kernel with the front-end block device driver and support for a rudimentary file system you will need to:
  • Modify the kernel's configuration header file config.h by enabling the labels defined to support both the block front-end device driver and the file system
  • Clone the software packages repository which contains the source code of the file system library and set its path correctly in the Makefile of the operating system
Once these steps have been performed you can compile Stardust by executing make.
Please note that the file system library contains simple tests for reading files from or writing files to the file disk image.