This version is for Arm routers: RT-AC56U, RT-AC66U_B1, RT-AC68U, RT-AC87U, RT-AC88U, RT-AC3200, RT-AC5300...
Can't be installed on mipsel devices because kernel is too old, use debian wheezy instead from here
I setup a chrooted Debian Jessie v8.9 where you can compile and install any package you want, of course if routers memory permit it, ex. transmission, plexmediaserver, minidlna, lighttpd, rutorrent, owncloud...
Choose only one version to install from point 1a or 1b, Optware or Entware
1a - Install NEW GENERATION OPTWARE from here, to simplify things, debian will be installed in optware-ng.arm folder, in this case is /mnt/usb_disk/optware-ng.arm
or
1b - Install NEW GENERATION ENTWARE from here, to simplify things, debian will be installed in entware-ng.arm folder, in this case is /mnt/usb_disk/entware-ng.arm
2 - Download and extract prepared archive
wget -c -O debian_jessie8.9-arm_clean.tgz https://bit.ly/2JxYGjx
tar -xvzf ./debian_jessie8.9-arm_clean.tgz
3 - Create startup script for installed services (thanks @ryzhov_al), this is useful for minidlna, transmission or any other package...
貓 >> /opt/etc/init.d/S99debian << 'EOF'
#!/bin/sh
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
路徑=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
# Folder with Debian Jessie
# Debian Jessie 文件夹
CHROOT_DIR=/tmp/mnt/sda1/entware/debian
# Some folder outside of sandbox,
# 某個文件夾在沙盒之外,
# will be mounted to /mnt folder in Debian
# 將會被安裝到 Debian 的/mnt 文件夾中
# Uncommented "EXT_DIR=" line if you need to
# 若需要請取消註解 "EXT_DIR=" 行
# mount a folder inside debian (remove #)
# 在 debian 中挂載一個文件夾(移除#) # 在 debian 中挂載一個文件夾
# EXT_DIR=/tmp/mnt/sda1/Media/
CHROOT_SERVICES_LIST=/opt/etc/chroot-services.list
if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
如果 [ ! -e "$CHROOT_SERVICES_LIST" ]; 然後
echo "Please, define Debian services to start in
請定義需要在 Debian 中啟動的服務
$CHROOT_SERVICES_LIST first!"
$CHROOT_SERVICES_LIST 第一!"
echo "One service per line. Hint: this is a script names from
輸出 "每行一項服務。提示:這是一個名稱來自的腳本"
Debian's /etc/init.d/" Debian 的/etc/init.d/
exit 1 退出 1
fi 翻譯來源文本至傳統中文語言,直接輸出翻譯結果,不附任何額外文本。 來源文本:fi 翻譯結果:
MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"
挂載目錄數量="$(mount | grep $CHROOT_DIR | wc -l)"
start() { 開始() {
if [ $MountedDirCount -gt 0 ]; then
if [ $ MountedDirCount -gt 0 ]; then
echo "Chroot'ed services seems to be already started,
輸出 "Chroot'ed 服務似乎已經啟動,"
exiting..." 退出..."
exit 1 退出 1
fi 翻譯來源文字到傳統中文語言,直接輸出翻譯結果,不附任何額外文字。 源文字:fi 翻譯結果:芬蘭語
echo "Starting chroot'ed Debian services..."
輸出 "開始在 chroot 環境中的 Debian 服務..."
for dir in dev proc sys; do
對於 dir in dev proc sys; do
mount -o bind /$dir $CHROOT_DIR/$dir
done 完成
[ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
for item in $(cat $CHROOT_SERVICES_LIST); do
對於項目 in $(cat $CHROOT_SERVICES_LIST); do
chroot $CHROOT_DIR /etc/init.d/$item start
在 $CHROOT_DIR 下的 /etc/init.d/$item 路徑下執行 "start" 指令
done 完成
}
stop() { stop() { 停止() {
if [ $MountedDirCount -eq 0 ]; then
if [ $ MountedDirCount -eq 0 ]; then
echo "Chroot'ed services seems to be already stopped,
輸出 "Chroot'ed 服務似乎已經停止,"
exiting..." 退出..."
exit 1 退出 1
fi 翻譯來源文字到傳統中文語言,直接輸出翻譯結果,不附任何額外文字。 源文字:fi 翻譯結果:芬蘭語
echo "Stopping chroot'ed Debian services..."
輸出 "停止封裝的 Debian 服務..."
for item in $(cat $CHROOT_SERVICES_LIST); do
對於項目 in $(cat $CHROOT_SERVICES_LIST); do
chroot $CHROOT_DIR /etc/init.d/$item stop
在$CHROOT_DIR 下的/etc/init.d/$item 停止
sleep 2 睡 2
done 完成
umount /opt/debian/dev/pts
卸載 /opt/debian/dev/pts
mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
}
restart() { restart() { 重新開始() {
if [ $MountedDirCount -eq 0 ]; then
if [ $ MountedDirCount -eq 0 ]; then
echo "Chroot'ed services seems to be already stopped"
輸出 "Chroot'ed 服務似乎已經停止"
start 開始
else 不然
echo "Stopping chroot'ed Debian services..."
輸出 "停止在 chroot 中的 Debian 服務..."
for item in $(cat $CHROOT_SERVICES_LIST); do
對於項目 in $(cat $CHROOT_SERVICES_LIST); do
chroot $CHROOT_DIR /etc/init.d/$item stop
在$CHROOT_DIR 的子目录下,執行/etc/init.d/$item 停機。
sleep 2 睡 2
done 完成
mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
echo "Restarting chroot'ed Debian services..."
echo "重新啟動套牢的 Debian 服務..."
for dir in dev proc sys; do
對於 dir in dev proc sys; do
mount -o bind /$dir $CHROOT_DIR/$dir
done 完成
[ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
for item in $(cat $CHROOT_SERVICES_LIST); do
對於項目 in $(cat $CHROOT_SERVICES_LIST); do
chroot $CHROOT_DIR /etc/init.d/$item start
在 $CHROOT_DIR 下的 /etc/init.d/$item start
done 完成
fi 翻譯來源文本至傳統中文語言,直接輸出翻譯結果,不附任何額外文本。 來源文本:fi 翻譯結果:
}
enter() { 進入() {
[ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
mount -o bind /dev/ /opt/debian/dev/
掛載 -o bind /dev/ /opt/debian/dev/
mount -o bind /dev/pts /opt/debian/dev/pts
mount -o bind /proc/ /opt/debian/proc/
掛載 -o bind /proc/ /opt/debian/proc/
mount -o bind /sys/ /opt/debian/sys/
掛載 -o bind /sys/ /opt/debian/sys/
chroot /opt/debian /bin/bash
在/opt/debian 中使用/bin/bash 進行 chroot 操作
}
status() { 狀態() {
if [ $MountedDirCount -gt 0 ]; then
if [ $ MountedDirCount -gt 0 ]; then
echo "Chroot'ed services running..."
輸出 "Chroot'ed 服務正在運行..."
else 不然
echo "Chroot'ed services not running!"
輸出 "Chroot'ed 服務未運行!"
fi 翻譯來源文本至傳統中文語言,直接輸出翻譯結果,不附任何額外文本。 來源文本:fi 翻譯結果:
}
case "$1" in case "$1" 在 $1 情況下
start) 開始)
start 開始
;;
stop) 停止)
stop 停止
;;
restart) 重新開始
restart 重新啟動
;;
enter) 進入)
enter 進入
;;
status) status 狀態) 狀態
;;
*)
echo "Usage: (start|stop|restart|enter|status)"
輸出:"使用方法:(開始|停止|重新啟動|進入|狀態)"
exit 1 退出 1
;;
esac esa
echo Done. 完成。
exit 0 退出 0
EOF 文件終結符
Press ENTER
Make script executable
In this script is a path EXT_DIR to your external media folder which will be mounted in debian as /mnt, default is /mnt/sda1/Media/ (must be a single folder not the whole partition), don't forget to uncomment if is used, inside Debian, EXT_DIR /mnt/sda1/Media/ will become /mnt (Ex. you need to set Transmission download path to /mnt/transmission or a new library in Plex Media Server path to /mnt
在這個腳本中,有個路徑 EXT_DIR 到您的外部媒體文件夾,它將在 debian 中掛載為/mnt,預設為/mnt/sda1/Media/(必須是一個單一的文件夾,而不是整個分區),在 debian 中,EXT_DIR /mnt/sda1/Media/將變為/mnt(例如,您需要將傳輸下載路徑設置為/mnt/transmission 或 plex media server 中新的庫路徑為/mnt) 不要忘記如果使用了則取消註解。
If your disk has a label change sda1 from CHROOT_DIR with your disk label, modify the script to match your settings with a text editor, use this command:
After editing EXT_DIR and CHROOT_DIR, save settings with CTRL-O, press ENTER and exit nano with CTRL-X
ln -s /opt/etc/init.d/S99debian /opt/bin/debian
Every time you want to start installed services in debian without typing long command "/opt/etc/init.d/S99debian start/stop", type only
debian stop
debian restart
debian enter
debian status
But don't forget to add services name from /opt/debian/etc/init.d/ to /opt/etc/chroot-services.list
6 - Enter chrooted debian, you will see in terminal username will change to root@RT-AC... from admin@RT-AC... or other name if changed previously in router menu (all terminals commands with purple border are inside debian)
7 - Run update to see if some recent packages are available
8 - Set your country time zone
9 - Install some packages, ex. wget
Now you have a full Debian distro and may install any package from here
10 - To exit chrooted debian just type exit
HOW TO UNINSTALL DEBIAN
It's very important to unmount external folder before removing debian, if not - all content from that directory will be deleted: movies, music files, photos...
/opt/etc/init.d/S99debian stop
rm /opt/bin/debian
HOW TO BACKUP-RESTORE DEBIAN
After installing a lot of packages, it's better to make a backup, if something goes wrong just restore it without reconfigure all off your work.
It's very important to unmount external folder before backing up debian, if not - all content from that directory will be included in archive and may become huge...
tar -cvzf ./chosen_debian_name.tgz ./debian/
tar -xvzf ./chosen_debian_name.tgz