linux第六週微職位

1、請詳細描述CentOS系統的啓動流程(詳細到每個過程系統做了哪些事情)

1)加電自檢,BIOS啓動引導階段;

     在該過程中實現硬件的初始化以及查找啓動介質;

     從MBR中裝載啓動引導管理器(GRUB)並運行該啓動引導管理;

2)GRUB啓動引導階段;

     裝載stage1

     裝載stage1.5

     裝載stage2

     讀取/boot/grub.conf文件並顯示啓動菜單;

     裝載所選的kernel和initrd文件到內存中

3)內核階段:

     運行內核啓動參數;

     解壓initrd文件並掛載initd文件系統,裝載必須的驅動;

     掛載根文件系統

4)init用戶空間初始化階段:

     啓動/sbin/init程序;

     運行rc.sysinit腳本,設置系統環境,啓動swap分區,檢查和掛載文件系統;

     讀取/etc/inittab文件,運行在/et/rc.d/rc<#>.d中定義的不同運行級別的服務初始化腳本;

     打開字符終端1-6號控制檯/打開圖形顯示管理,設置登錄


2、爲運行於虛擬機上的CentOS 6添加一塊新硬件,提供兩個主分區;

(1) 爲硬盤新建兩個主分區;併爲其安裝grub;

(2) 爲硬盤的第一個主分區提供內核和ramdisk文件; 爲第二個分區提供rootfs;

(3) 爲rootfs提供bash、ls、cat程序及所依賴的庫文件;

(4) 爲grub提供配置文件;

(5) 將新的硬盤設置爲第一啓動項並能夠正常啓動目標主機;

  ~]#  fdisk /dev/sdc

  ~]#  partx -a /dev/sdc

  ~]#  mkfs -t ext4 /dev/sdc1 

  ~]#  mkfs -t ext4 /dev/sdc2

  ~]#  mkdir /mnt/{boot,sysroot}

  ~]#  mount /dev/sdc1 /mnt/boot/

  ~]#  mount /dev/sdc2 /mnt/sysroot/

  ~]#  cp /boot/vmlinuz-2.6.32-573.el6.x86_64 /mnt/boot/

  ~]#  cp /boot/initramfs-2.6.32-573.el6.x86_64.img /mnt/boot/

  ~]#  vim /mnt/boot/grub.conf  #新建一個grub配置文件

default=0

timeout=15

title Centos6.70 homemake

root (hd0,0)

kernel /vmlinuz-2.6.32-573.el6.x86_64 ro root=/dev/sdc2 selinux=0 init=/bin/bash

initrd /initramfs-2.6.32-573.el6.x86_64.img


  ~]#  mkdir -p /mnt/rootfs/{bin,lib64}

  ~]#  cp -r /bin/{bin,ls,cat} /mnt/rootfs/bin/

  ~]#  cp -r /bin/{bash,ls,cat} /mnt/rootfs/bin/      #複製bash,ls,cat,所依賴的庫文件 

  ~]#  cp $(ldd /bin/bash | awk '$3~/^\/lib64/print $3}') /mnt/rootfs/lib64/#

  ~]#  cp $(ldd /bin/bash | awk '$3~/^\/lib64/print $3}') /mnt/rootfs/lib64/

  ~]#  cp $(ldd /bin/bash | awk '$3~/^\/lib64/{print $3}') /mnt/rootfs/lib64/

  ~]#  cp $(ldd /bin/ls | awk '$3~/^\/lib64/{print $3}') /mnt/rootfs/lib64/

  ~]#  cp $(ldd /bin/cat | awk '$3~/^\/lib64/{print $3}') /mnt/rootfs/lib64/

重啓服務設置從sdc啓動進入系統



3、製作一個kickstart文件以及一個引導鏡像。描述其過程。

# Kickstart file automatically generated by anaconda.

 

#version=DEVEL

install

cdrom

lang zh_CN.UTF-8

keyboard us

network --onboot no --device eth0 --bootproto dhcp --noipv6

rootpw  --iscrypted $6$We6z2yOuLLzQlEQQ$97ev7j9SgwMI0P5hRj79nccpgyPxqIQxSixn69PUIsJA/BmnY92sFl7QoBF2W4IeS79Nm.c0iI5ACdVqWOCFT/

firewall --service=ssh

authconfig --enableshadow --passalgo=sha512

selinux --enforcing

timezone --utc Asia/Shanghai

bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

# The following is the partition information you requested

# Note that any partitions you deleted are not expressed

# here so unless you clear all partitions first, this is

# not guaranteed to work

#clearpart --none

#part /boot --fstype=ext4 --size=200

#part swap --size=8192

#part / --fstype=ext4 --grow --size=200

repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100

%packages

@base

@chinese-support

@core

@debugging

@development

@directory-client

@java-platform

@network-file-system-client

@print-client

@server-platform

@server-policy

@workstation-policy

pax

oddjob

sgpio

device-mapper-persistent-data

systemtap-client

jpackage-utils

samba-winbind

certmonger

pam_krb5

krb5-workstation

~]#mkdir -p /data/iso/isolinux 

~]#cp /media/isolinux/* /data/iso/isolinux/ 

~]#cp /root/anaconda-ks.cfg  /data/iso/isolinux/myks.cfg 

~]#mkisofs -R -J -T -v –no-emul-boot –boot-load-size 4 –boot-info-table -V "CentOS 6.8 x86_64 boot" -b /data/iso/isolinux/isolinux.bin -c /data/iso/isolinux/boot.cat -o /root/boot.iso myiso        

#創建引導鏡像

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章