首页交流分享ubuntu22.04.05 U盘全自动安装--硬盘分区方法

ubuntu22.04.05 U盘全自动安装--硬盘分区方法

时间2024-10-21 08:53:39发布caterwang分类交流分享 评论1浏览36

    折腾了一个星期,综合网上的分享经验和官网说明,总结整理一个硬盘分区的方法。

    1.背景

    需要把centos7下的程序移植到ubuntu22.04下,同时硬盘分区也需要按之前的来划分,并且要求在生产时用U盘装系统,要实现自动安装,即语言、键盘、网络及硬盘分区的设置要做到无人值守。

    第一次安装时手动配置,完了后取出相应的配置文件

/var/log/installer/autoinstall-user-data

    这个配置文件的内容就是我们接下来要实现自动安装的重要文件,以经包含了所有手动安装时做的配置。本文重点分享硬盘分区,因为手动安装的配置文件中硬盘部分是无法直接用于其他机器上的。典型的报错信息如下(只知道有错误,不知道具体原画,看日志文件也看不出来什么):

 

微信截图_20241021090906.png

  

    2.手撕配置文件 

    官网文档关于硬盘分区的说明部分:Storage — curtin 23.1.1 documentation

    以下得到的配置文件重命名为 user-data 并取消只读属性,然后修改 storage 部分如下

  storage:
    config:
    - id: disk-sda
      type: disk
      ptable: gpt
      wipe: superblock-recursive
      preserve: false
      grub_device: false
      path: /dev/sda
      
    - id: disk-sda-part1
      type: partition
      device: disk-sda
      number: 1
      offset: 1048576
      size: 1.5G
      wipe: superblock
      flag: boot
      preserve: false
      grub_device: true
    - id: disk-sda-part1-fs
      type: format
      fstype: fat32
      volume: disk-sda-part1
    - id: disk-sda-part1-fs-mount
      type: mount
      path: /boot/efi
      device: disk-sda-part1-fs
      
    - id: disk-sda-part2
      type: partition
      device: disk-sda
      number: 2
      size: 1G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part2-fs
      type: format
      fstype: ext4
      volume: disk-sda-part2
    - id: disk-sda-part2-fs-mount
      type: mount
      path: /boot
      device: disk-sda-part2-fs
     
    - id: disk-sda-part3
      type: partition
      device: disk-sda
      number: 3
      size: 8G
      wipe: superblock
      flag: swap
      preserve: false
      grub_device: false
    - id: disk-sda-part3-fs
      type: format
      fstype: swap
      volume: disk-sda-part3
    - id: disk-sda-part3-fs-mount
      type: mount
      path: ''
      device: disk-sda-part3-fs
      
    - id: disk-sda-part4
      type: partition
      device: disk-sda
      number: 4
      size: 25G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part4-fs
      type: format
      fstype: ext4
      volume: disk-sda-part4
    - id: disk-sda-part4-fs-mount
      type: mount
      path: /
      device: disk-sda-part4-fs
      
    - id: disk-sda-part5
      type: partition
      device: disk-sda
      number: 5
      size: 3G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part5-fs
      type: format
      fstype: ext4
      volume: disk-sda-part5
    - id: disk-sda-part5-fs-mount
      type: mount
      path: /tmp
      device: disk-sda-part5-fs
      
    - id: disk-sda-part6
      type: partition
      device: disk-sda
      number: 6
      size: 5G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part6-fs
      type: format
      fstype: ext4
      volume: disk-sda-part6
    - id: disk-sda-part6-fs-mount
      type: mount
      path: /var
      device: disk-sda-part6-fs
    - id: disk-sda-part7
      type: partition
      device: disk-sda
      number: 7
      size: 1G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part7-fs
      type: format
      fstype: ext4
      volume: disk-sda-part7
    - id: disk-sda-part7-fs-mount
      type: mount
      path: /hriSafe
      device: disk-sda-part7-fs
    - id: disk-sda-part8
      type: partition
      device: disk-sda
      number: 8
      size: 5G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part8-fs
      type: format
      fstype: ext4
      volume: disk-sda-part8
    - id: disk-sda-part8-fs-mount
      type: mount
      path: /hriBack
      device: disk-sda-part8-fs
    - id: disk-sda-part9
      type: partition
      device: disk-sda
      number: 9
      size: 1.5G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part9-fs
      type: format
      fstype: ext4
      volume: disk-sda-part9
    - id: disk-sda-part9-fs-mount
      type: mount
      path: /hrifs
      device: disk-sda-part9-fs
    - id: disk-sda-part10
      type: partition
      device: disk-sda
      number: 10
      size: 15G
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part10-fs
      type: format
      fstype: ext4
      volume: disk-sda-part10
    - id: disk-sda-part10-fs-mount
      type: mount
      path: /hriData
      device: disk-sda-part10-fs
    - id: disk-sda-part11
      type: partition
      device: disk-sda
      number: 11
      size: -1
      wipe: superblock
      preserve: false
      grub_device: false
    - id: disk-sda-part11-fs
      type: format
      fstype: ext4
      volume: disk-sda-part11
    - id: disk-sda-part11-fs-mount
      type: mount
      path: /hriVCR
      device: disk-sda-part11-fs
    - id: disk-sdb
      type: disk
      ptable: gpt
      wipe: superblock-recursive
      preserve: false
      grub_device: false
      path: /dev/sdb
    - id: disk-sdb-part1
      type: partition
      device: disk-sdb
      number: 1
      size: -1
      wipe: superblock
      flag: linux
      preserve: false
      grub_device: false
    - id: disk-sdb-part1-fs
      type: format
      fstype: ext4
      volume: disk-sdb-part1
    - id: disk-sdb-part1-fs-mount
      type: mount
      path: /hriVCR2
      device: disk-sdb-part1-fs


简单说明一下,硬盘1是通过

path: /dev/sda

与系统匹配的

微信截图_20241021091959.png

以上说明简单说明了,硬盘与分区,分区与格式化和挂载部分如何关联的,配置文件中各项关键字的含义,请参考官方文件说明Storage — curtin 23.1.1 documentation

最终的分区效果

微信截图_20241021092911.png

    

凯特网版权声明:以上内容允许转载,但请注明出处,谢谢!

展开全文READ MORE
linux下另一种实现ping的方法 ubuntu22.04.05 U盘全自动安装--镜像修改

游客 回复需填写必要信息
caterwang
又发现一个问题,用这个配置时,不能接网线刷机
caterwang2024-10-22 10:08:35回复