AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 556413
Accepted
Michael A
Michael A
Asked: 2019-12-10 12:05:16 +0800 CST2019-12-10 12:05:16 +0800 CST 2019-12-10 12:05:16 +0800 CST

如何使用 Debian 预置文件在 /etc/apt/sources.list 中设置镜像?

  • 772

我正在使用preseeding构建 Debian 10 stable(“buster”)的自定义 ISO 映像,并且我的自定义preseed.cfg文件可以完美运行,除了一件事:我希望它/etc/apt/sources.list使用我选择的存储库进行配置,这样我就不必每次安装新系统时手动执行。

目标是/etc/apt/sources.list这样的(这里必须使用 https):

deb https://deb.debian.org/debian buster main contrib non-free
deb-src https://deb.debian.org/debian buster main contrib non-free

deb https://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb-src https://deb.debian.org/debian-security/ buster/updates main contrib non-free

deb https://deb.debian.org/debian buster-updates main contrib non-free
deb-src https://deb.debian.org/debian buster-updates main contrib non-free

我的preseed.cfg文件如下所示:

#### Contents of the preconfiguration file (for buster)
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US

# Keyboard selection.
d-i keyboard-configuration/xkb-keymap select us
# d-i keyboard-configuration/toggle select No toggling

### Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/hostname string vienna1-preseed

d-i netcfg/wireless_wep string

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

### Account setup
d-i passwd/root-login boolean false

# To create a normal user account.
d-i passwd/user-fullname string theusername
d-i passwd/username string theusername
d-i passwd/user-password-crypted password $6$qVk198UWGPxpW$tzMYxQyiOrI4ClDJdDGALsyYq1j1IbXWbpem3JevFT9Krqdmt4wKdvtiY8ry3PRh277V6GHzSKP3zSI7jt04Y/

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern

d-i clock-setup/ntp boolean true

### Partitioning
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select atomic

d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true


# https://serverfault.com/a/622818
d-i apt-setup/use_mirror boolean false
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false
d-i apt-setup/cdrom/set-failed boolean false

### Base system installation
# Configure APT to not install recommended packages by default. Use of this
# option can result in an incomplete system and should only be used by very
# experienced users.
#d-i base-installer/install-recommends boolean false

### Apt setup
# You can choose to install non-free and contrib software.
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true

### Package selection
tasksel tasksel/first multiselect standard
d-i pkgsel/upgrade select full-upgrade
popularity-contest popularity-contest/participate boolean false

### Boot loader installation
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev  string default

d-i finish-install/reboot_in_progress note
d-i debian-installer/exit/poweroff boolean true
debian apt
  • 2 2 个回答
  • 2650 Views

2 个回答

  • Voted
  1. Best Answer
    Michael A
    2019-12-10T12:05:16+08:002019-12-10T12:05:16+08:00

    中的d-i preseed/late_command string命令preseed.cfg做你想做的事。我sources.list在iso中添加了一个自定义文件,然后在安装完成后将其复制过来。在preseed.cfg.

    d-i preseed/late_command string \
    cp sources.list /target/etc/apt/sources.list; \
    in-target apt-get update; \
    in-target apt-get install -y git;
    

    最后两个命令演示了更新包列表和安装不包含在 cd (git) 中的包。

    以下是我使用 newpreseed.cfg和 new 构建 iso 映像的方法sources.list:

    #!/usr/bin/env bash
    
    # Install dependencies
    # sudo apt install isolinux syslinux-utils xorriso
    
    cd ~
    mkdir iso
    xorriso -osirrox on -indev debian-10.2.0-amd64-netinst.iso -extract / iso/
    
    chmod +w -R iso/install.amd/
    gunzip iso/install.amd/initrd.gz
    echo preseed.cfg | cpio -H newc -o -A -F iso/install.amd/initrd
    echo sources.list | cpio -H newc -o -A -F iso/install.amd/initrd
    gzip iso/install.amd/initrd
    chmod -w -R iso/install.amd/
    
    cd iso/
    chmod +w md5sum.txt
    md5sum `find -follow -type f` > md5sum.txt
    cd ..
    
    xorriso -as mkisofs -o preseed.iso -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table iso
    

    该脚本假定您正在使用 Debian 10 stable(“buster”)amd64,preseed.cfg并且sources.list文件位于您用于构建 iso 的任何系统的主目录中。

    • 2
  2. user507099
    2021-12-22T04:18:15+08:002021-12-22T04:18:15+08:00
    d-i preseed/late_command string \
        echo "{{source1}}" > /target/etc/apt/sources.txt; \
        echo "{{source2}}" >> /target/etc/apt/sources.txt; \
        echo "{{source3}}" >> /target/etc/apt/sources.txt; \
        in-target mv /etc/apt/sources.txt /etc/apt/sources.list; \
        in-target chmod 644 /etc/apt/sources.list; \
        in-target apt update && apt-get dist-upgrade -y; \
    
    • 0

相关问题

  • GRUB 配置以识别同一 Linux 发行版的不同桌面环境(安装)

  • astyle 不会更改源文件格式

  • 接收有关全新 Debian 的电子邮件

  • Debian Stretch:libgs_plugin_systemd-updates.so 中的 gnome-software 段错误

  • 如何在拼音输入法中输入ü?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve