Embedded System Ramdisk from USB
Sometimes it is convenient to boot an embedded System without a network. For example shipping one to customers for factory tests.
Documentation only valid for acc7.
pendrive
requires an USB Pendrive, any size will do and root permissions on a linux system.
Connect pendrive, run parted to create a boot and a localinit partition.
root@host# parted /dev/sdb
(parted) mklabel msdos
(parted) mkpart primary fat32 2048s 512M
(parted) set 1 boot on
(parted) print
Model: (scsi)
Disk /dev/sdb: 1992MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 512MB 511MB primary fat32 boot, lba
create filesystems:
root@host# mkfs.vfat -n BOOT /dev/sdb1
syslinux
Install syslinux and the bootsector (Where is the bootsector? rpm -ql syslinux-nonlinux)
root@host# syslinux -i /dev/sdb1
root@host# cat /usr/share/syslinux/mbr.bin > /dev/sdb
now mount
/dev/sdb1
somewhere. it will contain an ldlinux.c32 and ldlinux.sys.
ramdisk
Create a ramdisk from opkg packages that contains the localinit package. Sample config
arch="x86_64"
kernel="linux-scu"
packages=(
"localinit"
"libxml2"
"$kernel-modules"
)
password=XXX
Copy kernel and initramfs to /dev/sdb1
Add a
syslinux.cfg
(in the /dev/sdb1 filesystem)
DEFAULT default
LABEL default
KERNEL kernel
APPEND initrd=initramfs
network
the default embedded network script is still executed. It will request an ip via dhcp. If no ip is received within 30 seconds, the system will reboot.
This can be configured via kernel commandline parameters. Either specify a kernel ip config (ip=...) or dhcp=TIMEOUT:PANIC_TIMEOUT. Where timeout is the number of seconds to wait for an ip and panic_timeout the number of seconds before a system reset is executed. A panic_timeout of zero disables the reset.
for example the following
syslinux.cfg
DEFAULT default
LABEL default
KERNEL kernel
APPEND initrd=initramfs dhcp=30:0
localinit
if the localinit package is included. On boot the system will try to mount a partition with label "BOOT". If you followed the partitioning guide above, it is the same partition as the ramdisk. Note that windows only displays the first partition on a pendrive. The location of the overlay filesystem can be customized using a kernel parameter localinit to either specify a device or a filesystem label. For example
LABEL sda
KERNEL kernel
APPEND initrd=initramfs localinit=/dev/sda4
LABEL foobar
KERNEL kernel
APPEND initrd=initramfs localinit=LABEL=foobar
The file
/opt/localinit/overlay.tar.gz
will be unpacked over the ramdisk. And the file
/opt/localinit/overlay.sh
will be copied to
/etc/init/boot.d/99-overlay
and executed. This should make it possible to use a vfat filesystem on the overlay partition, as all posix attributes are in the tarball.
Replacing uid/gid during tarball creation
cd overlay; tar cvzf ../overlay.tar.gz --owner=0 --group=0 *.
For an example disk image that can be written to a pendrive see
EmbeddedRamdiskUSB