瑞芯微Rockchip开发者社区
直播中

王芳

7年用户 1433经验值
私信 关注
[经验]

RK3399 Ubuntu系统在PC虚拟机中使用apt-get修改文件系统

首先在VM虚拟机中安装qemu相关环境

forlinx@ubuntu:$ sudo apt-get install qemu-user-static

将Forlinx Desktop源码目录下OK3399-desktop-release/rootfs/ubuntu.img文件扩容后挂载()

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ sudo fsck.ext3 -f IMAGE

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ sudo resize2fs IMAGE SIZE

(IMAGE为要修改的镜像名称,SIZE为块的数量、一个块的大小为4K(即当SIZE为783770时,783770*4=3135080,大概为3.2G,1250000时为5G))按需求扩容对应的容量大小。

ubuntu.img镜像大小与开发板rootfs分区有关,扩容为5G没有问题,再往上扩容需要查看开发板rootfs分区大小,ubuntu.img ≤ rootfs分区大小,

扩容后将ubuntu.img文件挂载到target目录下

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ sudo mount ubuntu.img target/

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ cd target

修改配置

forlinx@ubuntu:~/OK3399-desktop-release/rootfs/target$ sudo cp /usr/bin/qemu-arm-static usr/bin/

拷贝PC主机端的dns配置,因为待会安装程序时要用网络:

forlinx@ubuntu:~/OK3399-desktop-release/rootfs/target$ sudo cp -b /etc/resolv.conf etc/resolv.conf

forlinx@ubuntu:~/OK3399-desktop-release/rootfs/target$ sudo vim etc/apt/source.list

添加

deb xenial main universe

deb-src xenial main universe

创建qemu挂载脚本

forlinx@ubuntu:~/OK3399-desktop-release/rootfs/target$ cd ..

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ touch mount.sh

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ vi 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

保存退出

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ chmod +x mount.sh

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ sudo ./mount.sh -m target/

到此,成功将ubuntu.img挂载到qemu上,虚拟机操作用户应该变为root@ubuntu:/# ,此时执行apt等操作会保留在ubuntu.img文件中

做对应的修改即可

退出 exit

取消挂载

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ sudo ./mount.sh -u target/

forlinx@ubuntu:~/OK3399-desktop-release/rootfs$ sudo umount target/

然后运行编译脚本生成update.img即可。

原作者:飞凌嵌入式

更多回帖

发帖
×
20
完善资料,
赚取积分