This page contains information about work to add support to partition MTD flash in Debian installer.

Outline for future work

Try existing work

GNU Parted

This is possible to do on an ordinary desktop machine, with nandsim no real MTD is needed.

Download and build the work done on GNU Parted.

Create a 256 MB simulated NAND with the nandsim linux kernel module.

modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa \
                 third_id_byte=0x00 fourth_id_byte=0x15

Also load the mtdchar linux kernel module

modprobe mtdchar

Run parted (with superuser privileges) on the created character device

sudo parted
GNU Parted 1.9.0.89-751b-dirty
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

Select the device (/dev/mtd0 in this example)

(parted) select /dev/mtd0
Using /dev/mtd0

Create a loop label on the device (WARNING! DO NOT DO THIS ON REAL FLASH, IT WRITES TO THE MEMORY WHICH IS PROBABLY REALLY DANGEROUS!!!)

(parted) mklabel loop
(parted) print
Model: nand NAND simulator partition 0 (mtd)
Disk /dev/mtd0: 256MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End  Size  File system  Flags

Monolithic hackish ISO

ISO

Download monolithic Debian installer image from http://sigsucc.se/mtd/mini.iso .

Screenshots

Screenshots of current work and necessary Debian installer patches are available at http://sigsucc.se/mtd/ .

Build it yourself

GNU Parted

Install automake from sid.

(If it does not work then download, build, and install automake 1.11, and symlink $PREFIX/share/aclocal-1.11/pkg.m4 to /usr/share/aclocal/pkg.m4.)

wget ftp://ftp.gnu.org/gnu/automake/automake-1.11.tar.gz
tar zxf automake-1.11
cd automake-1.11
./configure
make
sudo make install

Clone the Parted git repository and update the git submodules

git clone git://git.debian.org/users/avtobiff-guest/parted.git
git submodule init
git submodule update

Check out the next-mtd branch

git checkout next-mtd

bootstrap, configure, and build

cd parted
./bootstrap
./configure
make
sudo make install

Try it out!

Monolithic hackish ISO

Get dependencies and source

Checkout Debian installer

In order to build it yourself do a checkout of Debian installer.

svn co svn://svn.debian.org/svn/d-i/trunk debian-installer

Custom kernel

Compile a kernel with UBI and UBIFS support.

CONFIG_MTD_UBI=m
CONFIG_UBIFS_FS=m
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=n # Could not zlib compression symbols for some reason.

Also add nandsim kernel module for testing with simulated NAND.

CONFIG_NAND_NANDSIM=m

Build the kernel as documented in DebianInstaller/Modify/CustomKernel

In the source package linux-kernel-di-2.6 (read how to modify Debian installer with custom kernel) add the following files in order to include mtd, ubi and nandsim.

cd linux-kernel-di-2.6*
echo <<EOF >>package-list
Package: lzo-modules
Depends: kernel-image, core-modules

Package: mtd-modules
Depends: kernel-image, core-modules

Package: nand-modules
Depends: kernel-image, core-modules, mtd-modules

Package: nandsim-modules
Depends: kernel-image, core-modules, nand-modules

Package: ubi-modules
Depends: kernel-image, core-modules, nand-modules, crc-modules

Package: ubifs-modules
Depends: kernel-image, core-modules, mtd-modules, ubi-modules, lzo-modules, zlib-modules, crc-modules
EOF
echo lzo >modules/i386/lzo-modules
(echo mtd
 echo mtdblock
 echo mtdchar ) >modules/i386/mtd-modules
echo nand >modules/i386/nand-modules
echo nandsim >modules/i386/nandsim-modules
echo ubi >modules/i386/ubi-modules
echo ubifs >modules/i386/ubifs-modules

Now build the kernel udebs (build the package).

Partman UBI

Main module partman-ubi is available in git.

Clone and build:

git clone git://git.debian.org/avtobiff-guest/partman-ubi.git
cd partman-ubi
git-buildpackage

liblzo2 udeb

Creating udeb of liblzo2 (build dependency for MTD utils).

Clone and build:

git clone git://git.debian.org/avtobiff-guest/lzo2.git
cd lzo2
git-buildpackage

MTD utils

MTD utils, udeb is needed to manage UBI.

Clone and build:

git clone git://git.debian.org/avtobiff-guest/mtd-utils.git
cd mtd-utils
git-buildpackage

nandsim udeb

For convenience I have added a simple script which loads the nandsim module and creates a 256 MB NAND flash.

Clone and build

git clone git://git.debian.org/avtobiff-guest/nandsim-auto.git
cd nandsim-auto
git-buildpackage

Finish

Copy all resulting udebs from the steps above to debian-installer/installer/build/localudebs/.

Building

Patch with patches to Debian installer to enable building with a custom kernel, make partman handle MTD and UBI, and pinning the custom udebs for inclusion in the d-i build process.

Patch with Debian installer patch blob

cd debian-installer
wget http://sigsucc.se/mtd/patches/d-i-blob.patch
patch < d-i-blob.patch

Build partman-base and copy to localudebs for inclusion

cd packages/partman/partman-base
dpkg-buildpackage -rfakeroot -us -uc
cp ../*udeb ../../installer/build/localudebs

Make sure that installer/build/preferences.udeb.local pins the udebs to the version supplied in installer/build/localudebs. Also make sure that every package listed in installer/build/pkg-lists/local is supplied in installer/build/localudebs.

Build monolithic image

fakeroot make rebuild_monolithic

Finally run the resulting monolithic image (in KVM for instance)

kvm -cdrom debian-installer/installer/build/dest/monolithic/mini.iso \
    -boot d -redir tcp:8080::80 -no-reboot