ExtRoot: HowToBuild
Alternatives:
- In case you not want to build you own firmware, there is a separate howto for that: install extroot later on
- An alternative to ExtRoot could be to make
opkginstall new packages somewhere else: See Installation.destinations - Another one to hack the bootloader and make him boot from external device directly. See dockstar
- And yet another one to use kexec
Installation
Configuration
1. Select the prerequisites
Assuming you just started # make menuconfig and are in the build system.
The package block-extroot won't even be displayed unless you have selected a block device package in Kernel Modules. Specifically you must have either ide-core (and any other required IDE drivers), or usb-storage (and the USB host controller, such as usb-ohci), or the mmc package (and any required modules for an SD/MMC device).
You must also select the block-mount package from Base system.
As of r26314 block-extroot has been merged with block-mount. That means that once you select block-mount the scripts for extroot mounting are installed. block-mount can be used even if you have not selected a block device package, but if you want extroot behaviour you must still install the drivers (block device package) for the external root device as well as the filesystem you want to use (e.g. fat or ext4) |
If you want the filesystem to be run through a filesystem check/repair before mounting, you must also include the appropriate fsck package (.e.g. e2fsprogs which contains e2fsck for ext2/3/4 filesystems), however you are not required to have an fsck program.
You will also need the kernel modules for the filesystem format you want to use on your root filesystem. Don't forget the nls-base kernel module, if you system requires it, however neither of these are a dependency of the block-extroot package.
If you intend to partition and/or format the filesystem on a live system, so that you can use an external storage device, you will the packages required to do that in the image, or available to opkg as well.
2. Select the package
The block-extroot package was located in the disc submenu of the Utilities menu. As of r23098 block-extroot is located in the Base system menu. It has one item below, which allows to specify the 'settle time' of the of the root fs device, which is to say the amount of time to wait for the device to be recognized by the system once the modules are loaded. This is needed for USB and possibly other block device types. |
3. (Optional) Preconfigure the rootfs
NOTE At this time block-extroot does not activate until there is a valid configuration. If you are using a squashfs based filesystem it will never boot into your external rootfs on the first boot. With other filesystem types, or an upgrade of a squashfs filesystem, if there is a valid configuration in the firmware image (i.e. by placing a ./files/etc/config/fstab in your OpenWRT root directory), then it will be used on the first (and subsequent boots).
You will also need to make sure your rootfs is empty, or contains only valid files from the system you are upgrading.
see extroot.prerequisites for information on how to prepare the filesystem.
4. Build the image
e.g. make from the root directory of your OpenWRT tree.
5. Flash the image and boot
e.g. sysupgrade imagefile
6. Configure the system (if not preconfigured)
- Partition your device (if not already partitioned as you desire)
- Format the device (partition) if not already formatted
- Copy everything from /jffs (if on a squashfs and you want the current configuration and settings to be copied to the new rootfs) to the new root device (partition)
- Edit
/etc/config/fstab(as described in fstab. Also see extroot.examples for configuration examples)
7. Reboot (if not already in rootfs)
You should now be in the rootfs on your external storage device.
8. Upgrade
See extroot.system.upgrade for information on updating your extroot image. Note that for revisions before OpenWrt 10.03.1-rc4 'Backfire' you will always have to build your own image because extroot must be included in the image. After that the appropriate packages are allowed be added to the jffs2 after flashing instead of being required in the image (e.g. packages from the same snapshot as your kernel and jffs2/squashfs).
Old Notes
With extroot you will be able to easily upgrade your packages, but not be able to perform kernel update, since the kernel remains on the device flash on a read-only partition.
opkg upgrade
will not do anything anyway, since with opkg you have to name the package you want to upgrade. So to upgrade all your installed packages, you could do
opkg upgrade $(opkg list-upgradable)
DO NOT DO THAT! Since the kernel is on read-only flash partition, and all the kernel modules are on your external device, the modules will be updated, but the kernel not. You will end up with not matching kernel <> kernel-modules and your installation will not survive a reboot. To avoid that, you have to exclude all kernel-modules from being updated, for example so:
opkg upgrade $(opkg list-upgradable | awk '($1 !~ "^kmod|Multiple") {print $1}')
| Since Trunk r23173 (Backfire r23206) the kernel and kmod packages are flagged as hold. The opkg upgrade command won't attempt to update them anymore. |
| The upgrade of your kernel + kernel modules, requires much more effort… you need to first update you kernel-modules (with opkg upgrade …) and then immediately WITHOUT rebooting, reflash the kernel. Then reboot. This is not complicated at all, but the problem is, that the OpenWrt-Maintainer do not consider it necessary to include the packages required by extroot in the default images offered for download. So you cannot download the images offered here! So every time, you wish to simply upgrade your kernel and kernel modules you will have to build an image by yourself. Cumbersome. Another possibility would be to make the kernel-partition read-write. This would allow opkg to upgrade the kernel itself, too. Another one to hack the bootloader, and make him start kernel from you external device instead of the internal flash. And yet another possibility is to use kexec. |
| Actually the problem was that at the time block-extroot was experimental and not able to be added after the fact to a released image, so it was decided that block-extroot would only available if you compiled your own kernel. The poster is also mistaken in the belief that the kernel is on a real partition. The kernel mtd block device is exactly the size of the kernel, and the squashfs immediately follows. The remaining space is used for the jffs2, so as you can see, these sizes are all variable and may differ from build to build. |
doc/howtobuild/extroot.howtobuild.txt · Last modified: 2012/04/23 21:00 by valentt
