zoukankan      html  css  js  c++  java
  • debootstrap折腾

    安装

    sudo apt-get install debootstrap


    下载rootfs

    debootstrap --no-check-gpg --arch=amd64 --include=vim,ca-certificates,net-tools,iputils-ping,iputils-tracepath,iproute,bash,aptitude,locales-all,openssh-server,openssh-client jessie debian-jessie http://mirrors.ustc.edu.cn/debian

    这里用的jessie,其实就是 debian 8, 是一个比较就的稳定版


    尝试下载 stretch(debian 9)和 buster(debian 10), 发现最高只能到9。  10下载的不完整,有问题。 难道是源的问题?

    james@james-virtual-machine:~/x86/debootstrap/test$ ls debian*
    debian10:
    debootstrap  var

    debian9:
    bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var


    chroot

    用下面脚本

    ./ch-mount.sh -m jessie

    是可以用的。





    下载内核:

    apt-get install linux-image-amd64


    解压内核

    参考https://access.redhat.com/solutions/24029

    cd /boot

    zcat initrd.img-3.16.0-6-amd64 | cpio -idmv


    打包内核:

    find . | cpio -o -c -R root:root | gzip -9 > /boot/new.img

    分析 /init

    vi init

    启动后会去挂载真实的root

    具体分析见另一篇文章




    查看debian版本:

    cat /etc/os-release
    PRETTY_NAME="Debian GNU/Linux 10 (buster)"
    NAME="Debian GNU/Linux"
    VERSION_ID="10"
    VERSION="10 (buster)"
    VERSION_CODENAME=buster
    ID=debian
    HOME_URL="https://www.debian.org/"
    SUPPORT_URL="https://www.debian.org/support"
    BUG_REPORT_URL=https://bugs.debian.org/




    chroot-mnt.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

  • 相关阅读:
    转载:KOF97东丈
    写一个ajax程序就是如此简单
    转载:97特瑞心得
    老生常谈:享元模式
    获得微软最有影响力开发者
    老生常谈设计模式系列文章索引
    asp.net中的异步页面
    转载:KOF97简易出招原理解析
    leaks 使用手册
    ObjectiveC中一种消息处理方法performSelector: withObject:
  • 原文地址:https://www.cnblogs.com/cute/p/14133839.html
Copyright © 2011-2022 走看看