【求教】U盘全自动安装ubuntu22.04Server教程

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
caterwang
帖子: 2
注册时间: 2024-10-17 14:28

U盘全自动安装ubuntu22.04Server autoinstall 不生效

#1

帖子 caterwang » 2024-10-17 14:49

2.png
需求:
通过U盘全自动安装系统,除了启动时,其他时间不需要人工干预,自动按autoinstall配置文件完成肩语言、网卡及硬盘分区的工作,并最终完成系统的安装。

实现方法:
1.在U盘根目录新建文件夹 server 并放入配置文件 meta-data 和 user-data 。

以下内容是 user-data 文件内容(是基于手动安装后拷贝的安装文件做了许修改)

代码: 全选

#cloud-config
# See the autoinstall documentation at:
# https://canonical-subiquity.readthedocs-hosted.com/en/latest/reference/autoinstall-reference.html
autoinstall:
  apt:
    disable_components: []
    fallback: offline-install
    geoip: true
    mirror-selection:
      primary:
      - country-mirror
      - arches: &id001
        - amd64
        - i386
        uri: http://archive.ubuntu.com/ubuntu/
      - arches: &id002
        - s390x
        - arm64
        - armhf
        - powerpc
        - ppc64el
        - riscv64
        uri: http://ports.ubuntu.com/ubuntu-ports
    preserve_sources_list: false
    security:
    - arches: *id001
      uri: http://security.ubuntu.com/ubuntu/
    - arches: *id002
      uri: http://ports.ubuntu.com/ubuntu-ports
  codecs:
    install: false
  drivers:
    install: false
  identity:
    hostname: hri-isp
    password: $6$o53wh2M9AT0e8t//$hIjf/8gMmr5sET0ksVvbY9jZ5JXfr/5sTYu7aXiLO5ZR.nB2UmTwzs/uk5IkTBQIjGhhVDzvBcdB9ZeY2FqFg0
    realname: hri
    username: hri
  kernel:
    package: linux-generic
  keyboard:
    layout: us
    toggle: null
    variant: ''
  locale: en_US.UTF-8
  network:
    ethernets:
      eno1:
        addresses:
        - 192.168.61.21/24
        nameservers:
          addresses:
          - 114.114.114.114
          - 8.8.8.8
          search: []
        routes:
        - to: default
          via: 192.168.61.1
    version: 2
  oem:
    install: auto
  source:
    id: ubuntu-server
    search_drivers: false
  ssh:
    allow-pw: true
    authorized-keys: []
    install-server: true
  storage:
    config:
    - ptable: gpt
      serial: aigo_SSD_S500E_120GB_AHJ9082B17A1111
      path: /dev/sda
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: false
      id: disk-sda
      type: disk
    - device: disk-sda
      size: 1.05G
      wipe: superblock
      flag: boot
      number: 1
      preserve: false
      grub_device: true
      offset: 1048576
      path: /dev/sda1
      id: partition-0
      type: partition
    - fstype: fat32
      volume: partition-0
      preserve: false
      id: format-0
      type: format
    - device: disk-sda
      size: 25G
      wipe: superblock
      number: 2
      preserve: false
      grub_device: false
      offset: 1128267776
      path: /dev/sda2
      id: partition-1
      type: partition
    - fstype: ext4
      volume: partition-1
      preserve: false
      id: format-1
      type: format
    - path: /
      device: format-1
      id: mount-2
      type: mount
    - device: disk-sda
      size: 8G
      wipe: superblock
      flag: swap
      number: 3
      preserve: false
      grub_device: false
      offset: 27971813376
      path: /dev/sda3
      id: partition-2
      type: partition
    - fstype: swap
      volume: partition-2
      preserve: false
      id: format-2
      type: format
    - path: ''
      device: format-2
      id: mount-3
      type: mount
    - device: disk-sda
      size: 1G
      wipe: superblock
      number: 4
      preserve: false
      grub_device: false
      offset: 36561747968
      path: /dev/sda4
      id: partition-3
      type: partition
    - fstype: ext4
      volume: partition-3
      preserve: false
      id: format-3
      type: format
    - path: /boot
      device: format-3
      id: mount-4
      type: mount
    - device: disk-sda
      size: 5G
      wipe: superblock
      number: 5
      preserve: false
      grub_device: false
      offset: 37635489792
      path: /dev/sda5
      id: partition-4
      type: partition
    - fstype: ext4
      volume: partition-4
      preserve: false
      id: format-4
      type: format
    - path: /tmp
      device: format-4
      id: mount-5
      type: mount
    - device: disk-sda
      size: 5G
      wipe: superblock
      number: 6
      preserve: false
      grub_device: false
      offset: 43004198912
      path: /dev/sda6
      id: partition-5
      type: partition
    - fstype: ext4
      volume: partition-5
      preserve: false
      id: format-5
      type: format
    - path: /var
      device: format-5
      id: mount-6
      type: mount
    - device: disk-sda
      size: 1.5G
      wipe: superblock
      number: 7
      preserve: false
      grub_device: false
      offset: 48372908032
      path: /dev/sda7
      id: partition-6
      type: partition
    - fstype: ext4
      volume: partition-6
      preserve: false
      id: format-6
      type: format
    - path: /hriSafe
      device: format-6
      id: mount-7
      type: mount
    - device: disk-sda
      size: 1.5G
      wipe: superblock
      number: 8
      preserve: false
      grub_device: false
      offset: 49983520768
      path: /dev/sda8
      id: partition-7
      type: partition
    - fstype: ext4
      volume: partition-7
      preserve: false
      id: format-7
      type: format
    - path: /hriBack
      device: format-7
      id: mount-8
      type: mount
    - device: disk-sda
      size: 1.5G
      wipe: superblock
      number: 9
      preserve: false
      grub_device: false
      offset: 51594133504
      path: /dev/sda9
      id: partition-8
      type: partition
    - fstype: ext4
      volume: partition-8
      preserve: false
      id: format-8
      type: format
    - path: /hrifs
      device: format-8
      id: mount-9
      type: mount
    - device: disk-sda
      size: 15G
      wipe: superblock
      number: 10
      preserve: false
      grub_device: false
      offset: 53204746240
      path: /dev/sda10
      id: partition-9
      type: partition
    - fstype: ext4
      volume: partition-9
      preserve: false
      id: format-9
      type: format
    - path: /hriData
      device: format-9
      id: mount-10
      type: mount
    - device: disk-sda
      size: -1
      wipe: superblock
      number: 11
      preserve: false
      grub_device: false
      offset: 69310873600
      path: /dev/sda11
      id: partition-10
      type: partition
    - fstype: ext4
      volume: partition-10
      preserve: false
      id: format-10
      type: format
    - path: /hriVCR
      device: format-10
      id: mount-11
      type: mount
    - path: /boot/efi
      device: format-0
      id: mount-1
      type: mount
	  
    - ptable: gpt
      path: /dev/sdb
      preserve: true
      name: ''
      grub_device: false
      id: disk-sdb
      type: disk
    - device: disk-sdb
      flag: linux
      number: 1
      preserve: true
      grub_device: false
      offset: 1048576
      path: /dev/sdb1
      id: partition-sdb1
      type: partition
    - fstype: ext4
      volume: partition-sdb1
      preserve: true
      id: format-11
      type: format
    - path: /hriVCR2
      device: format-11
      id: mount-12
      type: mount
	  
    swap:
      size: 0
  updates: security
  version: 1
2.修改配置文件 boot/grub/grub.cfg

代码: 全选

set timeout=30

loadfont unicode

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

menuentry "Install Ubuntu22.04.05 Server for HriISP" {
	set gfxpayload=keep
	linux	/casper/vmlinuz autoinstall ds=nocloud\;s=/cdrom/server/  ---
	initrd	/casper/initrd
}
3.插上U盘并让主机从U盘启动,选择 “Install Ubuntu22.04.05 Server for HriISP”进入,安装

:What 遇到的问题:
1.不能实现自动安装,还是会进入到语言、等引导设置过程;
2.移除 storage 部分的配置后,能自动安装完成,但这样就失去了自动安装的意义。
caterwang
帖子: 2
注册时间: 2024-10-17 14:28

【求教】U盘全自动安装ubuntu22.04Server教程

#2

帖子 caterwang » 2024-10-17 15:19

自己已经按网上提的教程尝试过了,但是并不能真正实现U盘全自动安装。我的需求如下:
1.自定义的硬盘分区--大头
2.自定义的预配置网络

就是说我有一批同配置的机器需要装系统,一个U盘来搞定,每台只需要启动时人工参与,后续的语言选择、硬盘分区等都不需要人工参与。
onlylove
论坛版主
帖子: 5369
注册时间: 2007-01-14 16:23

Re: 【求教】U盘全自动安装ubuntu22.04Server教程

#3

帖子 onlylove » 2024-10-17 17:44

请不要重复发内容相似的帖子

既然你移除了storage的配置能自动完成,就证明你storage的配置有问题,关注下storage方面就可以了

https://canonical-subiquity.readthedocs ... stall.html

https://askubuntu.com/questions/1235529 ... ge-section

https://hmli.ustc.edu.cn/doc/linux/ubun ... .html#id14
头像
大宝
帖子: 3077
注册时间: 2008-06-30 22:32
联系:

Re: 【求教】U盘全自动安装ubuntu22.04Server教程

#4

帖子 大宝 » 2024-10-22 22:19

除了用镜相还原,还没试过全自动安装呢
lurensanqian3000
帖子: 3
注册时间: 2025-03-09 20:54
系统: windows11

Re: 【求教】U盘全自动安装ubuntu22.04Server教程

#5

帖子 lurensanqian3000 » 2025-03-09 22:45

大佬,有测试成功过么,请教一下,怎么实现的呀
回复