Skip to content

Commit

Permalink
Updated build_debian_rootfs
Browse files Browse the repository at this point in the history
Rootfs now includes:
-vim, nano
-locales, keyboard, tzdata setup (with dialog)
-default network config
-tweaks for eth, sysctl (from Tweaks.txt)
  • Loading branch information
Heisath committed Oct 13, 2020
1 parent 0b8e10e commit 92c2521
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions build_debian_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ exit_with_error()
# we can never know what aliases may be set, so remove them all
unalias -a

# set options
# set options
target_dir="output"
rootfs="${target_dir}"/rootfs
release='buster'
arch='armhf'
qemu_binary='qemu-arm-static'
components='main,contrib'
includes="ccache,locales,git,ca-certificates,debhelper,rsync,python3,distcc,systemd,init,udev,kmod,bash-completion,busybox,ethtool,dirmngr,hdparm,ifupdown,iproute2,iputils-ping,logrotate,net-tools,nftables,powermgmt-base,procps,rename,resolvconf,rsyslog,ssh,sysstat,update-inetd" #libfile-fcntllock-perl,devscripts,
# Adjust package list here
includes="ccache,locales,git,ca-certificates,debhelper,rsync,python3,distcc,systemd,init,udev,kmod,bash-completion,busybox,ethtool,dirmngr,hdparm,ifupdown,iproute2,iputils-ping,logrotate,net-tools,nftables,powermgmt-base,procps,rename,resolvconf,rsyslog,ssh,sysstat,update-inetd,isc-dhcp-client,isc-dhcp-common,vim,dialog,apt-utils,nano,keyboard-configuration,console-setup"
mirror_addr="http://httpredir.debian.org/debian/"

# Adjust default root pw
root_pw='1234'

# Adjust hostname here
def_hostname='wdmycloud'

# cleanup old
rm -rf "${rootfs}"
rm -rf "${target_dir}"/"${release}"-rootfs.tar.gz
Expand Down Expand Up @@ -55,14 +61,12 @@ mount -t devpts chpts "${rootfs}"/dev/pts

echo "### Applying tweaks"
[[ -f "${rootfs}"/etc/locale.gen ]] && sed -i "s/^# en_US.UTF-8/en_US.UTF-8/" "${rootfs}"/etc/locale.gen
chroot "${rootfs}" /bin/bash -c "locale-gen; update-locale LANG=en_US:en LC_ALL=en_US.UTF-8"
#chroot "${rootfs}" /bin/bash -c "locale-gen; update-locale LANG=en_US:en LC_ALL=en_US.UTF-8"
chroot "${rootfs}" /bin/bash -c "dpkg-reconfigure locales"
chroot "${rootfs}" /bin/bash -c "dpkg-reconfigure tzdata"
chroot "${rootfs}" /bin/bash -c "dpkg-reconfigure keyboard-configuration"
chroot "${rootfs}" /bin/bash -c "/usr/sbin/update-ccache-symlinks"

#if [[ -f "${rootfs}"/etc/default/console-setup ]]; then
# sed -e 's/CHARMAP=.*/CHARMAP="UTF-8"/' -e 's/FONTSIZE=.*/FONTSIZE="8x16"/' \
# -e 's/CODESET=.*/CODESET="guess"/' -i "${rootfs}"/etc/default/console-setup
# eval 'LC_ALL=C LANG=C chroot $rootfs /bin/bash -c "setupcon --save"'
#fi

chroot "${rootfs}" /bin/bash -c "apt-get -y update"
chroot "${rootfs}" /bin/bash -c "apt-get -y full-upgrade"
Expand All @@ -72,6 +76,7 @@ chroot "${rootfs}" /bin/bash -c "apt-get -y clean"
# set root password
chroot "${rootfs}" /bin/bash -c "(echo ${root_pw};echo ${root_pw};) | passwd root >/dev/null 2>&1"

# create fstab, adjust for your layout here
cat << EOF > ${rootfs}/etc/fstab
# Default mounts
/dev/sdb2 / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1
Expand All @@ -91,10 +96,28 @@ sysfs /sys sysfs defaults 0 0
#/dev/sda1 /mnt/hd-intern ext4 defaults,noatime 0 1
EOF

# Apply tweaks in sysctl
cat << EOF >> ${rootfs}/etc/sysctl.conf
vm.min_free_kbytes=8192
net.core.somaxconn=4096
net.core.wmem_max=16777216
net.core.rmem_max=16777216
net.core.wmem_default=163840
net.core.rmem_default=163840
net.core.netdev_max_backlog=3000
net.ipv4.tcp_keepalive_time=1800
net.ipv4.tcp_fin_timeout=30
net.ipv4.tcp_max_syn_backlog=2048
net.ipv4.tcp_timestamps=0
EOF

# Setup hostname
cat << EOF > ${rootfs}/etc/hostname
wdmycloud
${def_hostname}
EOF

# Setup interfaces (eth0)
cat << EOF > ${rootfs}/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
Expand All @@ -112,6 +135,7 @@ iface eth0 inet dhcp
# netmask 255.255.255.0
# gateway 192.168.1.1
# dns-nameservers 192.168.1.1
pre-up /sbin/ethtool -C eth0 pkt-rate-low 20000 pkt-rate-high 3000000 rx-frames 32 rx-usecs 1150 rx-usecs-high 1150 rx-usecs-low 100 rx-frames-low 32 rx-frames-high 32 adaptive-rx on
EOF

echo "### Unmounting"
Expand Down

0 comments on commit 92c2521

Please sign in to comment.