mirror of
https://github.com/adron-s/mtik_initrd_hacks.git
synced 2025-12-10 07:44:40 +01:00
minimize initrd size: remove busybox from initrd and use for_ftp_uload busybox
This commit is contained in:
parent
056325ac6e
commit
0b4adc91e1
26 changed files with 61 additions and 29 deletions
|
|
@ -15,7 +15,7 @@ busybox and then launch the telnetd service. To run Linux kernel with modified i
|
|||
uses the standard RouterBOOT ability - loading via the network using dhcp/bootp and tftp
|
||||
server. dhcp/bootp server can be deployed on another device with RouterOS and OpenWRT or
|
||||
even tftp32 program. For a one-time launch with tftp, You can use this commands in RouterOS:
|
||||
|
||||
|
||||
/system/routerboard/settings/set boot-device=try-ethernet-once-then-nand
|
||||
/system/reboot
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ For Developers:
|
|||
cd ./finder
|
||||
./Build.sh
|
||||
cd ..
|
||||
edit ./globals.sh and set your target device ARCH: arm or mips
|
||||
edit ./globals.sh and set your target device ARCH: aarch64 or arm or mips
|
||||
./unpack-npk.sh ./ros/routeros-mipsbe-6.45.6.npk
|
||||
./unpack-kernel.sh
|
||||
cd ./init
|
||||
|
|
@ -65,3 +65,6 @@ For Developers:
|
|||
Upload content of ./for_ftp_upload/pub/* to target RouterOS device via FTP(to /pub or /flash or ...)
|
||||
Put ./bins/kernel-new.elf to your tftp and Netboot from it
|
||||
telnet x.x.x.x 22111
|
||||
|
||||
If you want to boot the modified kernel from a flash drive, then place it in the /flash/boot dir:
|
||||
nc x.x.x.y 1111 > /flash/boot/kernel
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,3 +1,3 @@
|
|||
binary files from routeros arm64 7.1rc4!
|
||||
binary files from routeros arm64 7.2rc1!
|
||||
routeros needs armv7 compiler!
|
||||
In fact, the entire user space in it is still use 32bit!
|
||||
In fact, the entire user space in it is still use 32bit!
|
||||
|
|
|
|||
BIN
cpio-fs-arm/init
BIN
cpio-fs-arm/init
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
binary files from routeros arm 6.44!
|
||||
binary files from routeros arm 7.2rc1!
|
||||
|
|
@ -1 +0,0 @@
|
|||
busybox скомпилен вот тут: /home/prog/openwrt/switch/mikrotik-tools-master/busybox-arm-soft-float
|
||||
Binary file not shown.
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
HOST="172.20.1.1"
|
||||
HOST="127.0.0.1"
|
||||
USER="admin"
|
||||
PASS=${FTP_UPLOAD_PASS}
|
||||
[ -z ${PASS} ] && {
|
||||
[ -z ${PASS} ] && [ ${HOST} != "127.0.0.1" ] && {
|
||||
echo "just do# export FTP_UPLOAD_PASS=xYz"
|
||||
exit 1
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ FILE=./bins/kernel-new.elf
|
|||
FAKEFNAME="linux_t1.bin"
|
||||
[ "$HOST" = "127.0.0.1" ] && {
|
||||
cat $FILE > /var/lib/tftpboot/$FAKEFNAME
|
||||
echo "$FILE > /var/lib/tftpboot/$FAKEFNAME"
|
||||
exit 0
|
||||
}
|
||||
ftp -inv $HOST << EOF
|
||||
|
|
|
|||
20
globals.sh
20
globals.sh
|
|
@ -4,9 +4,9 @@
|
|||
#
|
||||
|
||||
#rb5009
|
||||
TARGET_ARCH="aarch64"
|
||||
#TARGET_ARCH="aarch64"
|
||||
#rb3011(ipq806x), rb450dx4(ipq401x)
|
||||
#TARGET_ARCH="arm"
|
||||
TARGET_ARCH="arm"
|
||||
#ath79, ramips
|
||||
#TARGET_ARCH="mips"
|
||||
|
||||
|
|
@ -19,10 +19,14 @@ TOOLS_BINS_PREFIX="openwrt-linux"
|
|||
}
|
||||
|
||||
[ ${TARGET_ARCH} = "arm" ] && {
|
||||
OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x
|
||||
export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.4.0_musl_eabi
|
||||
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x
|
||||
#export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.4.0_musl_eabi
|
||||
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq4xxx
|
||||
#export STAGING_DIR=${OPENWRT_DIR}/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.4.0_musl_eabi
|
||||
GCC=arm-linux-gnueabi-gcc
|
||||
OBJDUMP=arm-linux-gnueabi-objdump
|
||||
OBJCOPY=arm-linux-gnueabi-objcopy
|
||||
LD=arm-linux-gnueabi-ld
|
||||
}
|
||||
|
||||
[ ${TARGET_ARCH} = "mips" ] && {
|
||||
|
|
@ -31,7 +35,7 @@ TOOLS_BINS_PREFIX="openwrt-linux"
|
|||
export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl
|
||||
}
|
||||
|
||||
GCC=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-gcc
|
||||
OBJDUMP=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objdump
|
||||
OBJCOPY=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objcopy
|
||||
LD=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-ld
|
||||
#GCC=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-gcc
|
||||
#OBJDUMP=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objdump
|
||||
#OBJCOPY=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objcopy
|
||||
#LD=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-ld
|
||||
|
|
|
|||
41
init/init.c
41
init/init.c
|
|
@ -7,9 +7,11 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
void my_system(char *cmd, char *arg1, char *arg2, char *arg3){
|
||||
void my_system(char *cmd, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
char *new_argv[] = { cmd, arg1, arg2, arg3, NULL };
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
|
|
@ -21,8 +23,23 @@ void my_system(char *cmd, char *arg1, char *arg2, char *arg3){
|
|||
waitpid(pid, NULL, 0);
|
||||
}
|
||||
|
||||
static void do_chmod(const char *fname, int perm)
|
||||
{
|
||||
int fd;
|
||||
fd = open(fname, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
printf("do_chmod(): can't set permissions: %d to file: %s\n",
|
||||
perm, fname);
|
||||
return;
|
||||
}
|
||||
printf("Making %s executable\n", fname);
|
||||
fchmod(fd, perm);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static char *work_dirs[ ] = { "/flash/rw/disk/pub", "/flash/rw/disk/flash/rw/disk/pub", NULL };
|
||||
void daemonized_OWL(void){
|
||||
void daemonized_OWL(void)
|
||||
{
|
||||
int a = 0;
|
||||
int ret = 0;
|
||||
static char bin_busybox[128];
|
||||
|
|
@ -46,17 +63,17 @@ void daemonized_OWL(void){
|
|||
printf("work_dir found at: '%s'\n", work_dir);
|
||||
snprintf(bin_busybox, sizeof(bin_busybox), "%s/OWL/bin/busybox", work_dir);
|
||||
snprintf(owl_sh, sizeof(owl_sh), "%s/OWL.sh", work_dir);
|
||||
if(stat(bin_busybox, &sb) == 0 && !(sb.st_mode & S_IXUSR)){
|
||||
printf("Making %s executable\n", bin_busybox);
|
||||
my_system("/bin/busybox", "chmod", "777", bin_busybox);
|
||||
if(stat(bin_busybox, &sb) == 0) {
|
||||
if (sb.st_mode & S_IXUSR))
|
||||
do_chmod(bin_busybox, 777);
|
||||
my_system(bin_busybox, "sh", owl_sh, work_dir);
|
||||
}
|
||||
if(stat(owl_sh, &sb) == 0)
|
||||
my_system("/bin/busybox", "sh", owl_sh, work_dir);
|
||||
//my_system("/bin/busybox", "rm", "-Rf", "/flash/rw/disk/pub/OWL");
|
||||
//my_system("/bin/busybox", "ls", "-l", "/flash/rw/disk/flash/rw/disk");
|
||||
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh");
|
||||
//my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub");
|
||||
//my_system("/bin/busybox", "--help", NULL);
|
||||
//my_system(bin_busybox, "sh", owl_sh, work_dir);
|
||||
//my_system(bin_busybox, "rm", "-Rf", "/flash/rw/disk/pub/OWL");
|
||||
//my_system(bin_busybox, "ls", "-l", "/flash/rw/disk/flash/rw/disk");
|
||||
//my_system(bin_busybox, "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh");
|
||||
//my_system(bin_busybox, "ls", "-l", "/system/flash/rw/disk/pub");
|
||||
//my_system(bin_busybox, "--help", NULL);
|
||||
//my_system("/order", "--help", NULL);
|
||||
sleep(1);
|
||||
}
|
||||
|
|
|
|||
BIN
owl/bin/busybox
Executable file
BIN
owl/bin/busybox
Executable file
Binary file not shown.
BIN
owl/init
Executable file
BIN
owl/init
Executable file
Binary file not shown.
BIN
owl/oldinit
Executable file
BIN
owl/oldinit
Executable file
Binary file not shown.
1
owl/readme.txt
Normal file
1
owl/readme.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
binary files from routeros arm 7.2rc1!
|
||||
|
|
@ -18,4 +18,9 @@ ${OBJCOPY} --update-section initrd=./bins/kernel-new.combo ./bins/kernel.elf ./b
|
|||
#cat ./bins/kernel-new.elf > /var/lib/tftpboot/linux_t1.bin
|
||||
|
||||
#now update busybox for current ARCH
|
||||
cat ./cpio-fs-${TARGET_ARCH}/bin/busybox > ./for_ftp_upload/pub/OWL/bin/busybox
|
||||
BUSYBOX_FOR_ARCH="./busyboxes/${TARGET_ARCH}/busybox"
|
||||
if [ -f ${BUSYBOX_FOR_ARCH} ]; then
|
||||
cat ${BUSYBOX_FOR_ARCH} > ./for_ftp_upload/pub/OWL/bin/busybox
|
||||
else
|
||||
echo "Error: No busybox for TARGET_ARCH: ${TARGET_ARCH} !!!"
|
||||
fi
|
||||
|
|
|
|||
BIN
ready-kernels/kernel-new-7.2b1-arm64.elf
Executable file
BIN
ready-kernels/kernel-new-7.2b1-arm64.elf
Executable file
Binary file not shown.
BIN
releases/7.2rc1-arm64.zip
Normal file
BIN
releases/7.2rc1-arm64.zip
Normal file
Binary file not shown.
1
work/rb5009/ros/rootfs/dev/fd
Symbolic link
1
work/rb5009/ros/rootfs/dev/fd
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/proc/self/fd
|
||||
1
work/rb5009/ros/rootfs/dev/log
Symbolic link
1
work/rb5009/ros/rootfs/dev/log
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/rw/log
|
||||
Loading…
Add table
Reference in a new issue