技术专栏
ubuntu文件系统制作(从无到有)
1011
打赏
- 收藏
- 点赞
- 分享
- 举报
目录
1,下载ubuntu-base
2,解压文件
3,安装 qemu
4,设置源
5,挂载文件系统
6,设置账户名和密码
7,添加主机入口到/etc/hosts
8,添加nameserver
9,安装桌面
10,取消挂载
11,制作IMG镜像
1,下载ubuntu-base
https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/ubuntu-base/releases/20.04/release/
2,解压文件
mkdir ubuntu2004-rootfs
sudo tar -xpvf ubuntu-base-20.04.5-base-arm64.tar.gz -C ubuntu2004-rootfs
3,安装 qemu
sudo apt-get install qemu-user-static
sudo cp /usr/bin/qemu-arm-static ubuntu2004-rootfs/usr/bin/
4,设置源
#将主机DNS拷贝至虚拟机,为了方便虚拟机能上网
sudo cp /etc/resolv.conf ./etc/resolv.conf
安装apt-transport-https工具
apt update
apt install apt-transport-https
遇到问题
问题:Ceritificate verification failed:
Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal Release
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
解决办法
touch apt/apt.conf.d/99verify-peer.conf \
&& echo >>/etc/apt/apt.conf.d/99verify-peer.conf "Acquire { https::Verify-Peer false }"
问题2
apt install --reinstall ca-certificates
5,挂载文件系统
挂载脚本(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 mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
function umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
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
chmod a+x ch-mount.sh
./ch-mount.sh -m ubuntu-rootfs/
6,设置账户名和密码
7,设置主机名useradd -s '/bin/bash' -m -G adm,sudo joyu
passwd joyu
passwd root
echo 'ubuntu.joyu' > /etc/hostname
7,添加主机入口到/etc/hosts
127.0.0.1 localhost
127.0.0.1 ubuntu.joyu
127.0.1.1 joyu
8,添加nameserver
vim /etc/resolvconf/resolv.conf.d/head
#添加nameserver
nameserver 114.114.114.114
nameserver 8.8.8.8
9,安装桌面
安装桌面软件,包括系统面板、窗口管理器、文件浏览器、终端等各类桌面应用程序。
apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop
10,取消挂载
exit
./ch-mount.sh -u ubuntu-rootfs/
11,制作IMG镜像
dd if=/dev/zero of=ubuntu2004-rootfs.img bs=1M count=4000
mkfs.ext4 ubuntu2004-rootfs.img
sudo mount ubuntu2004-rootfs.img rootfs/
sudo cp -rfp ubuntu-rootfs/* rootfs/
sudo umount rootfs/
e2fsck -p -f ubuntu2004-rootfs.img
resize2fs -M ubuntu2004-rootfs.img
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
评论
0个
时间排序
共 0 条记录 第
0 / 页
相关专栏
-
浏览量:2198次2020-08-30 10:04:00
-
浏览量:44次2023-03-20 14:39:03
-
浏览量:2269次2020-02-28 16:10:06
-
浏览量:2394次2017-11-16 11:37:49
-
浏览量:1383次2017-12-15 16:32:59
-
浏览量:2086次2020-04-27 16:58:40
-
浏览量:4221次2020-04-22 13:48:27
-
浏览量:6520次2020-11-10 20:43:55
-
浏览量:1746次2021-12-23 15:45:38
-
浏览量:1625次2020-05-21 19:20:01
-
浏览量:3827次2017-11-30 17:16:20
-
浏览量:1225次2020-08-28 15:08:37
-
浏览量:2578次2020-08-30 12:27:19
-
2020-11-09 12:31:13
-
浏览量:5843次2020-11-15 20:39:00
-
浏览量:1588次2022-10-17 20:51:39
-
浏览量:2628次2020-08-19 16:34:45
-
浏览量:3561次2022-06-01 09:36:28
-
浏览量:1951次2020-09-30 16:48:30
关于作者

艾编程的鲁小班
一个爱技术的人
文章
25
问答
17
我要创作
分享技术经验,可获取创作收益
切换马甲
上一页
下一页
打赏作者

艾编程的鲁小班
您的支持将鼓励我继续创作!
打赏金额:
¥1

¥5

¥10

¥50

¥100

支付方式:

举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注