- How To Upgrade Debian 9 Stretch To Debian 10 Buster {safely}
- Cached
- Upgrade Debian 9 To 10
- Flashplugin-nonfree At The Debian Package Tracking System
- More Debian 9 Flash Images
How to install and boot Linux Debian on Flash storage using the JFFS2 file system.
In this video, we will see how to make a bootable USB flash drive for Debian 9 'Stretch' on Ubuntu or any other Linux distribution. Run one of these commands. Ubuntu is Debian based but is not Debian, so packages build for Ubuntu is not always available or compatible with Debian, forcing a install can brake the OS and cause a lot of trouble that people are not looking for. This are the steps: Download the last flash player from Adobe and extract somewhere. . internal (for in-system flashing in the mainboard). dummy (virtual programmer for testing flashrom). nic3com (for flash ROMs on 3COM network cards). nicrealtek (for flash ROMs on Realtek and SMC 1211 network cards). nicnatsemi (for flash ROMs on National Semiconductor DP838. network cards). nicintel (for parallel flash ROMs on Intel 10. Debian On Flash. My favourite Linux distribution is Debian, and the following description applies to Debian Etch. However the general principle on making Linux boot a JFFS2 drive can certainly be adapted for any other Linux distribution. Installing Debian.
There are already projects on that matter, like RootSync. But these currently seem to be in an early stage. So I tried out what is possible with existing Linux distributions. Here are the results:
Compact Flash drives are, compared to a hard disk, extremely low power devices. Https trackid sp 006. Of course, the price for a certain amount of storage is still much more expensive on a Compact Flash drive than on a hard disk. But if you don't need the capacity of a hard disk, you can save some energy (and money[1]) by putting all data including the operating system on a Compact Flash. The idea of the following project is to build a really low power workstation or server which would boot a standard Linux off a Compact Flash.
With an adapter, a Compact Flash can be used as a replacement for an IDE disk. However, the Flash technology allows only a limited number of write cycles for each memory cell, and most file systems have 'hot spots' which are written very frequently, which could render a flash drive unusable within short time. Therefore a technique called wear levelling is required, to distribute write access across the medium. Rumors say that this is done in the controller of the Compact Flash Cards, but I have seen this only explicitely noted in the product description for industrial grade Compact Flash cards. I am really not sure whether cheap consumer grade Compact Flash Cards also perform wear levelling. The Compact Flash Association does not mention wear levelling. There is only a 'defect managment and error correction', which, i.m.o. does not prevent defects, but merely replace bad areas after they have become faulty. When all spare sectors are exhausted, the capability of the drive to replace bad blocks eventually comes to an end, in which case the drive is defect despite of 'defect management and error correction'[2]. In order to use consumer grade cards safely, the wear levelling task can be done in software. This is where a file system like JFFS2 comes into play.
How To Upgrade Debian 9 Stretch To Debian 10 Buster {safely}
There are a couple of problems, though.
JFFS2 is designed to work only with Memory Technology Devices.
Using JFFS2 on top of Compact Flash drives is generally not recommended.
There is no obvious way to install Linux directly into a JFFS2 partition.
To overcome the first issue, a block2mtd
driver is available.
The second point is something to think about. Adding yet another layer on top of an IDE emulation on top of a flash memory storage does not increase performance. If performance is an issue (and money is not), stop reading here. Buy an industrial grade Compact Flash instead and proceed normally.
The third issue is what the remainder of this article is about. This might also be useful for really embedded solutions where flash memory is directly addressable by the CPU and does not have its own logic.
So if you want to go ahead with me, this is what you can expect:
JFFS2 adds the benefit of implicit data compression: expect the card to hold roughly double its nominal capacity.
You can use Compact Flash drives off the shelf. We will leave them formatted as
FAT
drives. The Linux file system will be inside one or more container files. If you like, you can attach the Compact Flash to any Windows box and copy these files for backup.We will have to customize the Linux boot procedure. This will give you some insights of what is going on at a stage where most users see only a progress bar.
My favourite Linux distribution is Debian, and the following description applies to Debian Etch. However the general principle on making Linux boot a JFFS2 drive can certainly be adapted for any other Linux distribution.
As mentioned above, there is no obvious way to install Linux directly into a JFFS2 partition. So we don't.
Instead, we install Linux into a separate drive, which we attach temporarly to the target. An USB disk is fine, even if the target does not know how to boot USB disks. We won't boot that installation directly. So just go ahead and install Linux onto that drive. I prefer the netinst CD, but this requires a fast internet connection.
Note |
---|
Running the install CD with |
Note |
---|
If your low-power system happens to be VIA C3 based, don't use a i686 kernel. The C3 will not run i686 code. |
Install the Compact Flash in the location where you will later boot it. This might be an adapter which makes it an IDE drive. Compact Flash drives come preformatted as FAT
drives. This is OK. Copy the kernel and the initial ram disk from your fresh Linux installation to the root directory of the compact flash. Name them vmlinuz
and initrd.img
, respectively.
We will boot the flash using Syslinux. If you can't boot your newly installed Linux yet, you can use an already working Linux (a Knoppix system running from CD is fine) to install Syslinux on the Compact Flash. Create a configuration file syslinux.cfg
on the root of the Compact Flash as follows:
Replace /dev/sda1
with the path to your (temporary) installation disk.
Install a master boot record on the flash. This can be done with the command install-mbr
. If you are using Knoppix to prepare your flash disk, this command will be already available. On a vanilla Debian, you will probably have to install the package mbr
first.
You should now be able to boot your new Linux installation, using the Compact Flash merely as an initial boot medium.
Note |
---|
If you update your kernel, don't forget to update the copies of the kernel and the initial ram disk on the Compact Flash too. |
We will later extend the boot configuration to allow to boot the system we are now installing on the flash itself.
Install the package mtd-tools
. This will provide mkfs.jffs2
.
Create an image of a size that suits your Compact Flash (and the expected final size of your Linux system). Use a command like the following:
Where empty
is the name of an empty directory. We will add files later. See below. The eraseblock
parameter should match the actual technology used on the drive - which we usually don't know in case of a Compact Flash drive. 64k might be a useful guess, but probably the setting will not be optimal. You have been warned. The pad
parameter specifies the actual size of the image. In bytes. For example a 800MB container (fitting nicely in a 1GB drive) has a size of 838860800. The size should be a multiple of the eraseblock
size (otherwise mkfs.jffs2
will round it to an apropriate value). The output parameter should point to your mounted Compact Flash drive.
Cached
If you want to keep parts of the file name space like /usr
and /var
on separate containers, you are free to to so. Just repeat the step above with other file names and sizes for the additional containers. I.m.o this only complicates things, but it is possible.
Where /media/hda1/rootfs.img
is the path where you mounted your Compact Flash drive.
If your setup requires more than one image, repeat with increasing index numbers (minor number)
Note |
---|
The size parameter (65536) must match the eraseblock parameter in mkfs.jffs2 above. |
If your setup requires more than one image, specifiy the remaining loop devices with additional block2mtd=
parameters:xxx
.. or where ever you want the flash image to appear in your file system.
Note |
---|
This might take a while, especially when the size of the drive is in the gigabyte range. |
Before populating the target flash system, install the following package:
Upgrade Debian 9 To 10
This will be required to make the Debian package manager (apt) work on the flash file system
Flashplugin-nonfree At The Debian Package Tracking System
Note |
---|
Do not populate the special directories |
Replace /var/tmp
with a link to /tmp. We will mount tmpfs
into /tmp
later:
Remove files which will later be placed on tmpfs
:
Edit /mnt/etc/fstab
to look like this:
It is now safe to unmount the Compact Flash. But before we do, we first
When Linux first boots, there is just the kernel, a boot command line, and an embryonal file system called the Initial RAM Disk. The latter is normally created by the installation procedure, and updated by system updates, but in general, we don't have to worry about much. Booting a JFFS is different. We have to teach the Initial RAM Disk new tricks. Here is how. The following requires the package initramfs-tools
. It usually comes with the installation. If you don't have it, install it now.
Create a file in /etc/initramfs-tools/hooks
with the following content. You can choose any file name, say mtdsetup
.
Make the file executable (chmod +x mtdsetup
).
The hook above just ensures that the mentioned modules and programs are included in the RAM disk. It does not cause them to be called. This must be done in init scripts. We need two of them.
Create a file in /etc/initramfs-tools/scripts/local-top
with the following content. You can choose any file name consisting of alphanumeric characters. Don't put a dash (minus) in the name! [3]
Make the script executable. It will be called during the boot process just before the root file system is mounted.
Note |
---|
The MTD emulation stuff is made conditional with a boot command line parameter |
Note |
---|
If you want to put |
Create a file in /etc/initramfs-tools/scripts/local-bottom
with the following content. You can choose any file name consisting of alphanumeric characters. Don't put a dash (minus) in the name![3]
Make the script executable. It will be called during the boot process just after the root file system has been mounted, but before it is made the root of the file system.
Note |
---|
The original mount point ( |
The last commands create an empty dmesg file to keep the boot procedure happy which tries to chown
it and complains if it is not there.
We are almost done. We now recreate the initial RAM disk using the command Catalina 32 bit.
Copy the RAM disk image to the root of the flash disk. It should be safe to replace the RAM disk image created above.
Now update syslinux.cfg:
Note |
---|
Note the |
Note |
---|
You will find messages like in the system logs. This is harmless. |
After running the system for a while, you might encounter the following problem: Dc copy format.
After a system update, the defined locales might have disappeared. The reason for this is that the program locale-gen
, which is supposed to generate new or updated locales, uses file mapping to map the file /usr/lib/locale/locale-archive
directly into memory. However file mapping does not work with a compressed file system such as JFFS2[4], and generating the locales fails.
Solution: Generate the locales manually, after replacing the directory /usr/lib/locale
with a piece of RAM disk as follows:
[1] The energy consumed by a hard disk (rated at 10W) during one year pays for a discount 2GB Flash Drive, or for a 1GB brand model.
[2] My personal experience on that matter is a memory stick which became faulty after only one year of use.
[4] For the same reason, apt
will not work when the index files are located on a JFFS2 volume.
Links for flashrom
Debian Resources:
Download Source Package flashrom:
Maintainer:
- Uwe Hermann (QA Page)
External Resources:
More Debian 9 Flash Images
- Homepage [www.flashrom.org]
Similar packages:
Identify, read, write, erase, and verify BIOS/ROM/flash chips
flashrom is a tool for identifying, reading, writing, verifying and erasingflash chips. It's often used to flash BIOS/EFI/coreboot/firmware/optionROMimages in-system using a supported mainboard, but it also supports flashing ofnetwork cards (NICs), SATA controller cards, and other external devices whichcan program flash chips.
It supports a wide range of DIP32, PLCC32, DIP8, SO8/SOIC8, TSOP32/40/48,and BGA chips, which use various protocols such as LPC, FWH, parallelflash, or SPI.
The tool can be used to flash BIOS/firmware images for example -- be itproprietary BIOS images or coreboot (previously known as LinuxBIOS) images.
It can also be used to read the current existing BIOS/firmware from aflash chip.
Currently supported programmers include:
Tags: System Administration: System Boot, Hardware Support, Field: Electronics, Hardware Enablement: hardware::TODO, implemented-in::c, User Interface: Command Line, Role: role::program, scope::utility
Other Packages Related to flashrom
|
|
|
|
- dep:libc6 (>= 2.14) [amd64]
- GNU C Library: Shared libraries
also a virtual package provided by libc6-udeb
- dep:libc6 (>= 2.17) [arm64, ppc64el]
- dep:libc6 (>= 2.7) [not amd64, arm64, ppc64el]
- dep:libftdi1-2 (>= 1.2)
- Library to control and program the FTDI USB controllers
- dep:libpci3 (>= 1:3.5.2-1) [not s390x]
- Linux PCI Utilities (shared library)
- dep:libusb-0.1-4 (>= 2:0.1.12)
- userspace USB programming library
- dep:libusb-1.0-0 (>= 2:1.0.9)
- userspace USB programming library
Download flashrom
Architecture | Version | Package Size | Installed Size | Files |
---|---|---|---|---|
amd64 | 0.9.9+r1954-1+b1 | 444.8 kB | 1,063.0 kB | [list of files] |
arm64 | 0.9.9+r1954-1+b1 | 381.1 kB | 831.0 kB | [list of files] |
armel | 0.9.9+r1954-1+b1 | 378.8 kB | 726.0 kB | [list of files] |
armhf | 0.9.9+r1954-1+b1 | 378.4 kB | 678.0 kB | [list of files] |
i386 | 0.9.9+r1954-1+b1 | 446.9 kB | 942.0 kB | [list of files] |
mips | 0.9.9+r1954-1+b1 | 384.0 kB | 774.0 kB | [list of files] |
mips64el | 0.9.9+r1954-1+b1 | 386.1 kB | 856.0 kB | [list of files] |
mipsel | 0.9.9+r1954-1+b1 | 385.3 kB | 778.0 kB | [list of files] |
ppc64el | 0.9.9+r1954-1+b1 | 385.2 kB | 899.0 kB | [list of files] |
s390x | 0.9.9+r1954-1+b1 | 378.0 kB | 831.0 kB | [list of files] |