[Ubuntu系统] 【Ubuntu】客户ubuntu文件系统定制使用说明

419 0
Honkers 2026-5-27 16:58:26 来自手机 | 显示全部楼层 |阅读模式

1.在开发板的UBUNTU系统上面安装软件rsync : sudo apt-get install rsync

2.在开发板的UBUNTU系统上面安装软件openssh的服务端openssh-server并修改root登录权限 : 
sudo apt-get install openssh-server
sudo vi /etc/ssh/sshd_config
修改PermitRootLogin选项用以确保root登录权限足够

重启开发板或者重启ssh服务(/etc/init.d/ssh restart)

3.PC端安装openssh客户端openssh-client
sudo apt-get install openssh-client

4.PC端安装rsync
sudo apt-get install rsync

5.通过rsync
新建目录ubuntu_make :
mkdir ubuntu_make 
cd ubuntu_make
在PC端当前目录新建ubuntu目录:mkdir ubuntu 
同步数据:sudo rsync -avx root@开发板IP:/ ubuntu/
开发板IP为客户端通过ifconfig确认
6.在ubuntu文件夹下面增加文件etc/onlyone.sh
sudo vi etc/onlyone.sh
内容为:
#!/bin/sh

read line < /proc/cmdline
for arg in $line; do
        if [ "5" -le "$(expr length $arg)" ]; then
                if [ "root=" = "$(expr substr $arg 1 5)" ]; then
                {
                        debug_arg=$(expr $arg : 'root=\(.*\)')
                        resize2fs $debug_arg
                }
                fi
        fi
done 
更改文件权限sudo chmod 777 etc/onlyone.sh
使用脚本打包UBUNTU系统:拷贝make_ubuntu.sh到当前文件夹
7制作ubuntu固件:
./make_ubuntu.sh ubuntu
制作ubuntu_core:
./make_ubuntu.sh ubuntu_core
如下图所示分别为ubuntu_core和ubuntu固件:

 8.附上make_ubuntu.sh脚本内容:

  1. #!/bin/bash
  2. #ubuntu(ubuntu-core) build already annotation
  3. #not Often compiled .......too slow and need root
  4. MAKE_THEARD=`cat /proc/cpuinfo| grep "processor"| wc -l`
  5. RESULT="Image-rk3288-ubuntu"
  6. function creat_result_dir()
  7. {
  8. if [ ! -d $RESULT ];
  9. then
  10. {
  11. mkdir Image-rk3288-ubuntu
  12. }
  13. fi
  14. }
  15. function ubuntu_core_build()
  16. {
  17. dd if=/dev/zero of=linux-rootfs-core.img bs=1M count=1000
  18. sudo mkfs.ext4 -F -L linuxroot linux-rootfs-core.img
  19. if [ ! -d mount ];
  20. then
  21. {
  22. mkdir mount
  23. }
  24. fi
  25. sudo mount linux-rootfs-core.img mount
  26. sudo cp -a ubuntu_core/* mount
  27. sudo umount mount
  28. e2fsck -p -f linux-rootfs-core.img
  29. resize2fs -M linux-rootfs-core.img
  30. rm -rf mount
  31. mv linux-rootfs-core.img $RESULT
  32. }
  33. function ubuntu_build()
  34. {
  35. dd if=/dev/zero of=linux-rootfs.img bs=1M count=5000
  36. sudo mkfs.ext4 -F -L linuxroot linux-rootfs.img
  37. if [ ! -d mount ];
  38. then
  39. {
  40. mkdir mount
  41. }
  42. fi
  43. sudo mount linux-rootfs.img mount
  44. sudo cp -a ubuntu/* mount
  45. sudo umount mount
  46. e2fsck -p -f linux-rootfs.img
  47. resize2fs -M linux-rootfs.img
  48. rm -rf mount
  49. mv linux-rootfs.img $RESULT
  50. }
  51. function ubuntu_clean()
  52. {
  53. rm $RESULT/linux-rootfs.img
  54. }
  55. function ubuntu_core_clean()
  56. {
  57. rm $RESULT/linux-rootfs-core.img
  58. }
  59. function result_clean()
  60. {
  61. rm -rf $RESULT
  62. }
  63. creat_result_dir
  64. if [ $1 == "clean" ]
  65. then
  66. {
  67. if [ ! -n $2 ]
  68. then
  69. {
  70. ubuntu_core_clean
  71. ubuntu_clean
  72. result_clean
  73. echo clean Img oK
  74. }
  75. elif [ $2 == "ubuntu" -o $2 == "ubuntu/" ]
  76. then
  77. {
  78. ubuntu_clean
  79. }
  80. elif [ $2 == "ubuntu_core" -o $2 == "ubuntu_core/" -o $2 == "ubuntu-core" -o $2 == "ubuntu-core/" ]
  81. then
  82. {
  83. ubuntu_core_clean
  84. }
  85. else
  86. {
  87. ubuntu_core_clean
  88. ubuntu_clean
  89. result_clean
  90. echo clean Img oK
  91. }
  92. fi
  93. }
  94. elif [ $1 == "ubuntu_core" -o $1 == "ubuntu_core/" -o $1 == "ubuntu-core" -o $1 == "ubuntu-core/" ]
  95. then
  96. {
  97. ubuntu_core_build
  98. }
  99. elif [ $1 == "ubuntu" -o $1 == "ubuntu/" ]
  100. then
  101. {
  102. ubuntu_build
  103. }
  104. else
  105. {
  106. ubuntu_core_build
  107. ubuntu_build
  108. }
  109. fi
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行