Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4463198
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: 嵌入式

2018-12-10 11:44:24

这其实是openwrt中的一个功能,现在把它移到普通的target中
target文件系统是squashfs,它是只读的,每升级一个文件都得整个区擦除然后重新写,很麻烦,使用overlayfs可以使只读区中单个文件进行替换修改,很方便。
根目录是squashfs只读的挂载设备是/dev/mtdblock2,其上有/overlay /rootdir文件夹, 分配出一个jffs2分区mtdblock3来做为可写区, 内核中使能overlay文件系统,
在init中实现overlay挂载

  1. #!/bin/sh
  2. init_sys()
  3. {
  4. mount -t proc proc /proc
  5. mount -t sysfs sysfs /sys
  6. mount -n -t jffs2 /dev/mtdblock3 /overlay
  7. mount -n -t overlayfs overlayfs -o lowerdir=/,upperdir=/overlay /rootdir
  8. mount -n /proc -o noatime,--move /rootdir/proc
  9. mount -n /dev -o noatime,--move /rootdir/dev
  10. mount -n /tmp -o noatime,--move /rootdir/tmp
  11. mount -n /sys -o noatime,--move /rootdir/sys
  12. mount -n /rootdir/overlay -o noatime,--move /overlay
  13. }
  14. fini_system()
  15. {
  16. umount /proc
  17. umount /sys
  18. umount /dev
  19. }
  20. boot()
  21. {
  22. fini_system
  23. if [ -x /sbin/init ]; then
  24. exec chroot /rootdir /sbin/init
  25. fi
  26. }
  27. start_shell()
  28. {
  29. /sbin/getty -L ttyS1 115200 vt100 -n -l /bin/ash
  30. }
  31. init_sys
  32. bootm=1
  33. times=0
  34. # read -n1 -t2 bootm
  35. case $bootm in
  36. 1)
  37. # echo "Boot the normal pid: $$...."
  38. boot
  39. ;;
  40. 9)
  41. # echo "Start the shell pid: $$...."
  42. start_shell
  43. ;;
  44. *)
  45. boot
  46. ;;
  47. esac
作者:帅得不敢出门


阅读(2791) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~