当前位置: 首页 > article >正文

FreeBSD里制作ubuntu22 jammy兼容环境的脚本

参考文档:https://book.bsdcn.org/di-21-zhang-linux-jian-rong-ceng/di-21.3-jie-linux-jian-rong-ceng-ji-yu-ubuntudebian

FreeBSD里制作ubuntu22 jammy兼容环境的脚本

#/bin/sh

rootdir=/compat/ubuntu22
baseurl="https://mirrors.ustc.edu.cn/ubuntu/"
codename=jammy

echo "begin to install ubuntu ..."
echo "check modules ..."

# check linux module
if [ "$(sysrc -n linux_enable)" = "NO" ]; then
        echo "linux module should be loaded. Continue?(N|y)"
        read answer
        case $answer in
                [Nn][Oo]|[Nn])
                        echo "linux module not loaded"
                        exit 1
                        ;;
                *)
                        sysrc linux_enable=YES
                        ;;
        esac
fi
echo "start linux"
service linux start

# check dbus
if ! /usr/bin/which -s dbus-daemon;then
        echo "dbus-daemon not found. install it [N|y]"
        read  answer
        case $answer in
            [Nn][Oo]|[Nn])
                echo "dbus not installed"
                exit 2
                ;;
            *)
                pkg install -y dbus
                ;;
        esac
    fi

if [ "$(sysrc -n dbus_enable)" != "YES" ]; then
        echo "dbus should be enable. Continue?(N|y)"
        read answer
        case $answer in
            [Nn][Oo]|[Nn])
                        echo "dbus not running"
                        exit 2
                        ;;
            *)
                        sysrc dbus_enable=YES
                        ;;
        esac
fi
echo "start dbus"
service dbus start

if ! /usr/bin/which -s debootstrap; then
        echo "debootstrap not found. install it? (N|y)"
        read  answer
        case $answer in
            [Nn][Oo]|[Nn])
                echo "debootstap not installed"
                exit 3
                ;;
            *)
                pkg install -y debootstrap
                ;;
        esac
    fi
echo "now we will bootstrap ${codename}.press any key."
read  answer

debootstrap ${codename} ${rootdir} ${baseurl}

if [ ! "$(sysrc -f /boot/loader.conf -qn nullfs_load)" = "YES" ]; then
        echo "nullfs_load should load. continue? (N|y)"
        read answer
        case $answer in
            [Nn][Oo]|[Nn])
                echo "nullfs not load"
				exit 4
                ;;
            *)
                sysrc -f /boot/loader.conf nullfs_load=yes
                ;;
        esac
    fi

if ! kldstat -n nullfs >/dev/null 2>&1;then
        echo "load nullfs module"
        kldload -v nullfs
fi

echo "mount some fs for linux"
echo "devfs ${rootdir}/dev devfs rw,late 0 0" >> /etc/fstab
echo "tmpfs ${rootdir}/dev/shm tmpfs rw,late,size=1g,mode=1777 0 0" >> /etc/fstab
echo "fdescfs ${rootdir}/dev/fd fdescfs rw,late,linrdlnk 0 0" >> /etc/fstab
echo "linprocfs ${rootdir}/proc linprocfs rw,late 0 0" >> /etc/fstab
echo "linsysfs ${rootdir}/sys linsysfs rw,late 0 0" >> /etc/fstab
echo "/tmp ${rootdir}/tmp nullfs rw,late 0 0" >> /etc/fstab
echo "/home ${rootdir}/home nullfs rw,late 0 0" >> /etc/fstab
mount -al

echo "add ustc apt sources"
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse" > /compat/ubuntu22/etc/apt/sources.list
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse" >> /compat/ubuntu22/etc/apt/sources.list

echo "remove rsyslog and install nano fonts-wqy-microhei  fonts-wqy-zenhei language-pack-zh-hans and wget"
chroot ${rootdir} /bin/bash -c "apt remove rsyslog && apt update && apt upgrade && apt install nano wget fonts-wqy-microhei  fonts-wqy-zenhei language-pack-zh-hans"
echo "Now you can run '#chroot /compat/ubuntu22/ /bin/bash' Into Ubuntu"

后期还需要把ubuntu里的/dev/null设为777

运行x11软件

xhost +x250

xhost后面跟主机名


 

调试:

apt update报错

E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Err:4 http://mirrors.ustc.edu.cn/ubuntu jammy-backports InRelease
  gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Reading package lists... Done
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu jammy InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu jammy-security InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu jammy-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu jammy-updates InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu jammy-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu jammy-backports InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu jammy-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Now you can run '#chroot /compat/ubuntu22/ /bin/bash' Into Ubuntu

 手动测试:

修改source.list文件,用https,然后执行:

chroot /compat/ubuntu22  /bin/bash -c "apt
remove rsyslog && apt update && apt upgrade "

还是报错

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'rsyslog' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
0% [Working]
Ign:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security Release [128 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security Release.gpg [833 B]     
0% [Waiting for headers]                                             424 B/s 0s/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Ign:3 http://security.ubuntu.com/ubuntu jammy-security Release.gpg             
0% [Waiting for headers]                                             424 B/s 1s^C
 

删掉,还是走mirror,

改成原始的

deb http://archive.ubuntu.com/ubuntu jammy main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security universe multiverse restri
cted main
deb http://archive.ubuntu.com/ubuntu jammy-backports universe multiverse restric
ted main
deb http://archive.ubuntu.com/ubuntu jammy-updates universe multiverse restricte
d main

 不行,到ubuntu22里,把null设为777

root@x250:/dev# chmod 777 null

再apt update,成功!

结论,就是需要手工将ubuntu里的/dev/null 权限设为777


http://www.kler.cn/a/518863.html

相关文章:

  • Neural networks 神经网络
  • 讯飞绘镜(ai生成视频)技术浅析(二):大模型
  • 【PowerQuery专栏】PowerQuery的M语言函数Access数据库访问
  • Spring Boot 自动配置
  • 如何解压rar格式文件?8种方法(Win/Mac/手机/网页端)
  • 32、【OS】【Nuttx】OSTest分析(1):stdio测试(二)
  • FAST-DDS and ROS2 RQT connect
  • npm启动前端项目时报错(vue) error:0308010C:digital envelope routines::unsupported
  • 代码练习2
  • 速通JS中的函数作用域与全局污染
  • 鸿蒙next 自定义日历组件
  • C++语法·食二
  • Python 字典排序:详解 sort()、reversed()、sorted()、cmp()
  • thinkphp6+swoole使用rabbitMq队列
  • GPMC介绍
  • Android 定位 获取当前位置 (Kotlin)
  • 企业信息化4:集团化企业的财务管理系统
  • 2025牛客寒假算法基础集训营1
  • C++异步future
  • hexo + Butterfly搭建博客
  • 【Django DRF Apps】从零搭建一个导出 Excel 和 PDF的app应用
  • 电力场效应晶体管(电力 MOSFET),全控型器件
  • 【ComfyUI专栏】ComfyUI 部署Kolors
  • 【实践】Python使用Pandas处理气象数据
  • 【数据分享】1929-2024年全球站点的逐日平均能见度(Shp\Excel\免费获取)
  • github配置SSH公钥后需要输入密码