Ubuntu应用拓展(8)——qemu虚拟机挂载运行
作者:互联网
平台:RK3399
系统:Ubuntu18.04
挂载文件系统
源码解读:
OK3399-desktop-release //飞凌释放的Ubuntu系统源码
OK3399-desktop-release/build_ubuntu.sh //编译Ubuntu的脚本
OK3399-desktop-release/rootfs/ubuntu.img //Ubuntu文件系统镜像
挂载镜像
sudo mount rootfs/ubuntu.img rootfs/target
查看分区情况,可见文件系统镜像挂载的分区空余容量已经没有了,这个和我们制作镜像的手法相关,所以我们需要先卸载刚才挂载的镜像,并对镜像进行扩容,然后才能挂载使用。
OK3399-desktop-release$ df -h
Filesystem Size Used Avail Use% Mounted on
overlay 22T 9.5T 12T 46% /
tmpfs 64M 0 64M 0% /dev
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sdb1 22T 9.5T 12T 46% /etc/hosts
shm 64M 0 64M 0% /dev/shm
/dev/loop0 3.1G 3.0G 0 100% /home/forlinx/work/OK3399-linux-source/OK3399-desktop-release/rootfs/target
镜像扩容
我们追加4000M的空余容量给我们的镜像
dd if=/dev/zero of=./add.img bs=1M count=4000
cat add.img >> rootfs/ubuntu.img
e2fsck -f rootfs/ubuntu.img
resize2fs rootfs/ubuntu.img
使用fdisk -lu查看镜像信息
OK3399-desktop-release$ fdisk -lu rootfs/ubuntu.img
Disk rootfs/ubuntu.img: 7 GiB, 7549747200 bytes, 14745600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
启动arm虚拟机
重新挂载镜像
OK3399-desktop-release$ sudo mount rootfs/ubuntu.img rootfs/target
OK3399-desktop-release$ ls rootfs/target/
bin boot dev etc home include lib lost+found media mnt opt proc root run sbin share srv sys system tmp usr var
执行如下指令,使用chroot命令切换到指定的根文件系统目录,启动arm虚拟机qemu-aarch64-static:
TARGET_ROOTFS_DIR="$PWD/rootfs/target"
if [ ! -e /usr/bin/qemu-aarch64-static ];then
echo "please install qemu-aarch64-static!!!"
sudo umount $TARGET_ROOTFS_DIR/dev
exit -1
fi
sudo mount -o bind /dev $TARGET_ROOTFS_DIR/dev
sudo chroot $TARGET_ROOTFS_DIR
执行完就进入到新指定的文件系统根目录:
root@d25935313377:/# ls
bin boot dev etc home include lib lost+found media mnt opt proc root run sbin share srv sys system tmp usr var
现在我们就可以安装一些基础版文件系统没有安装的工具和软件了:
更新Ubuntu的源:
mv /var/lib/apt/lists /var/lib/apt/lists.old
mkdir -p /var/lib/apt/lists/partial
apt-get update -y
apt-get upgrade -y
安装工具
安装locales之类的工具
root@d25935313377:/# apt-get install locales
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
locales
0 upgraded, 1 newly installed, 0 to remove and 21 not upgraded.
Need to get 3611 kB of archives.
After this operation, 14.5 MB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 locales all 2.27-3ubuntu1.4 [3611 kB]
Fetched 3611 kB in 3s (1350 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)
Selecting previously unselected package locales.
(Reading database ... 110532 files and directories currently installed.)
Preparing to unpack .../locales_2.27-3ubuntu1.4_all.deb ...
Unpacking locales (2.27-3ubuntu1.4) ...
Setting up locales (2.27-3ubuntu1.4) ...
Generating locales (this might take a while)...
Generation complete.
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
qemu: Unsupported syscall: 277
root@d25935313377:/# locale
locale locale-check locale-gen localectl localedef
编译应用程序
cp OK3399-Test rootfs/target/tmp -rf //拷贝我们的应用程序到qemu虚拟机中
root@d25935313377:/# ls tmp/
OK3399-Test
root@d25935313377:/# cd tmp/OK3399-Test/
root@d25935313377:/tmp/OK3399-Test# qmake
Info: creating stash file /tmp/OK3399-Test/.qmake.stash
Project ERROR: Unknown module(s) in QT: charts
安装缺少的qt模块
root@d25935313377:/tmp/OK3399-Test# apt-get install libqt5charts5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libqt5charts5
The following NEW packages will be installed:
libqt5charts5 libqt5charts5-dev
0 upgraded, 2 newly installed, 0 to remove and 21 not upgraded.
Need to get 328 kB of archives.
After this operation, 1765 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libqt5charts5 arm64 5.9.5-0ubuntu1 [307 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libqt5charts5-dev arm64 5.9.5-0ubuntu1 [21.9 kB]
Fetched 328 kB in 2s (164 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)
Selecting previously unselected package libqt5charts5:arm64.
(Reading database ... 111150 files and directories currently installed.)
Preparing to unpack .../libqt5charts5_5.9.5-0ubuntu1_arm64.deb ...
Unpacking libqt5charts5:arm64 (5.9.5-0ubuntu1) ...
Selecting previously unselected package libqt5charts5-dev:arm64.
Preparing to unpack .../libqt5charts5-dev_5.9.5-0ubuntu1_arm64.deb ...
Unpacking libqt5charts5-dev:arm64 (5.9.5-0ubuntu1) ...
Setting up libqt5charts5:arm64 (5.9.5-0ubuntu1) ...
Setting up libqt5charts5-dev:arm64 (5.9.5-0ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...
再编译就没有问题了。
root@d25935313377:/tmp/OK3399-Test# qmake
root@d25935313377:/tmp/OK3399-Test# make
标签:...,OK3399,虚拟机,ubuntu,dev,Ubuntu,libqt5charts5,qemu,rootfs 来源: https://blog.csdn.net/scottmvp/article/details/120953874