Fedora Server定制化封装ISO(2)-定制KickStart

上一章我们实践了如何将Fedora重新打包成ISO,接下来对ISO安装过程进行定制,使用的技术主要是kickstart文件进行管理。

定制化自动安装Kickstart

KS详细配置参数请参考KICKSTART SYNTAX REFERENCE

之前在安装Fedora的时候,一般会在root目录生成一个安装的配置文件anaconda.cfg,这个文件是一个当前系统安装kickstart文件的一个简略版,可以参考一下:

[root@localhost ~]# ls
anaconda-ks.cfg  Fedora-Server-dvd-x86_64-31-1.9.iso

先看一下这个文件,我适当的添加关键性注释:

#version=DEVEL
ignoredisk --only-use=sda
iscsiname iqn.1994-05.com.redhat:46a93490da59
# autopart是自动分区,如果想手动分区,需要注释此行
autopart
# Partition clearing information
clearpart --none --initlabel
# Use graphical install
graphical
# Use CDROM installation media
cdrom
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
# 这里是网络配置,如果想在装完系统后再配置网络,可以将此部分注释掉
network  --bootproto=dhcp --device=enp0s5 --ipv6=auto --activate
network  --hostname=localhost.localdomain
# Root password
# 这个密码是安装此操作系统时的root密码,如果指定这里,root密码会在安装时指定,并在过程中直接跳过
rootpw --iscrypted $6$wdv7q0CXjYg3MVuf$UfUKQuNCLxiAjRNslH59a4QIWl5yqeHYAiD53OxExBYyVvR8Q3phNLLhRGVXYJkvpMGk4yVJQd1YvAD9r5QAH0
# Run the Setup Agent on first boot
firstboot --enable
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
%packages
# 这里是安装的包
@^server-product-environment
# 这里可以增加我们要安装的包
%end
%addon com_redhat_kdump --disable --reserve-mb='128'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

在我们的需求中,大部分的修改数据就是以上注释的几个部分:

  1. 分区,我的部署过程一般是将分区部分注释掉的,这样可以让管理员按自己的逻辑进行分区处理
  2.  网络配置也是一般注释掉的,网络配置由管理员手动配置
  3. password使用预置的password,这样可以给服务器一个默认的密码,可以使用以下命令生成进行替换:
    python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())'
  4. 安装的包一般有两种方式,一种是配置rpmxml文件,将rpm加入到server-product-environment中,另一种是直接将包放到%packages%end之间,进行指定安装
  5. 配置一些包的开启关闭状态(参考下面的文件关闭selinux和firewall)
  6. 还可以在ks文件最后加入要执行的脚本,例如下例中展示的允许root使用密码登录

以下是我常用的ks文件:

auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
#version=DEVEL
ignoredisk --only-use=sda

# Use graphical install
graphical
# Use CDROM installation media
cdrom
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'

# 关闭selinux和firewall
selinux --disabled
firewall --disabled

# System language
lang en_US.UTF-8
# Network information
#network  --bootproto=dhcp --device=enp0s5 --ipv6=auto --activate
#network  --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$wdv7q0CXjYg3MVuf$UfUKQuNCLxiAjRNslH59a4QIWl5yqeHYAiD53OxExBYyVvR8Q3phNLLhRGVXYJkvpMGk4yVJQd1YvAD9r5QAH1
# Run the Setup Agent on first boot
firstboot --enable
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
%packages
@^server-product-environment
%end
%post
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
%end

将这个文件保存到ks.cfg,然后放到制作ISO的目录中,我这里是/opt/fedora-custom/isolinux/

然后修改/opt/fedora-custom/isolinux/isolinux.cfg

找到Install Fedora的部分,让操作系统安装的时候使用ks文件安装,修改如下:

menu separator # insert an empty line
label linux
  menu label ^Install Fedora 31
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CDROM ks=hd:LABEL=CDROM:/isolinux/ks.cfg quiet

修改完成后,重新使用上一章中创建ISO脚本重新打包,就可以验证我们的ks是不是正常了,按之前的设置,不需要设置root密码,之需要对分区进行划分就可以安装Fedora了。

 下面来看一下如何定制一个自己程序专属的RPM包:Fedora Server定制化封装ISO(3)-定制RPM包

About the author

liuyuhang

View all posts

70 Comments

  • Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary Anallese Forrest Katzir

  • Hi, I do believe this is a great blog. I stumbledupon it 😉 I am going to revisit
    yet again since i have bookmarked it. Money and freedom is the greatest way to change, may
    you be rich and continue to help other people.

  • Howdy! This post could not be written any better!
    Reading through this post reminds me of my good old room mate!

    He always kept chatting about this. I will forward
    this write-up to him. Pretty sure he will have a good read.
    Thank you for sharing!

  • You need to be a part of a contest for one of the finest sites on the internet. I most certainly will highly recommend this website! Glad Bone Zeculon

  • This content is great! It definitely hits a pain point of a lot of startups and small businesses when they are trying to figure out the best payroll software for their company. After choosing Intuit, having a walk through the intricacies was important and extremely helpful. Elisa Fredrick Hernardo

  • whoah this blog is magnificent i love reading your posts. Keep up the great work! You know, many people are searching around for this information, you could help them greatly. Celie Inglebert Fulvi

  • Definitely believe that which you stated. Your favorite reason appeared to be on the net the simplest thing to be aware of. I say to you, I certainly get annoyed while people think about worries that they plainly do not know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people can take a signal. Will likely be back to get more. Thanks Jennica Dmitri Blessington

  • This piece of writing is genuinely a fastidious one it assists new the web viewers, who are wishing in favor of blogging. Cammi Alwyn Fogel

  • Nice read, I just passed this onto a friend who was doing a little research on that. And he actually bought me lunch as I found it for him smile Thus let me rephrase that: Thanks for lunch! Dorotea Darrell Ame

  • I every time used to read article in news papers but now as I am a user of web thus from now I am using net for articles, thanks to web. Codi Fax Eveleen

  • Can I simply say what a relief to seek out somebody who really is aware of what theyre speaking about on the internet. You undoubtedly know the best way to bring a problem to mild and make it important. Extra people need to learn this and perceive this aspect of the story. I cant believe youre not more widespread since you positively have the gift. Leanora Quinn Beatriz

  • Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Anjanette August Drisko

  • As I web-site possessor I believe the content matter here is rattling magnificent , appreciate it for your efforts. You should keep it up forever! Best of luck. Dode Bond Bonnee

  • Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?| Orella Ingar Boru

  • Thanks for expressing your ideas with this blog. In addition, a misconception regarding the finance institutions intentions whenever talking about foreclosure is that the standard bank will not getreceive my installments. There is a specific amount of time the bank will take payments here and there. If you are far too deep inside hole, they are going to commonly require that you pay the actual payment entirely. However, i am not saying that they will have any sort of payments at all. In the event you and the traditional bank can seem to work anything out, your foreclosure practice may end. However, if you continue to miss out on payments in the new strategy, the foreclosure process can just pick up exactly where it was left off. Shayna Alberto Colville

  • Sweet blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? Kerianne Svend Sanson

  • Hello. This post was really interesting, especially because I was investigating for thoughts on this matter last Thursday. Ruthanne Eben Genni

  • Ex eligendi iste sunt et. Repellendus quia praesentium enim beatae sint maxime. Nisi ipsam molestias vel aspernatur quam. Alena Alair Hurlbut

  • Heya outstanding website! Does running a blog like this require a great deal of work?
    I have no understanding of computer programming but I had been hoping to start my own blog soon. Anyways, if you have any suggestions or techniques
    for new blog owners please share. I know this is off topic nevertheless
    I just needed to ask. Thank you!

  • You are so awesome! I do not think I have read through anything like this before.
    So good to discover someone with some original thoughts on this subject.
    Seriously.. thanks for starting this up. This site is something that is needed on the web, someone with a little originality!

  • What an adorable mini set-up. I love the Holidays and this is just too cute. Plus the hot cocoa and candy canes are perfect! Dee Dee Abba Brena

  • Hi, I think your blog might be having browser compatibility
    issues. When I look at your blog in Chrome, it looks fine but
    when opening in Internet Explorer, it has some overlapping.

    I just wanted to give you a quick heads up! Other then that, great blog!

  • I was wondering if you ever considered changing the page layout of
    your blog? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having
    one or 2 images. Maybe you could space it out better?

  • Attractive component to content. I just stumbled upon your blog
    and in accession capital to say that I get actually enjoyed
    account your blog posts. Anyway I will be subscribing for your feeds or even I success you get right of entry to persistently fast.

  • I believe that is one of the so much significant info for me.
    And i am happy reading your article. However wanna observation on few general things, The web site
    taste is wonderful, the articles is actually nice : D.
    Excellent activity, cheers

  • Curabitur tincidunt justo sit amet enim molestie, quis ornare nunc ornare. Nullam tincidunt ex non augue vulputate, non commodo arcu consectetur. Aenean eget sagittis ex, ut blandit neque. Kellsie Ferdie Leta

  • Needed to post you that bit of word just to say thanks a lot as before about the beautiful advice you have shown in this article. It is quite remarkably open-handed with people like you to provide extensively just what a few individuals could possibly have sold for an electronic book to generate some money for their own end, most notably given that you could have tried it if you decided. The secrets also worked like the great way to fully grasp many people have the identical keenness the same as my personal own to figure out way more with regards to this issue. I am certain there are thousands of more pleasant moments up front for many who scan your blog. Auberta Linus Porush

  • An interesting conversation deserves comment. I think that you need to write much more on this topic, it could not be a frowned on subject however usually individuals are insufficient to speak on such topics. To the next. Thanks Jonell Nester Etrem

  • Howdy! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a extraordinary job!| Esme Reid Sula

  • This paragraph is really a nice one it helps new internet visitors, who are wishing in favor of blogging. Kaylil Arlan Boatwright

  • I will have to look up both of these authors. I have not read their work before, and am always looking for new authors to read! Thanks for sharing! Natividad Wendel Steinway

  • Hello mates, its wonderful article on the topic of cultureand completely defined, keep it up all the time.| Reiko Toby Craggie

  • Nice post. I was checking constantly this blog and I am
    impressed! Extremely helpful information specially the last part 🙂
    I care for such info a lot. I was looking for this particular information for a very long time.
    Thank you and good luck.

  • Good day! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my comment form?

    I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

  • I like the valuable info you supply to your articles.
    I’ll bookmark your blog and take a look at once more here frequently.
    I’m reasonably sure I’ll be told lots of new stuff proper right here!
    Good luck for the following!

发表评论

电子邮件地址不会被公开。 必填项已用*标注