OpenWrt-从门口到入门

本文介绍了非root用户下OpenWrt系统的编译和配置过程,包括下载源码、更新feeds、下载依赖文件、编译等步骤。还提及了编译错误、运行问题的处理方式,以及Luci安装、设置root密码、修改hostname等配置操作,并给出了相关配置参考链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

***以下操作不要使用root用户***

1.下载源码并更新。(注意:不要用root用户下载)

#git clone https://github.com/openwrt/openwrt.git
#git pull

2.Updating Feeds

(1) update

#./scripts/feeds update -a

(2) install

单个安装

#./scripts/feeds install <PACKAGENAME>

全部安装(默认全部安装)

#./scripts/feeds install -a

3.下载所有依赖原文件(需要耐心等待)

首先,进入make menuconfig配置硬件平台


配置好后,开始编译,先用make download下载配置所需库,再make V=s编译。这两步时间较长,请耐心等待……

#make download 
#make V=s

 

#1编译错误:

#make[2]: *** [tools/pkg-config/compile] Error 2

处理方式

#cd /build_dir/host/pkg-config-0.29.2/glib

#./configure --disable-option-checking --prefix=/opt/openwrt/openwrt/staging_dir/host CC=gcc CFLAGS='-O2 -I/opt/openwrt/opeing_dir/host/usr/include' CPPFLAGS='-I/opt/openwrt/openwrt/staging_dir/host/include -I/opt/openwrt/openwrt/staging_dir/host/usr/include' LDFLAGS='-L/opt/openwrt/openwrt/staging_dir/host/usr/lib' --enable-iconv=no --with-libiconv=gnu --with-internal-glib

#make

这一步编译生成的系统BIN只有3.5M左右

 

#2运行问题:

烧录运行后出现:

bootconsole [early0] disabled

根据menuconfig中target profile选项去target/linux/ramips/dts/xxx.dts修改bootargs参数。

vi target/linux/ramips/dts/LINKIT7688.dts

我这里是使用ttyS0,波特率设置为57600。(这里根据硬件不同有所不同)

 

#3 Luci安装

进入menuconfig界面后,选择luci/ Collections/luci为[*]后,开始编译

make V=s

编译后生成的BIN文件大约增加0.5M。

安装中文包

修改源码文件默认为中文:feeds/luci/modules/luci-base/root/etc/config/luci

config core main

    option resourcebase '/luci-static/resources'

    #设置默认语言

    option lang 'zh_cn'

    #设置默认主题

    option mediaurlbase '/luci-static/bootstrap'

#设置可选择的语言       

config internal languages

    option zh_cn 'chinese'

    option en 'English'#设置可选择的主题

config internal themes

    option Bootstrap '/luci-static/bootstrap'

 

修改默认IP:

vi package/base-files/files/bin/config_generate

 

默认打开wifi,并修改SSID为YLFM-OpenWrt

vi package/kernel/mac80211/files/lib/wifi/mac80211.sh

 

#4 配置参考

开发指南 https://blog.youkuaiyun.com/u013162035/article/details/78872218

https://www.jianshu.com/p/66c7b0969a31

 

#5 设置root密码

先连接平台,使用passwd命令设置密码;再使用cat /etc/shadow命令查看密码。

将红色框复制到 package/base-files/files/etc/shadow文件中。然后编译重新烧录。

 

#6 修改hostname

修改源码:package/base-files/files/bin/config_generate

如下图设置了hostname和时区(CST-8)

 

#修改启动信息

$cat package/base-files/files/etc/banner

字符可在http://www.network-science.de/ascii/ 网站生成,openwrt 风格为 rectangles ;  

_______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
-----------------------------------------------------
OpenWrt SNAPSHOT, r10075-ace2410
-----------------------------------------------------

 

#7 USB热插拔自动挂载

https://blog.youkuaiyun.com/u011641885/article/details/46530327

添加USB支持

Kernel modules —> USB Support —> <*> kmod-usb-core.  ##默认已经选了
Kernel modules —> USB Support —> <*> kmod-usb-ohci.  ##默认已选 old usb1.0
Kernel modules —> USB Support —> <*> kmod-usb-uhci.  ## usb1.1
Kernel modules —> USB Support —> <*> kmod-usb-storage.
Kernel modules —> USB Support —> <*> kmod-usb-storage-extras.
Kernel modules —> USB Support —> <*> kmod-usb2.  ##默认已经选了 usb2.0
Kernel modules —> USB Support —> <*> kmod-usb3.  

添加SCSI支持

Kernel modules —> Block Devices —> <*>kmod-scsi-core  ##默认已经选了 usb3.0

添加USB挂载

Base system —> <*>block-mount  ##添加USB挂载
Utilities —> Filesystem —> <*> badblocks  ##添加自动挂载工具

添加文件系统

Kernel modules —> Filesystems —> <*> kmod-fs-ext4 (移动硬盘EXT4格式选择)
Kernel modules —> Filesystems —> <*> kmod-fs-vfat(FAT16 / FAT32 格式 选择)
Kernel modules —> Filesystems —> <*> kmod-fs-ntfs (NTFS 格式 选择)

添加编码

Kernel modules —> Native Language Support —> <*> kmod-nls-utf8
Utilities  ---> disc ---> <*> fdisk.................................... manipulate disk partition table
Utilities  ---> <*> usbutils................................... USB devices listing utilities

编译 make

修改 /etc/config/fstab

option 'enabled'  '1'

自动挂载U盘:编辑系统文件 /etc/hotplug.d/block/10-mount 写入以下内容

(源码中如何修改暂没找到方法)

#!/bin/ash

case "$ACTION" in
    add)
        for i in $(ls /dev/ | grep 'sd[a-z][1-9]')
        do
            mkdir -p /mnt/$i
            mount -o iocharset=utf8,rw /dev/$i /mnt/$i
            if [ $? -ne 0 ]
            then
                mount -o rw /dev/$i /mnt/$i
            fi
        done
        ;;
    remove)
        MOUNT=`mount | grep -o '/mnt/sd[a-z][1-9]'`
        for i in $MOUNT
        do
            umount $i
            if [ $? -eq 0 ]
            then
                rm -r $i
            fi
        done
        ;;
esac

 

#添加多用户,并分配不同的权限

https://blog.youkuaiyun.com/xingyuzhe/article/details/47299825

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值