【I.MX6ULL移植】Ubuntu-base根文件系统移植

1.下载Ubuntu16.04根文件系统
http://cdimage.ubuntu.com/
1

2

3

4

5

2.解压ubuntu base 根文件系统

为了存放 ubuntu base 根文件系统,先在 PC 的 Ubuntu 系统中的 nfs 目录下创建一个名为

ubuntu_rootfs 的目录,命令如下:

【注意,这是一定使用下面解压命令解压,否则后面设置密码会出现错误】

bash 复制代码
cd /home/wj/linux/nfs 
mkdir ubuntu_rootfs
cd ubuntu_rootfs
sudo tar -vzxf ubuntu-base-16.04.5-base-armhf.tar.gz


3.安装 qemu

bash 复制代码
sudo apt-get install qemu-user-static

将刚刚安装的 qemu-user-static 拷贝到刚刚解压出来的 ubuntu base 目录中,也就是

ubuntu_rootfs/usr/bin 目录下,命令如下:

bash 复制代码
sudo cp /usr/bin/qemu-arm-static ./usr/bin/

sudo cp /etc/resolv.conf ./etc/resolv.conf 


4.设置中科大源

bash 复制代码
sudo gedit ubuntu_rootfs/etc/apt/sources.list 

将下面命令添加到sources.list 文件最后,切记这里是ubuntu_rootfs下面的,而不是自己PC电脑上的

bash 复制代码
#中科大源
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe


5.在主机挂载根文件系统

在 ubuntu_rootfs 目录下创建一个名为 mount.sh 和 unmount.sh的 shell 脚本

bash 复制代码
touch mount.sh  unmount.sh

其中mount.sh文件内容如下:【换成自己的ubuntu_rootfs路径】

bash 复制代码
#!/bin/bash
echo "MOUNTING"
sudo mount -t proc /proc /home/wj/linux/nfs/ubuntu_rootfs/proc
sudo mount -t sysfs /sys /home/wj/linux/nfs/ubuntu_rootfs/sys
sudo mount -o bind /dev /home/wj/linux/nfs/ubuntu_rootfs/dev
sudo mount -o bind /dev/pts /home/wj/linux/nfs/ubuntu_rootfs/dev/pts
sudo chroot /home/wj/linux/nfs/ubuntu_rootfs

其中unmount.sh文件内容如下:【换成自己的ubuntu_rootfs路径】

bash 复制代码
#!/bin/bash
echo "UNMOUNTING"
sudo umount /home/wj/linux/nfs/ubuntu_rootfs/proc
sudo umount /home/wj/linux/nfs/ubuntu_rootfs/sys
sudo umount /home/wj/linux/nfs/ubuntu_rootfs/dev/pts
sudo umount /home/wj/linux/nfs/ubuntu_rootfs/dev

最后给权限:

bash 复制代码
sudo chmod 777 mount.sh unmount.sh

一切准备就绪以后执行 mount.sh 脚本,将制作的根文件系统挂载到主机下,输入如下命

令:

bash 复制代码
./mount.sh

6.安装常用的命令和软件

bash 复制代码
apt update
apt install sudo
apt install vim
apt install kmod
apt install net-tools
apt install ethtool
apt install ifupdown
apt install language-pack-en-base
apt install rsyslog
apt install htop
apt install iputils-ping

7.设置 root 用户密码

账号和密码都设置成root

bash 复制代码
passwd root


8.设置本机名称和 IP 地址

c 复制代码
echo "wj_imx6ul" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 wj_imx6ul" >> /etc/hosts


9.设置串口终端

bash 复制代码
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc0.service 

10.退出挂载

bash 复制代码
exit
./unmount.sh


11.nfs 挂载测试

bash 复制代码
setenv bootargs 'console=tty1 console=ttymxc0,115200 root=/dev/nfs rw nfsroot=192.168.104.168:/home/wj/linux/nfs/ubuntu_rootfs ip=192.168.104.90:192.168.104.168:192.168.104.1:255.255.255.0::eth0:off'

saveenv

reset
相关推荐
rjszcb5 分钟前
stm32驱动开发与linux驱动的区别
linux
不想秃头的烟花1 小时前
Linux安装软件的方法
linux·debian·redhat·软件仓库
梓沂1 小时前
nginx过滤爬虫访问
运维·爬虫·nginx
l1o3v1e4ding2 小时前
windows和linux安装mysql5.7.31保姆级教程
linux·windows·mysql
最新小梦3 小时前
Docker Compose与私有仓库部署
运维·docker·容器
司职在下3 小时前
828华为云征文|Flexus云服务器X实例快速部署在线测评平台,适用各种信息学教学
运维·服务器·华为云
超维机器人3 小时前
智能巡检机器人局部放电检测的应用
运维·人工智能·算法·机器人
weixin_520475743 小时前
nginx部署时的路径配置问题
运维·nginx
银氨溶液3 小时前
DNS解析域名详解
linux·服务器·apache·域名解析