ubuntu 22.04 - jammy - autoinstall - pxe 自动安装

上一篇,测试了 debian 11 的pxe自动安装:https://liujia.anqun.org/index.php/archives/3994/ 。 这里想试试 ubuntu 22.04的。

  1. /srv/tftp/os-images/bullseye/netboot/pxelinux.cfg/01-08-00-27-49-b4-6c # 偷懒,直接使用 debian 11 netboot 中的 pxelinux 文件。仅对pxelinux的配置文件内容做改动。其中 vmlinuz 和 initrd 是从 ubuntu-22.04.1-live-server-amd64.iso 提取到的。http://192.168.3.1/jammy/ 中有 user-data 和 meta-data 配置文件

    DEFAULT linux
     SAY Now booting the kernel from SYSLINUX...
    LABEL linux
    #  KERNEL debian-installer/amd64/linux
    #  APPEND auto=true hostname=auto2 domain=local preseed/url=tftp://192.168.3.1/os-images/bullseye/preseed.cfg initrd=debian-installer/amd64/initrd.gz
    
    KERNEL http://192.168.3.1/jammy/vmlinuz
    INITRD http://192.168.3.1/jammy/initrd
    APPEND ip=dhcp autoinstall ds=nocloud-net;s=http://192.168.3.1/jammy/ url=http://192.168.3.1/jammy/ubuntu-22.04.1-live-server-amd64.iso
  2. http://192.168.3.1/jammy/user-data # 自动安装的应答文件内容,这里仅设置用户及安装openssh-server

    #cloud-config
    autoinstall:
     identity:
    hostname: jammy2
    password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
    username: ubuntu
     locale: zh_CN.UTF-8
     ssh:
    install-server: yes
     late-commands:
     - 'echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/ubuntu-nopw'
     - chmod 440 /target/etc/sudoers.d/ubuntu-nopw
     version: 1

遇到的问题,安装ubuntu 22.04的虚拟机分配了4GB内存,还不够用,用6GB内存后才顺利安装完成。

参考:

debian 11 网络远程自动安装测试 - pxe - preseed.cfg

如机房的机子,一般是远程管理,不方便实地用光盘或U盘安装系统,如 debian 11 是提供了完整的网络安装 netboot 文件及自动配置安装参数 preseed.cfg 的说明。

环境:用 VirtualBox 来创建两个虚拟机,A机为pxe服务所在的机子,B机当客户机。A机安装debian 11,分配两张网卡,一张公网,另一张是内网(enp0s8)

步骤:

  1. apt install dnsmasq # 在A机安装dnsmasq,为B机自动自动分配IP及网络引导启动、安装系统
  2. /etc/dnsmasq.conf # 配置文件内容。大概是设置好tftp的路径 /srv/tftp ,及为B机(传统BIOS启动)设置启动文件为 os-images/bullseye/netboot/pxelinux.0

    interface=enp0s8
    domain=debian.local
    dhcp-range=192.168.3.3,192.168.3.253,255.255.255.0,1h
    enable-tftp
    tftp-root=/srv/tftp
    # dhcp-optsfile=/etc/dnsmasq.opt
    #dhcp-match=ipxe,175
    # dhcp-boot=net:ipxe,default.ipxe
    # pxe-service=x86PC,"ipxe bios", ipxe/undionly.kpxe
    # pxe-service=tag:x86-64_efi,"ipxe efi", ipxe/ipxe.efi
    
    dhcp-match=set:bios-x86,option:client-arch,0
    # dhcp-boot=tag:bios-x86,ipxe/undionly.kpxe
    dhcp-boot=tag:bios-x86,os-images/bullseye/netboot/pxelinux.0
    
    # boot config for UEFI systems
    # dhcp-match=set:efi-x86_64,option:client-arch,7
    # dhcp-match=set:efi-x86_64,option:client-arch,9
    # dhcp-boot=tag:efi-x86_64,ipxe/ipxe.efi
    
    # dhcp-match=set:ipxe,175
    # dhcp-boot=tag:ipxe,http://192.168.3.1/boot2.php
    # dhcp-userclass=set:ENH,iPXE
    # dhcp-boot=tag:ENH,default.ipxe
  3. /srv/tftp/os-images/bullseye/netboot/pxelinux.cfg/01-08-00-27-49-b4-6c # 以B机的网卡mac地址为名创建一个pxelinux的启动配置文件内容。大概是将debian的自动应答文件preseed.cfg作为启动参数加载

    DEFAULT linux
     SAY Now booting the kernel from SYSLINUX...
    LABEL linux
     KERNEL debian-installer/amd64/linux
     APPEND auto=true hostname=auto2 domain=local preseed/url=tftp://192.168.3.1/os-images/bullseye/preseed.cfg initrd=debian-installer/amd64/initrd.gz
  4. os-images/bullseye/preseed.cfg # 文件内容。目的是自动回答安装过程中的问题,无人值守就可以完成系统安装

    #### Contents of the preconfiguration file (for bullseye). refer: https://www.debian.org/releases/bullseye/example-preseed.txt
    d-i debian-installer/locale string en_US
    d-i keyboard-configuration/xkb-keymap select us
    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 auto1
    d-i netcfg/wireless_wep string
    d-i mirror/country string manual
    d-i mirror/http/hostname string ftp.cn.debian.org
    d-i mirror/http/directory string /debian
    d-i mirror/http/proxy string
    d-i passwd/root-password password r00tme
    d-i passwd/root-password-again password r00tme
    d-i passwd/user-fullname string Debian User
    d-i passwd/username string debian
    d-i passwd/user-password password insecure
    d-i passwd/user-password-again password insecure
    d-i clock-setup/utc boolean true
    d-i time/zone string US/Eastern
    d-i clock-setup/ntp boolean true
    d-i partman-auto/method string lvm
    d-i partman-auto-lvm/guided_size string max
    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
    d-i apt-setup/cdrom/set-first boolean false
    tasksel tasksel/first multiselect standard, ssh-server
    popularity-contest popularity-contest/participate boolean true
    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
  5. /etc/nftables.conf # 如果A机要为B机充当网关,转发上网,还需要配置一下。发现一个现象是B机有时上不了外网,要重启一下nftables服务

    #!/usr/sbin/nft -f
    
    flush ruleset
    
    table inet filter {
        chain input {
                type filter hook input priority 0;
        }
        chain forward {
                type filter hook forward priority 0;
        }
        chain output {
                type filter hook output priority 0;
        }
    }
    
    #######
    table inet nat {
        chain input {
                type nat hook input priority 0; policy accept;
                ip protocol icmp accept
        }
    
        chain prerouting {
                type nat hook prerouting priority 0; policy accept;
        }
    
        chain postrouting {
                type nat hook postrouting priority 100; policy accept;
    #               ip saddr 192.168.3.0/24 oifname "enp0s3" masquerade
                oifname "enp0s3" masquerade
        }
    
        chain output {
                type nat hook output priority 0; policy accept;
        }
    }

参考:

晚夜骑单车(火车站路)

导师喊晚夜骑单车,我话我夜头视力不得,不敢骑。导师话骑火车站路,路大、车少,路灯还皓。我八点半左右在县中医院公交站牌见到导师,出发。我们在辅道骑,骑的速度慢:比行路快滴,捞人慢跑差不多。

晚夜骑单车,系较凉,且时不时有风吹过来,好舒服的。一路上,到火车站路口,人行道上有不少人散步,三三两两。过了火车站,就较少人散步了,多了不少摆稳红塑料凳的凉粉摊。有部分人,专门骑摩托或开小车到这,再步行散步或聊天说凉粉。我们并排着骑,边骑边讲话。导师话,爱一直骑到冇路灯的地段转头。我们就一直骑,本以为骑到大转弯那会冇路灯,就转头。乃只知得,一直都有路灯。导师骑到较快,一下子就见不到佢嘅车尾灯了,我沿大路向前骑。骑到有的路段,较暗下,蚊水不时从路灯下掠过,映到地下,一只会飘着走的黑影。我有滴怕,四周静悄悄的,我只听到单车后轮轮在路面的嚓嚓声,车速越快,嚓嚓声就越密,仿佛系有人在旁边催。我硬稳头皮继续骑。骑稳、骑稳,路面有两哒黑影,我闪不及,前轮压上,车身一震。可能系水泥块,我心里想。

好不容易骑到路边有摆凉粉摊的,我放慢了车速,再走一段,睇到停在路边的导师,我很高兴。我落车,捏前、后轮,怕单车有漏气或爆胎。好得,不曾,车还骑得到。我们决定继续向前,打大坝公路归了。

穿到大坝公路时,我傻了眼。冇路灯的,且来来往往,好多车掠稳过。其中有小车、有大货车。无论小车、大货车开得速度都快。无奈,我只好上单车,沿着路边慢慢骑。大坝路不好走啊:路边沙多、不时有水滩;路面不平、裂缝多。更要命的是,冇路灯,连路边的人家屋都冇。前边开来的车远光灯照来是全白的,睇不见路,晃眼。我骑稳、骑稳,觉得这段路怎么这么长,怎么还没到九子岗,我怕走了相反的方向。我赶紧大声问导师:“吖咪走错路?里下系落稳大坝?”导师好像用布蒙着嘴(防尘)答:“不系。走到冇错,冇错哩。”我静下心来,惹都不想,就睇稳前边嘅车灯,继续骑。终于骑到兴隆坝桥前边,我们转到滨河东路,算系到了较舒服嘅路段。我约九点四十分到家。

支付宝 - 基金 - 万家民瑞祥和6个月持有期债券A - 购买后182天赎回到账 - 到手年化收益率 4.21%

我通过支付宝app,在 2022-02-16 购买基金产品——万家民瑞祥和6个月持有期债券A。2022-02-17 日赎回,次日到账。购买时使用了约16元红包,扣除购买时手续费8元,资金占用182天,计得到手年化收益率约 4.21%。

感受:收益有稍大的波动,特别是2月大行情不好时,本金都会亏些的。好得,期末时,行情好,涨回来了
小结:根据个人的投资心理承受能力,暂不考虑基金产品了

我又想起京东金融平台推荐购买过的产品——国联证券的180天定期盈。同样是封闭半年,它的收益率却是-4.77%,不赚反亏本金。小白的我,一气之下,次次看到京东金融的推销电话就立即挂断。

蒸生蚝

昨天,我在某买菜app里买了约两斤的生蚝,十八吊钱。今天中午十二点前,团长打电话喊我去拿生蚝,说怕放久了变臭。

我第一次吃生蚝,是之前的老板请的。他喜欢吃生蚝,有一天晚上,我们路过街边摊,他停住用潮汕话问那烤着冒烟的小贩。然后我们就坐在小板凳上等着吃了。我拿着一个壳,将蚝肉连带着蒜末吮进口,嚼两下,生蚝挺鲜、挺香的。之后我去和平的饭店里吃喜酒,发现其中也有生蚝这么一道菜。饭店生蚝肉用一个平平的壳托着,上边盖着细的粉丝和蒜末。

我年龄越大,口味越清淡。我觉得海产品,大多都腥,用姜、用蒜都盖不住腥味,平时我不想吃的。昨天头一热,点了生蚝的单,打算自己动手试试。

我提回来的是一个泡沫箱,看到有些水渗出。我皱了皱眉头,还没打开包装,我已经嗅到腥味了。打开泡沫箱后,里边是一个胶袋,胶袋里装着麻里麻辣、石头般的生蚝,相互磕碰时,发出响声。我按着说明,先冲洗生蚝。我边冲水边用牙刷刷,刷的过程中,生蚝壳会掉下一些如水泥块的不规则东西。我将冲洗好生蚝,放到锅里,加水煮开,水开后关火。揭盖一看,哟,有的生蚝已经打开口了。所以,下一步“开口”的操作就很容易了:用送的刀子平着戳进微微打开的口子,然后转动刀子或往上往下使力顶开壳。我发现,用这种方法,我拿开的是下壳,不是上壳,就是蚝肉粘在比较㳀的那边壳上。然后,我剥蒜切碎,放到碗里,加酱油、盐、油,搅均,再将蒜末挟到生蚝肉四周。最后,我将装盘的生蚝放到锅里蒸约八分钟(水开后约三分钟)。

自己蒸的生蚝,蚝肉个子大,吃起来软绵绵的,像吃豆腐花,带蒜味的豆腐花。我将一只生蚝咬了一截,然后看到生蚝肉里有灰色的,有青色的,有白色的,一圈一圈夹杂着。我边吃边想,这个是纯的生蚝肉,还是包括生蚝的全部,例如其中有没它的粪便?是不是在我“一口一个生蚝”的时候,也将它的所有“有机物”也吃进肚子里?就如我们平时吃田螺:用力一吸,田螺头呀、田螺尾啊、田螺仔呀……统统都吃下去了。