arm rootfs定制[通俗易懂]

arm rootfs定制[通俗易懂]最近在做rk3288的OS定制,因此将过程中遇到的问题记录下来。本文主要记录ubuntu18.04rootfs制作过程。参考文档:http://opensource.rock-chips.com/wiki_Distribution1.准备步骤获取ubuntubase18.04.3,路径:http://cdimage.ubuntu.com/ubuntu-base/releases…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

最近在做rk3288的OS定制,因此将过程中遇到的问题记录下来。

本文主要记录ubuntu 18.04 rootfs制作过程。参考文档:http://opensource.rock-chips.com/wiki_Distribution

1.准备步骤

  1. 获取ubuntu base 18.04.3,路径:http://cdimage.ubuntu.com/ubuntu-base/releases/18.04.3/release/ubuntu-base-18.04.3-base-armhf.tar.gz
  2. 解压ubuntu base,命令为:tar -xvpf /path/to/ubuntu-base-armhf -C /path/to/rootfs,其中/path/to/rootfs为解压的目标文件夹,请替换成真实解压路径
  3. 安装qemu模拟器,并将其复制到根文件系统,命令为:sudo apt-get install qemu-user-static; sudo cp /usr/bin/qemu-arm-static /path/to/rootfs/usr/bin/
  4. 复制本地DNS到根文件系统,命令为:cp -b /etc/resolv.conf /path/to/rootfs/etc/resolv.conf
  5. 修改根文件系统apt源,推荐使用中科大的源,参考附录1

2.chroot到根文件系统

命令为:/path/to/ch-mount.sh -m /path/to/rootfs/,注意结尾的反斜杠是必要的。ch-mount.sh脚本内容见附录2。

3.安装软件

此时已经chroot到根文件系统,安装软件耗时会比较久,安装过程中需要进行keyboard layout的配置,主要安装的包包括lubuntu-core和lxde-core,命令如下:

apt-get update
apt install -y lubuntu-core --no-install-recommends
apt install -y lxde-core --no-install-recommends

4.配置和清理

需要添加用户或者安装其余的包的话可以在这一步执行,命令如下:

useradd -s '/bin/bash' -m -G adm,sudo user
#passwd user
#passwd root

#apt-get install xxx or dpkg -i xxx to install other packages

#cleanup
rm -rf /var/lib/apt/lists/*
apt clean

5.退出

在chroot的根文件系统中执行exit命令退出,然后执行命令:/path/to/ch-mount.sh -u /path/to/rootfs/,注意结尾的反斜杠是必要的

6.制作rootfs.img

命令为:/path/to/mkimage.sh /path/to/rootfs rootfs.img,mkimg.sh脚本见附录3

 

附录

附录1. 中科大的apt源:1.sources-18.04.list:

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security multiverse

附录2. ch-mount.sh脚本:

#!/bin/bash

function mnt() {
    echo "MOUNTING"
    sudo mount -t proc /proc ${2}proc
    sudo mount -t sysfs /sys ${2}sys
    sudo mount -o bind /dev ${2}dev

    sudo chroot ${2}
}

function umnt() {
    echo "UNMOUNTING"
    sudo umount ${2}proc
    sudo umount ${2}sys
    sudo umount ${2}dev

}


if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
    mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
    umnt $1 $2
else
    echo ""
    echo "Either 1'st, 2'nd or both parameters were missing"
    echo ""
    echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
    echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
    echo ""
    echo "For example: ch-mount -m /media/sdcard/"
    echo ""
    echo 1st parameter : ${1}
    echo 2nd parameter : ${2}
fi

附录3. mkimg.sh脚本:

#!/bin/bash

rootfs_dir=$1
rootfs_file=$2
rootfs_mnt="mnt"

if [ ! $rootfs_dir ] || [ ! $rootfs_file ];
then
        echo "Folder or target is empty."
        exit 0
fi

if [ -f "$rootfs_file" ]; then
    echo "-- Delete exist $rootfs_file ..."
    rm -f "$rootfs_file"
fi

echo "-- Create $rootfs_file ..."
dd if=/dev/zero of="$rootfs_file" bs=1M count=4096
sudo mkfs.ext4 -F -L linuxroot "$rootfs_file"

if [ ! -d "$rootfs_mnt" ]; then
        mkdir $rootfs_mnt
fi

echo "-- Copy data to $rootfs_file ..."
sudo mount $rootfs_file $rootfs_mnt
sudo cp -rfp $rootfs_dir/* $rootfs_mnt
sudo sync
sudo umount $rootfs_mnt
rm -r $rootfs_mnt

echo "-- Resize $rootfs_file ..."
/sbin/e2fsck -p -f "$rootfs_file"
/sbin/resize2fs -M "$rootfs_file"

echo "-- Done."

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/185193.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • IM在线聊天-微聊即时通讯完整源码「建议收藏」

    IM在线聊天-微聊即时通讯完整源码「建议收藏」简介:好友分享的,社区发布过很多版即时通讯了,零零碎碎几十套了,这个看了下和之前的有点小区别,同样是可以后台直接挂地址,方便内嵌一些cp啊,单啊之类的程序在里面,带一个简易的搭建说明,linux下运行的。网盘下载地址:http://kekewl.org/6zo4TAmfVRe0图片:…

    2022年5月15日
    36
  • Spring-boot_Spring Boot

    Spring-boot_Spring Boot1概述Jasypt是一个加密库,Github上有一个集成了Jasypt的SpringBoot库,叫jasypt-spring-boot,本文演示了如何使用该库对配置文件进行加密。2依赖首先添加依赖:<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId>

    2022年9月26日
    4
  • pcap文件格式及文件解析[通俗易懂]

    pcap文件格式及文件解析[通俗易懂]第一部分:PCAP包文件格式一基本格式:文件头数据包头数据报数据包头数据报……二、文件头:文件头结构体sturctpcap_file_header{DWORDmagic;DWORDversio

    2022年8月3日
    10
  • Python中的/与//的区别

    Python中的/与//的区别在github的项目中的水仙花例题中:1fornuminrange(100,1000):2low=num//103mid=num//10%104high=num//10

    2022年7月5日
    19
  • Java进阶(二十三)java中long类型转换为int类型

    Java进阶(二十三)java中long类型转换为int类型java中long类型转换为int类型由int类型转换为long类型是向上转换,可以直接进行隐式转换,但由long类型转换为int类型是向下转换,可能会出现数据溢出情况:主要以下几种转换方法,供参考:一、强制类型转换[java]longll=300000;intii=(int)ll;二、调用intValue()方法[j

    2022年5月7日
    98
  • 一篇文章,Vue快速入门!!!

    一篇文章,Vue快速入门!!!①Vue概述及第一个Vue程序(HelloWorld)1.1什么是MVVMMVVM(Model-View-ViewModel)是一种软件设计模式,由微软WPF(用于替代WinForm,以前就是用这个技术开发桌面应用程序的)和Silverlight(类似于JavaApplet,简单点说就是在浏览器上运行WPF)的架构师KenCooper和TedPeters开发,是一种简化用户界面的事件驱动编程方式。由JohnGossman(同样也是WPF和Sliverlight的架构师)与2005年在他的

    2022年5月4日
    52

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号