栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

制作debian64位编译小系统

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

制作debian64位编译小系统

环境:linux操作系统

  1. sudo apt-get install debian-archive-keyring
  2. 安装依赖,使用debootstrap命令创建文件系统。
$ mkdir ~/build; cd ~/build

# 安装必要依赖 debootstrap就是构建的命令

$ sudo apt-get install qemu qemu-user-static binfmt-support debootstrap

# 构建文件系统的命令

$ sudo debootstrap --arch=amd64 --foreign stretch linux-rootfs http://ftp.cn.debian.org/debian/

# qemu-x86_64-static是其中的关键,能在 x86_64 主机系统下 chroot 到 amd64 文件系统

$ sudo cp -a /usr/bin/qemu-x86_64-static ~/build/linux-rootfs/usr/bin/qemu-x86_64-static

–arch:指定制作的文件系统是什么架构的

–foreign:在与主机架构不相同时需要指定此参数,仅做初始化的解包

stretch:这个是Debian 9的发行版本号,为什么没用最新的Debian 10的buster,因为更换国内的镜像源总是有点问题(https://www.debian.org/releases/)

linux-rootfs:这个是要存放文件系统的文件夹,可以不用先创建,执行上述命令会自动创建此文件夹,也可以先创建

http://ftp.cn.debian.org/debian/ :这个是中国镜像服务器地址,Debian 全球镜像站(https://www.debian.org/mirror/list)

  1. 执行挂载脚本:

# 此脚本有两个参数 -u 是取消挂载 -m 是挂载

$ ./ch-mount.sh -m linux-rootfs/

脚本内容如下:

#!/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

  1. # 执行脚本后,没有报错会进入文件系统,显示 I have no name ,这是正常的,不要慌张,我当时就有点懵逼,这是因为还没有初始化。

I have no name!@node2:/#

  1. 初始化文件系统:
debootstrap/debootstrap --second-stage

  1. 初始化完成后再次进入文件系统用户就会显示成root:
sudo chroot linux-rootfs
  1. 增加镜像源:

/etc/apt/sources.list 文件中增加 镜像源:deb http://mirrors.163.com/debian stretch main;也可增加其他需要的源。

8、apt-get update以及安装其他需要的软件。

9、完成之后取消挂载:

./ch-mount -u linux-rootfs/

参考:https://blog.csdn.net/qq_36956154/article/details/100606619

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/681694.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号