ubuntu文件系统制作(从无到有)

ubuntu文件系统制作(从无到有) 艾编程的鲁小班 2023-02-01 09:16:54 2703

目录


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个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
关于作者
艾编程的鲁小班

艾编程的鲁小班

一个爱技术的人

原创17
阅读5.1w
收藏11
点赞19
评论3
打赏用户 0
我要创作
分享技术经验,可获取创作收益
分类专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
艾编程的鲁小班
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区