#!/bin/sh
#update images for x86_64
#git clone https://github.com/torvalds/linux.git --depth=1 --verbose
#cd linux #-------
#make defconfig
#cp arch/x86/configs/x86_64_defconfig .config
#modify some config option
#make -j8 bzImage
#cd .. #-------
#enable env
#source ~/Documents/tools/env_setup.sh
#source ~/Documents/tools/env_setup.sh
export PATH=$PATH:/home/dev/Documents/dev/buildroot/output/host/bin/
export ARCH=arm
export CROSS_COMPILE=arm-imx6ull-linux-gnueabihf-
#create filesystem from busybox src
rm -rf initramfs busybox
rm -f initramfs.cpio.gz
git clone https://git.busybox.net/busybox.git --verbose --depth=1
cd busybox #-------
make defconfig
sleep 5
#rm -rf _install
#cp .config.old .config
#sed '43d' .config
#sed '864,865d' .config
sed -i '43i CONFIG_STATIC=y' .config
sed -i '864i # CONFIG_FEATURE_ETC_NETWORKS is not set' .config
sed -i '865i # CONFIG_FEATURE_ETC_SERVICES is not set' .config
make -j24
make && make install
ls _install -al
cd .. #-------
#create rcS file
echo "#!/bin/sh" >> rcS
echo "echo -e "=============================="" >> rcS
echo "echo -e " === Welcome to ==="" >> rcS
echo "echo -e " === My mini ==="" >> rcS
echo "echo -e " === Linux ==="" >> rcS
echo " uname -a" >> rcS
echo "echo -e "=============================="" >> rcS
echo " " >> rcS
echo " " >> rcS
echo " " >> rcS
echo "PATH=/sbin:/bin:/usr/sbin:/usr/bin" >> rcS
echo " " >> rcS
echo "LD_LIBRARY_PATH=\$LD_LIBRARY_PATH/lib:/usr/lib" >> rcS
echo " " >> rcS
echo "export PATH LD_LIBRARY_PATH runlevel" >> rcS
echo " " >> rcS
echo " " >> rcS
echo " " >> rcS
echo "mount -a" >> rcS
echo " " >> rcS
echo "mkdir /dev/pts" >> rcS
echo " " >> rcS
echo "mount -t devpts devpts /dev/pts" >> rcS
echo " " >> rcS
echo " " >> rcS
echo " " >> rcS
#echo "echo /sbin/mdev >/proc/sys/kernel/hotplug" >> rcS
echo " " >> rcS
echo "mdev -s" >> rcS
#end create rcS
chmod 777 rcS
#create inittab
echo "::sysinit:/etc/init.d/rcS" >> inittab
echo "::respawn:~/bin/sh" >> inittab
echo "::askfirst:~/bin/sh" >>inittab
echo "::ctrlaltdel:/bin/umount -a -r" >> inittab
chmod 755 inittab
#create fstab
echo "proc /proc proc defaults 0 0" >> fstab
echo "tmpfs /tmp tmpfs defaults 0 0" >> fstab
echo "sysfs /sys sysfs defaults 0 0" >> fstab
chmod 755 fstab
echo 'current path: $pwd'
mkdir initramfs
cd initramfs
pwd
cp ../busybox/_install/* -rf ./
mkdir dev sys tmp mnt
mkdir -p home/miniuser
mkdir -p proc/sys/kernel/hotplug
mkdir -p etc/init.d/
ls -la
pwd
#echo "dev" | sudo -S -a /dev/{null,console,tty,tty1,tty2,tty3,tty4} dev/
#echo "dev" | sudo -S cp -a /dev/{null,console,tty,tty1,tty2,tty3,tty4} dev/
echo "dev" | sudo -S cp -a /dev/null dev/
echo "dev" | sudo -S cp -a /dev/console dev/
echo "dev" | sudo -S cp -a /dev/tty dev/
echo "dev" | sudo -S cp -a /dev/tty1 dev/
echo "dev" | sudo -S cp -a /dev/tty2 dev/
echo "dev" | sudo -S cp -a /dev/tty3 dev/
echo "dev" | sudo -S cp -a /dev/tty4 dev/
ls -al dev/
rm -f linuxrc
#create init file
echo "#!/bin/busybox sh" >> init
echo "echo \"{==DBG==} INIT SCRIPT\"" >> init
echo "mount -t proc none /proc" >> init
echo "mount -t sysfs none /sys" >> init
echo " " >> init
echo " " >> init
echo "echo -e \"{==DBG==} Boot took \$(cut -d' ' -f1 /proc/uptime) seconds\"" >> init
echo "exec /sbin/init" >> init
chmod a+x init
mv ../rcS ./etc/init.d/
mv ../inittab ./etc/
mv ../fstab ./etc/
echo "user" >>./etc/hostname
echo "127.0.0.1 localhost" >>./etc/hosts
echo "127.0.1.1 user" >>./etc/hosts
#cp ../init ./
ls -la
ls -la
find . -print0 |cpio --null -ov --format=newc |gzip -9 > ../initramfs.cpio.gz
ls -l
cd ..
#rm -rf initramfs/
标签:bin,busybox,cp,一键,dev,rcS,init,echo,arm
From: https://blog.csdn.net/nh5431313/article/details/140611140