构建debian文件系统,作为记录,最小rootfs在180MB左右。
安装构建文件系统的工具,一个是用来chroot,一个是用来构建文件系统
sudo apt install qemu-user-static -y
sudo apt install debootstrap -y
mkdir rootfs
构建文件系统之前,你要知道你想要构建哪个版本的文件系统,
我从https://www.debian.org/mirror/list.zh-cn.html这里,选择了我访问速度快的源,
并且该源有armel。
我看华为源挺快的,就用这个了mirrors.huaweicloud.com
然后就是debian的版本,我尝试一下最新的,buster
sudo debootstrap --foreign --verbose --arch=armel buster rootfs http://mirrors.huaweicloud.com/debian/
构建完成之后,需要chroot进去修改密码等配置
cd rootfs
sudo mount --bind /dev dev/
sudo mount --bind /sys sys/
sudo mount --bind /proc proc/
sudo mount --bind /dev/pts dev/pts/
cd ..
sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin/
sudo chmod +x rootfs/usr/bin/qemu-arm-static
sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs /debootstrap/debootstrap --second-stage --verbose
sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs
最后一条命令chroot完成,
此时可以先apt-get等给你的文件系统安装你需要的软件包
修改root登录密码的方式如下
passwd 你的密码
修改源
sudo gedit rootfs/etc/apt/sourc.list
改为deb http://mirrors.huaweicloud.com/debian buster main
这部操作不知道是干什么,应该和登录有关
sudo gedit rootfs/etc/ssh/sshd_config
添加PermitRootLogin yes
清理缓存,打包之后就可以替换你的文件系统了
apt-cache clean #删除安装包
exit #退出chroot
rm rootfs/usr/bin/qemu-arm-static
unmount all point 2 did. ---- but all documents not mention this.
cd rootfs #进到文件系统目录
tar cvf ../rootfs.tar . #要注意那个. 代表当前目录
生成的rootfs.tar任意解压到文件系统即可
最近编辑记录 迪卡 (2020-04-28 21:11:29)
离线
说说你的host系统版本。
我ubuntu 14.04,在debootstrap 的时候总是失败,dpkg-deb 解压xz文件有问题
离线
使用wpa_supplicant连接wifi。
创建配置文件
/etc/wpa_supplicant.conf
可以使用vi来编写此文件,我还特地去学了一下,如何改光标位置,如何删除,如何保存。
内容为
network={
ssid="我的热点"
psk="我的密码"
}
然后
wpa_supplicant -B -d -i wlan0 -c /etc/wpa_supplicant.conf就OK了
root@dika-pc:~# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
rfkill: Cannot open RFKILL control device
root@dika-pc:~# [ 444.817608] wlan0: authenticate with e4:67:1e:02:33:c0
[ 444.843208] wlan0: send auth to e4:67:1e:02:33:c0 (try 1/3)
[ 444.900867] wlan0: authenticated
[ 444.935561] wlan0: associate with e4:67:1e:02:33:c0 (try 1/3)
[ 444.986874] wlan0: RX AssocResp from e4:67:1e:02:33:c0 (capab=0x411 status=0 aid=4)
[ 445.033483] wlan0: associated
[ 446.047125] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
^C
root@dika-pc:~# udhcpc -i wlan0
udhcpc: started, v1.30.1
udhcpc: sending discover
udhcpc: sending select for 172.16.1.106
udhcpc: lease of 172.16.1.106 obtained, lease time 43200
root@dika-pc:~# ping www.dika.ren
PING www.dika.ren (149.129.80.46) 56(84) bytes of data.
64 bytes from 149.129.80.46: icmp_seq=3 ttl=45 time=217 ms
64 bytes from 149.129.80.46: icmp_seq=4 ttl=45 time=417 ms
64 bytes from 149.129.80.46: icmp_seq=5 ttl=45 time=102 ms
64 bytes from 149.129.80.46: icmp_seq=6 ttl=45 time=108 ms
^C
--- www.dika.ren ping statistics ---
6 packets transmitted, 4 received, 33.3333% packet loss, time 346ms
rtt min/avg/max/mdev = 102.009/211.020/417.367/127.586 ms
离线
曾经用squashfs将Debian的rootfs压缩到可以放在128MB的NAND中,缺点是squashfs是只读的,需要用overlayfs等方式实现完整的文件读写。
离线
debootstrap --arch=armhf buster chroot https://mirrors.ustc.edu.cn/debian/
这一行就够了,不用什么stage2之类的东西。
ref: https://www.lotlab.org/2020/04/09/run-debian-on-rtd1195-based-nas-device/
离线
增加swap分区,
使用free查看当前swap大小
使用如下命令创建你想要添加swap分区的大小
dd if=/dev/zero of=/swap1 bs=1M count=512 #改成你要设置的SWAP大小,512就是512MB
设置swap分区文件
mkswap /swap1
激活swap分区
swapon /swap1
此时使用free命令就能看到创建好的swap分区,但这只是临时性的, 重启会失效,我们让它给爸爸记住,下次开机时候要开swap
vi /etc/fstab
操作,在最后一行添加
/swap1 swap swap defaults 0 0
离线
https://blog.csdn.net/u012577474/article/details/104795000
大佬可以试一下跑一下桌面看一下效果
离线
跑得动吗?是否流畅?
离线
在这里存一个我的debian系统启动日志,在ubuntu20.04LTS编译的,里面还有一堆问题,慢慢解决吧
U-Boot SPL 2018.01-05679-g013ca457fd (Aug 04 2020 - 19:41:13)
DRAM: 32 MiB
Trying to boot from MMC1
U-Boot 2018.01-05679-g013ca457fd (Aug 04 2020 - 19:41:13 +0800) Allwinner Technology
CPU: Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM: 32 MiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment
In: serial@1c25000
Out: serial@1c25000
Err: serial@1c25000
Net: No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
reading /boot.scr
279 bytes read in 15 ms (17.6 KiB/s)
## Executing script at 80c50000
reading suniv-f1c100s-licheepi-nano.dtb
7583 bytes read in 26 ms (284.2 KiB/s)
reading zImage
3836280 bytes read in 202 ms (18.1 MiB/s)
## Flattened Device Tree blob at 80c00000
Booting using the fdt blob at 0x80c00000
Loading Device Tree to 816fb000, end 816ffd9e ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.15.0-rc8-licheepi-nano+ (lign@lign-G3-3579) (gcc version 7.2.1 20171011 (Lina0
[ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[ 0.000000] CPU: VIVT data cache, VIVT instruction cache
[ 0.000000] OF: fdt: Machine model: Lichee Pi Nano
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] random: fast init done
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 8128
[ 0.000000] Kernel command line: console=tty0 console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 rw
[ 0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.000000] Memory: 22684K/32768K available (6144K kernel code, 236K rwdata, 1388K rodata, 1024K init, 24)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xc2800000 - 0xff800000 ( 976 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xc2000000 ( 32 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (7136 kB)
[ 0.000000] .init : 0x(ptrval) - 0x(ptrval) (1024 kB)
[ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 237 kB)
[ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) ( 245 kB)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000045] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.000109] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000632] Console: colour dummy device 80x30
[ 0.001541] console [tty0] enabled
[ 0.001646] Calibrating delay loop... 203.16 BogoMIPS (lpj=1015808)
[ 0.070279] pid_max: default: 32768 minimum: 301
[ 0.070614] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.070708] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.072156] CPU: Testing write buffer coherency: ok
[ 0.073847] Setting up static identity map for 0x80100000 - 0x80100058
[ 0.076430] devtmpfs: initialized
[ 0.082710] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000s
[ 0.082874] futex hash table entries: 256 (order: -1, 3072 bytes)
[ 0.083179] pinctrl core: initialized pinctrl subsystem
[ 0.085175] NET: Registered protocol family 16
[ 0.086605] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.088461] cpuidle: using governor menu
[ 0.113667] SCSI subsystem initialized
[ 0.114081] usbcore: registered new interface driver usbfs
[ 0.114284] usbcore: registered new interface driver hub
[ 0.114536] usbcore: registered new device driver usb
[ 0.115023] pps_core: LinuxPPS API ver. 1 registered
[ 0.115102] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.115226] PTP clock support registered
[ 0.115711] Advanced Linux Sound Architecture Driver Initialized.
[ 0.117263] clocksource: Switched to clocksource timer
[ 0.142997] NET: Registered protocol family 2
[ 0.144457] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.144610] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.144698] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.145008] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.145116] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.145623] NET: Registered protocol family 1
[ 0.146863] RPC: Registered named UNIX socket transport module.
[ 0.146973] RPC: Registered udp transport module.
[ 0.147022] RPC: Registered tcp transport module.
[ 0.147069] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.149374] NetWinder Floating Point Emulator V0.97 (double precision)
[ 0.151230] Initialise system trusted keyrings
[ 0.151847] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[ 0.169096] NFS: Registering the id_resolver key type
[ 0.169266] Key type id_resolver registered
[ 0.169324] Key type id_legacy registered
[ 0.182591] Key type asymmetric registered
[ 0.182700] Asymmetric key parser 'x509' registered
[ 0.182939] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 0.183034] io scheduler noop registered
[ 0.183081] io scheduler deadline registered
[ 0.183856] io scheduler cfq registered (default)
[ 0.183952] io scheduler mq-deadline registered
[ 0.184006] io scheduler kyber registered
[ 0.185120] sun4i-usb-phy 1c13400.phy: Couldn't request ID GPIO
[ 0.194687] suniv-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 0.360320] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[ 0.366874] console [ttyS0] disabled
[ 0.387192] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 23, base_baud = 6250000) is a 16550A
[ 0.858334] console [ttyS0] enabled
[ 0.868820] panel-simple panel: panel supply power not found, using dummy regulator
[ 0.878297] SCSI Media Changer driver v0.25
[ 0.885945] m25p80 spi0.0: w25q128 (16384 Kbytes)
[ 0.893356] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.900090] ehci-platform: EHCI generic platform driver
[ 0.905660] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.912020] ohci-platform: OHCI generic platform driver
[ 0.917753] usbcore: registered new interface driver usb-storage
[ 0.924746] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending drivers
[ 0.933893] i2c /dev entries driver
[ 0.997390] sunxi-mmc 1c0f000.mmc: base:0x19fc4356 irq:19
[ 1.004869] usbcore: registered new interface driver usbhid
[ 1.010644] usbhid: USB HID core driver
[ 1.032408] NET: Registered protocol family 17
[ 1.037187] Key type dns_resolver registered
[ 1.043918] Loading compiled-in X.509 certificates
[ 1.059894] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc0739498)
[ 1.068873] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc073877c)
[ 1.076627] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 1.083392] [drm] No driver support for vblank timestamp query.
[ 1.139881] Console: switching to colour frame buffer device 60x34
[ 1.142302] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.144425] mmc0: new high speed SDHC card at address aaaa
[ 1.145530] mmcblk0: mmc0:aaaa SU04G 3.69 GiB
[ 1.147775] mmcblk0: p1 p2
[ 1.210025] sun4i-drm display-engine: fb0: frame buffer device
[ 1.229452] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[ 1.251131] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dur
[ 1.281958] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[ 1.300729] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[ 1.323889] hub 1-0:1.0: USB hub found
[ 1.334487] hub 1-0:1.0: 1 port detected
[ 1.346660] using random self ethernet address
[ 1.357775] using random host ethernet address
[ 1.370414] usb0: HOST MAC 9e:9e:f1:32:4e:96
[ 1.381226] usb0: MAC 7a:14:56:71:d9:b6
[ 1.391517] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008
[ 1.411527] g_cdc gadget: g_cdc ready
[ 1.422311] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 1.452108] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 1.471288] ALSA device list:
[ 1.480526] #0: Loopback 1
[ 1.490371] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 1.511183] cfg80211: failed to load regulatory.db
[ 1.525074] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[ 4.375320] random: crng init done
[ 13.218522] EXT4-fs (mmcblk0p2): recovery complete
[ 13.231022] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 13.251163] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 13.269447] devtmpfs: mounted
[ 13.283054] Freeing unused kernel memory: 1024K
[ 13.806441] systemd[1]: System time before build time, advancing clock.
[ 13.843921] systemd[1]: Failed to insert module 'autofs4': No such file or directory
[ 13.907908] systemd[1]: systemd 232 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +)
[ 13.951686] systemd[1]: Detected architecture arm.
Welcome to Debian GNU/Linux 9 (stretch)!
[ 13.999607] systemd[1]: Set hostname to <lign-G3-3579>.
[ 15.579686] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[ OK ] Started Dispatch Password Requests to Console Directory Watch.
[ 15.639666] systemd[1]: Created slice System Slice.
[ OK ] Created slice System Slice.
[ 15.695221] systemd[1]: Mounting Debug File System...
Mounting Debug File System...
[ 15.717544] systemd[1]: Created slice system-serial\x2dgetty.slice.
[ OK ] Created slice system-serial\x2dgetty.slice.
[ 15.781726] systemd[1]: Listening on Journal Socket.
[ OK ] Listening on Journal Socket.
[ 15.834835] systemd[1]: Starting Remount Root and Kernel File Systems...
Starting Remount Root and Kernel File Systems...
[ 15.965658] systemd[1]: Starting Load Kernel Modules...
Starting Load Kernel Modules...
[ OK ] Reached target Swap.
[ OK ] Listening on Journal Socket (/dev/log).
[ OK ] Listening on udev Kernel Socket.
[ OK ] Listening on udev Control Socket.
[ OK ] Started Forward Password Requests to Wall Directory Watch.
[ OK ] Reached target Paths.
Starting Create Static Device Nodes in /dev...
[ OK ] Created slice system-getty.slice.
[ OK ] Reached target Encrypted Volumes.
[ OK ] Listening on Syslog Socket.
Starting Journal Service...
[ OK ] Reached target Remote File Systems.
[ OK ] Listening on /dev/initctl Compatibility Named Pipe.
[ OK ] Reached target Sockets.
[ OK ] Reached target Slices.
[ OK ] Mounted Debug File System.
[ OK ] Started Remount Root and Kernel File Systems.
[ OK ] Started Load Kernel Modules.
[ OK ] Started Create Static Device Nodes in /dev.
Starting udev Kernel Device Manager...
Mounting Configuration File System...
Starting Apply Kernel Variables...
Starting Load/Save Random Seed...
Starting udev Coldplug all Devices...
[ OK ] Reached target Local File Systems (Pre).
[ OK ] Reached target Local File Systems.
[ OK ] Mounted Configuration File System.
[ OK ] Started Apply Kernel Variables.
Starting Raise network interfaces...
[ OK ] Started Load/Save Random Seed.
[ OK ] Started udev Kernel Device Manager.
[ OK ] Started Journal Service.
Starting Flush Journal to Persistent Storage...
[ 18.629046] systemd-journald[78]: Received request to flush runtime journal from PID 1
[ OK ] Started Flush Journal to Persistent Storage.
Starting Create Volatile Files and Directories...
[ OK ] Started Create Volatile Files and Directories.
Starting Update UTMP about System Boot/Shutdown...
Starting Network Time Synchronization...
[ OK ] Started Network Time Synchronization.
[ OK ] Started Update UTMP about System Boot/Shutdown.
[ OK ] Started Raise network interfaces.
[ OK ] Reached target Network.
[ OK ] Reached target System Time Synchronized.
[ OK ] Reached target Sound Card.
[ OK ] Started udev Coldplug all Devices.
[ OK ] Reached target System Initialization.
[ OK ] Started Daily Cleanup of Temporary Directories.
[ OK ] Reached target Basic System.
Starting getty on tty2-tty6 if dbus and logind are not available...
[ OK ] Started Regular background program processing daemon.
Starting System Logging Service...
Starting Permit User Sessions...
[ OK ] Started Daily apt download activities.
[ OK ] Started Daily apt upgrade and clean activities.
[ OK ] Reached target Timers.
[ OK ] Found device /dev/ttyS0.
[ OK ] Started System Logging Service.
[ OK ] Started Permit User Sessions.
[ OK ] Started getty on tty2-tty6 if dbus and logind are not available.
[ OK ] Started Getty on tty6.
[ OK ] Started Getty on tty5.
[ OK ] Started Getty on tty4.
[ OK ] Started Getty on tty3.
[ OK ] Started Getty on tty2.
[ OK ] Started Getty on tty1.
[ OK ] Started Serial Getty on ttyS0.
[ OK ] Reached target Login Prompts.
[ OK ] Reached target Multi-User System.
[ OK ] Reached target Graphical Interface.
Starting Update UTMP about System Runlevel Changes...
[ OK ] Started Update UTMP about System Runlevel Changes.
Debian GNU/Linux 9 lign-G3-3579 ttyS0
lign-G3-3579 login: lign
Password:
Login incorrect
lign-G3-3579 login: root
Password:
Linux lign-G3-3579 4.15.0-rc8-licheepi-nano+ #1 Tue Aug 4 10:58:22 CST 2020 armv5tejl
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@lign-G3-3579:~#
最近编辑记录 lignin (2020-08-04 21:24:14)
离线
请问我f1c100s跑linux内存就占掉20多兆,跑一个qt helloworld就剩1兆,这性能跑不了什么界面的应用吧?
但是看网上有人f1c100s做界面很花哨流畅,一点柑橘不到内存问题。
离线
尝试了一下在wsl里构建debian,结果运行sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs /debootstrap/debootstrap --second-stage --verbose
sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs一直报cannot execute binary file: Exec format error的错,结果发现wsl1不支持32位的程序,换成了wsl2才解决问题
离线
现在的问题是chroot之后没法连上网,不能用apt-get安装东西,不知道怎么解决
离线
现在的问题是chroot之后没法连上网,不能用apt-get安装东西,不知道怎么解决
解决了,是 dns的问题,改了resolv.conf就好了
离线