去Ubuutu镜像官网下载对应CPU架构的镜像,IMX6ULL支持硬件浮点运算,属于armhf,所以下载ubuntu-base-16.04.6-base-armhf.tar.gz即可,其他发行版本切换到其他目录去查找。
注意:ubuntu-base构建的文件系统是没有UI界面的!
mkdir ubuntu_base_rootfs
sudo tar xzf ubuntu-base-16.04.6-base-armhf.tar.gz -C ./ubuntu_base_rootfs/
cd ubuntu_base_rootfs/
sudo apt install qemu-user-static
sudo cp /usr/bin/qemu-arm-static ./usr/bin/ # 把对应CPU架构的qemu程序拷贝过去
sudo cp /etc/resolv.conf ./etc/resolv.conf
sudo vi ./etc/apt/sources.list
sources.list追加的内容如下(使用的是中科大的软件源):
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
sudo mount -t proc /proc ./proc
sudo mount -t sysfs /sysfs ./sys
sudo mount -o bind /dev ./dev
sudo mount -o bind /dev/pts ./dev/pts
sudo chroot ./ # 此时当前目录是在ubuntu-base目录下
apt update
apt install sudo vim kmod net-tools ethtool ifupdown language-pack-en-base rsyslog iputils-ping
passwd root
echo "yourhostname" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 yourhostname" >> /etc/hosts
以串口1为例,它的名称为ttymxc0,所以使用以下ln命令创建一个软链接文件指向/lib/systemd/system/[email protected]
:
ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]
exit # 退出前面的chroot修改的根目录
sudo umount ./proc
sudo umount ./sys
sudo umount ./dev/pts
sudo umount ./dev
与其他rootfs类似,可以使用NFS挂载,也可以用于生成对应文件系统类型后直接烧写到flash上启动,只要你喜欢。
Ubuntu 16.04.6 LTS yourhostname ttymxc0
yourhostname login: root
Password:
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.1.15-g49efdaa armv7l)
...
root@yourhostname:~#
(注意:如果操作过程中提示有错误,可以考虑文件系统是否有rw读写权限!)
root@yourhostname:/# adduser linrm
Adding user `linrm' ...
Adding new group `linrm' (1000) ...
Adding new user `linrm' (1000) with group `linrm' ...
Creating home directory `/home/linrm' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for linrm
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
root@yourhostname:/#
root@yourhostname:/# ls /home/
linrm
root@yourhostname:/#
su
chmod u+w /etc/sudoers
vi /etc/sudoers
yourusername ALL=(ALL:ALL) ALL
chmod u-w /etc/sudoers
使用过程中可能会提示一下错误提示:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
那么还需要切换root用户下执行以下命令:
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
如果使用的是NFS网络文件系统,这一步暂时不用管。
sudo echo auto eth0 > /etc/network/interfaces.d/eth0
sudo echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
sudo /etc/init.d/networking restart