RK3568构建Ubuntu22.04根文件系统

构建Ubuntu22.04根文件系统

一、官网下载ubuntu-base

http://cdimage.ubuntu.com/ubuntu-base/releases/
本文章使用的是:buntu-base-22.04.5-base-arm64.tar.gz
推荐一个:清华大学开源软件镜像站
https://mirror.tuna.tsinghua.edu.cn/help/ubuntu-ports/

#解压:

```bash
mkdir ubuntu_rootfs
sudo tar -zxvf ubuntu-base-22.04.5-base-arm64.tar.gz -C ubuntu22.04
sudo apt-get install qemu-user-static
sudo cp /usr/bin/qemu-arm-static ubuntu20.04/usr/bin/ 
chmod 777 ubuntu22.04/tmp
#挂载
sudo  ./mount_rootfs.sh -m ubuntu22.04
#!/bin/bash

# mount   : sudo  ./mount_rootfs.sh -m debian11_serve/
# unmount : sudo  ./mount_rootfs.sh -u debian11_serve/

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 bothparameters were missing"
    echo ""
    echo "1'st parameter can be one ofthese: -m(mount) OR -u(umount)"
    echo "2'nd parameter is the full pathof rootfs directory(with trailing '/')"
    echo ""
    echo "For example: ch-mount -m/media/sdcard/"
    echo ""
    echo 1st parameter : ${1}
    echo 2nd parameter : ${2}
fi

二、安装必备软件

apt-get update #首先更新源
apt-get upgrade #升级软件
apt-get install sudo -y
apt-get install openssh-server -y
apt-get install network-manager -y
apt-get install vim -y
apt-get install net-tools -y
apt-get install iproute2 -y
apt-get install udhcpc -y
apt install systemctl -y
apt install gcc -y
apt install make -y
apt install adb -y
apt install ethtool -y
apt install ifupdown -y
apt install htop -y
apt install iputils-ping -y
apt install -y bash-completion
apt install sudo vim udev net-tools ethtool udhcpc netplan.io iputils-ping openssh-sftp-server  ntp usbutils alsa-utils 

三、解决常见问题

  • 新建普通用户无法sudo
    问题描述:无法用sudo
    sudo:/usr/bin/sudo 必须属于用户 ID 0(的用户)并且设置 setuid 位
    解决方法:
    最终目的只有一个,想办法执行
$ chmod 4755 /usr/bin/sudo
$ chmod 755 /usr
  • 解决:perl: warning: Please check that your locale settings
    问题:
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = “zh_CN.UTF-8”,
    LC_TERMINAL_VERSION = “3.3.3beta2”,
    LC_TERMINAL = “iTerm2”,
    LANG = “en_US.utf8”
    are supported and installed on your system.
`sudo apt-get install language-pack-en-base language-pack-zh-han*`
在.bashrc的最后加上
export LC_ALL=C
source /root/.bashrc
或者/etc/profile
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
  • 开启 SSH,root 账号登录的方法

不建议开启,以下步骤仅供参考。
Debian 默认禁用 root SSH 密码登录(Pubkey 认证不受此限,默认启用),安装时候创建特定用户作为管理员帐号(通过 sudo 执行特权命令),启用 root 用户步骤如下:

#修改 root 密码(设置密码后可以通过控制台登录)
sudo passwd root
#修改配置文件(启用 SSH 密码登录)
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.baksudo vi /etc/ssh/sshd_config

找到下面相关配置:

# Authentication:#LoginGraceTime 2m#PermitRootLogin prohibit-password#StrictModes yes#MaxAuthTries 6#MaxSessions 10#PubkeyAuthentication yes# Expect .ssh/authorized_keys2 to be disregarded by default in future.#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2
#修改如下:
#补充:
PermitRootLogin prohibit-password  #允许 root 登录,但禁止使用密码认证可以配合使用 Pubkey 认证,默认 `PubkeyAuthentication yes`
#或者直接快速配置
sudo sed -i.bak "/^#PermitRootLogin/c"PermitRootLogin""yes"" /etc/ssh/sshd_config# 或者sudo sed -i.bak '/^#PermitRootLogin/c\PermitRootLogin yes' /etc/ssh/sshd_config
#重启服务生效
sudo systemctl restart ssh
  • 最近在Linux新增加用户时,发现新用户登录,终端只显示$,输入时tab键没有补全功能
usermod -s /bin/bash username
  • 使用sudo到出现输入密码提示延迟时间长,或卡死
    解决办法:
    查看当前 hostname,如PS提示符有提示也可。顺便看了下 /etc/hosts
    sudo 或 root 权限编辑 /etc/hosts,将你本机的 hostname 名称追加到 localhost 后,保存退出即可。
sudo vim /etc/hosts

至此,仅 sudo 卡而 su 不卡的问题解决。
分析原因:
sudo 命令执行时需要找到执行入口,默认是以hostname作为执行入口的地址。当 /etc/hosts 或 /etc/resolv.conf 中不含主机名映射时,就会等待直到超时,时间可能有15~20秒之间。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飘飘燃雪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值