Chinaunix首页 | 论坛 | 博客
  • 博客访问: 75481
  • 博文数量: 41
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 434
  • 用 户 组: 普通用户
  • 注册时间: 2017-03-23 09:31
个人简介

天行健,君子以自强不息;地势坤,君子以厚德载物

文章分类
文章存档

2018年(11)

2017年(30)

我的朋友

分类: LINUX

2018-01-06 18:20:40

添加一个独立的硬盘,
[root@localhost ~]# fdisk /dev/hda
Command (m for help): p

Disk /dev/hda: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1          42       19813+  83  Linux
/dev/hda2              43        1101      500377+  83  Linux

[root@localhost ~]# mkdir /mnt/boot
[root@localhost ~]# mkdir /mnt/sysroot
[root@localhost ~]# mount /dev/hda1 /mnt/boot
[root@localhost ~]# mount /dev/hda2 /mnt/sysroot
[root@localhost ~]# cp /boot/vmlinuz-2.6.18-308.el5 /mnt/boot/vmlinuz    #复制内核#
[root@localhost ~]# mkdir test
[root@localhost ~]# cd test
[root@localhost test]# zcat /boot/initrd-2.6.18-308.el5.img | cpio -id    #展开并归档#
[root@localhost test]# vim init
mkrootdev -t ext3 -o defaults,ro /dev/hda2                                #修改为根系统挂载设备/dev/hda2#
[root@localhost test]# find . | cpio -H newc --quiet -o | gzip -9 > /mnt/boot/initrd.gz    #制作initrd文件#
[root@localhost test]# grub-install --root-directory=/mnt /dev/hda        #安装grub#
[root@localhost test]# vim /mnt/boot/grub/grub.conf                          #编辑grub.conf#
default=0
timeout=3
title MageEdu Linux(2.6.18)
        root (hd0,0)
        kernel /vmlinuz ro root=/dev/hda2 quiet
        initrd /initrd.gz

[root@localhost sysroot]# mkdir etc/rc.d/init.d bin sbin proc sys dev lib root mnt media var/{log,run,lock/subsys,tmp} usr/{bin,sbin,local} tmp home opt boot -pv
                                #在根文件系统下创建所需要的目录#
[root@localhost sysroot]# vim etc/inittab                                 #创建配置文件#
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l3:3:wait:/etc/rc.d/rc 3
l6:6:wait:/etc/rc.d/rc 6

1:2345:respawn:/sbin/agetty -n -l /bin/bash 38400 tty1
2:2345:respawn:/sbin/agetty -n -l /bin/bash 38400 tty2

[root@localhost sysroot]# vim etc/rc.d/rc.sysinit                        #创建rc.sysinit脚本#
#!/bin/bash
#
echo -e "\tWelcome to \033[31mMagedu Team\033[0m Linux."
/bin/bash


[root@localhost sysroot]# chmod +x etc/rc.d/rc.sysinit

移植可执行程序脚本:
[root@localhost ~]# vim bincp.sh
#!/bin/bash
#
DEST=/mnt/sysroot
libcp() {
        LIBPATH=${1%/*}
        [ ! -d $DEST$LIBPATH ] && mkdir -p $DEST$LIBPATH
        [ ! -e $DEST${1} ] && cp $1 $DEST$LIBPATH && echo echo "copy lib $1 finished."
}

bincp() {
        CMDPATH=${1%/*}
        [ ! -d $DEST$CMDPATH ] && mkdir -p $DEST$CMDPATH
        [ ! -e $DEST${1} ] && cp $1 $DEST$CMDPATH

        for LIB in `ldd $1 | grep -o "/.*lib\(64\)\{0,1\}/[^[:space:]]\{1,\}"`; do
                libcp $LIB
        done
}

read -p "Your command: " CMD
until [ $CMD == 'q' ]; do
        ! which $CMD && echo "Wrong command" && read -p "Input againe" CMD && continue
        COMMAND=`which $CMD | grep -v "^alias" | grep -o "[^[:space:]]\{1,\}"`
        bincp $COMMAND
        echo "copy $COMMAND finished."
        read -p "Continue: " CMD
done


[root@localhost ~]# chmod +x bincp.sh
[root@localhost ~]# ./bincp.sh                          #移植命令#
Your command: init
/sbin/init
copy /sbin/init finished.
Continue: badh
which: no badh in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
Wrong command
Input againe:bash  
/bin/bash
copy /bin/bash finished.
Continue: ls
/bin/ls
copy /bin/ls finished.
Your command: touch
/bin/touch
copy /bin/touch finished.
Continue: mkdir
/bin/mkdir
copy /bin/mkdir finished.
Continue: rm
/bin/rm
copy /bin/rm finished.
Continue: mv
/bin/mv
copy /bin/mv finished.
Continue: cp
/bin/cp
copy /bin/cp finished.
Continue: cat
/bin/cat
copy /bin/cat finished.
Continue: mount
/bin/mount
copy /bin/mount finished.
Continue: umount
/bin/umount
copy /bin/umount finished.
Continue: vi
/bin/vi
copy /bin/vi finished.
Continue: vim
/usr/bin/vim
copy /usr/bin/vim finished.
Continue: chmod
/bin/chmod
copy /bin/chmod finished.
Continue: chown
/bin/chown
copy /bin/chown finished.
Continue: ping
/bin/ping
copy /bin/ping finished.
Continue: ifconfig
/sbin/ifconfig
copy /sbin/ifconfig finished.
Continue: insmod
/sbin/insmod
copy /sbin/insmod finished.
Continue: modprobe
/sbin/modprobe
copy /sbin/modprobe finished.
Continue: rmmod
/sbin/rmmod
copy /sbin/rmmod finished.
Continue: route
/sbin/route
copy /sbin/route finished.
Continue: halt
/sbin/halt
copy /sbin/halt finished.
Continue: reboot
/sbin/reboot
copy /sbin/reboot finished.
Continue: shutdown
/sbin/shutdown
copy /sbin/shutdown finished.
Continue: hostname
/bin/hostname
copy /bin/hostname finished.
Continue: q
[root@localhost ~]# sync                                              #同步到硬盘中#
[root@localhost ~]# sync
[root@localhost ~]# sync
[root@localhost ~]#

#进入测试小系统#

bash-3.2#mount -n -o remount,rw /      #将根目录重新挂载为可读写#

#实现关机、重启功能#

[root@localhost sysroot]# vim etc/rc.d/init.d/halt
#!/bin/bash
#
case $0 in
*reboot)
        COMMAND='/sbin/reboot' ;;
*halt)
        COMMAND='/sbin/halt -p' ;;
*)
        echo "Only call this script by *reboot OR *halt;"
        ;;
esac

case $1 in
start)
        ;;
stop)
        ;;
*)
        echo "Usage:`basename $0` {start|stop}"
        ;;
esac

exec $COMMAND

[root@localhost sysroot]# chmod +x etc/rc.d/init.d/halt
[root@localhost sysroot]# cd etc/rc.d/
[root@localhost rc.d]# ls init.d/
functions  halt  network  tserver
[root@localhost rc.d]# mkdir rc0.d rc6.d
[root@localhost rc.d]# cd rc0.d/
[root@localhost rc0.d]# ln -sv ../init.d/halt S99halt
[root@localhost rc.d]# cd rc6.d/
[root@localhost rc6.d]# ln -sv ../init.d/halt S99reboot

[root@localhost rc.d]# vim rc
#!/bin/bash
#
RUNLEVEL=$1

for I in /etc/rc.d/rc$RUNLEVEL.d/K*; do
        $I stop
done

for I in /etc/rc.d/rc$RUNLEVEL.d/S*; do
        $I start
done


[root@localhost rc.d]# chmod +x rc
[root@localhost sysroot]# vim etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l6:6:wait:/etc/rc.d/rc 6


#定义级别3,并实现启动服务功能#
[root@localhost sysroot]# vim etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l3:3:wait:/etc/rc.d/rc 3
l6:6:wait:/etc/rc.d/rc 6

[root@localhost sysroot]# vim etc/rc.d/init.d/tserver
#!/bin/bash
#
#chkconfig: 35 66 33
#description: test service script
#

prog=`basename $0`
lockfile=/var/lock/subsys/$prog

start() {
        echo "Starting $prog...."
        touch $lockfile
}

stop() {
        echo "Stooping $prog..."
        rm -f $lockfile

}

status() {
        if [ -f $lockfile ]; then
           echo "Running..."
        else
            echo "Stopped..."
        fi
}

usage() {
        echo "Usage: $prog {start|stop|status|restart}"
}

case $1 in
start)
        start;;
stop)
        stop;;
restart)
        stop
        start
        ;;
status)
        status
        ;;
*)
        usage
        exit 1
        ;;
esac

[root@localhost sysroot]# chmod +x etc/rc.d/init.d/tserver

[root@localhost sysroot]# cd etc/rc.d/rc3.d/
[root@localhost rc3.d]# ln -sv ../init.d/tserver S66tserver
[root@localhost rc.d]# cd rc0.d/
[root@localhost rc0.d]# ln -sv ../init.d/tserver K33server
[root@localhost rc0.d]# cd ../rc6.d/
[root@localhost rc6.d]# ln -sv ../init.d/tserver K33tserver

[root@localhost sysroot]# vim etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l3:3:wait:/etc/rc.d/rc 3
l6:6:wait:/etc/rc.d/rc 6

1:2345:respawn:/sbin/mingetty --loginprog=/bin/bash tty1
2:2345:respawn:/sbin/mingetty --loginprog=/bin/bash tty2



[root@localhost sysroot]# vim etc/rc.d/rc.sysinit                        #修改rc.sysinit脚本,删掉/bin/bash#
#!/bin/bash
#
echo -e "\tWelcome to \033[31mMagedu Team\033[0m Linux."


[root@localhost ~]# ./bincp.sh
Your command: mingetty    
/sbin/mingetty
copy /sbin/mingetty finished.
[root@localhost ~]# ./bincp.sh
Your command: basename    
/bin/basename
copy /bin/basename finished.

[root@localhost bin]# ln -sv bash sh


#让根文件系统,在sysinit脚本中完成以读写方式重新挂载;并且能够使用终端#

[root@localhost sysroot]# vim etc/fstab
/dev/hda2       /       ext3    defaults        0 0
/dev/hda1       /boot   ext3    defaults        0 0
proc            /proc   proc    defaults        0 0
sysfs           /sys    sysfs   defaults        0 0

[root@localhost sysroot]# mkdir etc/sysconfig/
[root@localhost sysroot]# vim etc/sysconfig/network                        #设定主机名#
HOSTNAME=minilinux.magedu.com

[root@localhost sysroot]# vim etc/rc.d/rc.sysinit
#!/bin/bash
#
echo -e "\tWelcome to \033[31mMagedu Team\033[0m Linux."

echo "Remount rootfs..."
mount -n -o remount,rw /

echo "Set the hostname..."
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
[ -z $HOSTNAME -o "$HOSTNAME" == '(none)' ] && HOSTNAME=localhost
/bin/hostname $HOSTNAME

[root@localhost sysroot]# vim etc/inittab                    #使用agetty替换mingetty,系统登录不需要用户名#
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l3:3:wait:/etc/rc.d/rc 3
l6:6:wait:/etc/rc.d/rc 6

1:2345:respawn:/sbin/agetty -n -l /bin/bash 38400 tty1
2:2345:respawn:/sbin/agetty -n -l /bin/bash 38400 tty2

[root@localhost ~]# ./bincopy.sh
Your command: agetty
/sbin/agetty
copy /sbin/agetty finished.
Continue: q

[root@localhost sysroot]# chroot /mnt/sysroot/           #在宿主机内切换到测试系统中进行测试脚本#
bash-3.2# /etc/rc.d/rc.sysinit
    Welcome to Magedu Team Linux.
Remount rootfs...
Set the hostname...
bash-3.2# exit
exit

#编译一个函数,使测试系统在开启或关闭某些功能时显示绿色OK或红色FAILED#
[root@localhost sysroot]# vim etc/rc.d/init.d/functions
SCREEN=`stty -F /dev/console size 2>/dev/null`
COLUMNS=${SCREEN#* }
[ -z $COLUMNS ] && COLUMNS=80

SPA_COL=$[$COLUMNS-14]

RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
NORMAL='\033[0m'

success() {
        string=$1
        RT_SPA=$[$SPA_COL-${#string}]               #${#string}显示$1字符串长度#
        echo -n "$string"
        for I in `seq 1 $RT_SPA`; do
                echo -n " "
        done
        echo -e "[   ${GREEN}OK${NORMAL}   ]"
}

failure() {
        string=$1
        RT_SPA=$[$SPA_COL-${#string}]
        echo -n "$string"
        for I in `seq 1 $RT_SPA`; do
                echo -n " "
        done
        echo -e "[ ${RED}FAILED${NORMAL} ]"
}

[root@localhost sysroot]# vim etc/rc.d/init.d/tserver
#!/bin/bash
#
#chkconfig: 35 66 33
#description: test service script
#
. /etc/rc.d/init.d/functions

prog=tserver
lockfile=/var/lock/subsys/$prog

start() {
        touch $lockfile
        [ $? -eq 0 ] && success "Starting $prog" || failure "Starting $prog"
}

stop() {
        rm -f $lockfile
        [ $? -eq 0 ] && success "Stopping $prog" || failure "Stopping $prog"

}

status() {
        if [ -f $lockfile ]; then
           echo "Running..."
        else
           echo "Stopped..."
        fi
}

usage() {
        echo "Usage: $prog {start|stop|status|restart}"
}

case $1 in
start)
        start;;
stop)
        stop;;
restart)
        stop
        start
        ;;
status)
        status
        ;;
*)
        usage
        exit 1
        ;;
esac


#实现配置IP地址功能#
[root@localhost sysroot]# mkdir lib/modules/
[root@localhost sysroot]# modinfo pcnet32
filename:       /lib/modules/2.6.18-308.el5/kernel/drivers/net/pcnet32.ko        #pcnet32模块存放目录#
license:        GPL
description:    Driver for PCnet32 and PCnetPCI based ethercards
author:         Thomas Bogendoerfer
srcversion:     F81443556AAE169CBF80F55
alias:          pci:v00001023d00002000sv*sd*bc02sc00i*
alias:          pci:v00001022d00002000sv*sd*bc*sc*i*
alias:          pci:v00001022d00002001sv*sd*bc*sc*i*
depends:        mii                                                                #pcnet32模块依赖库#
......

[root@localhost sysroot]# cp /lib/modules/2.6.18-308.el5/kernel/drivers/net/pcnet32.ko /mnt/sysroot/lib/modules/

[root@localhost sysroot]# modinfo mii
filename:       /lib/modules/2.6.18-308.el5/kernel/drivers/net/mii.ko
license:        GPL
description:    MII hardware support library
author:         Jeff Garzik
srcversion:     16DCEDEE4B5629C222C352D
depends:        
......

[root@localhost sysroot]# cp /lib/modules/2.6.18-308.el5/kernel/drivers/net/mii.ko /mnt/sysroot/lib/modules/

[root@localhost sysroot]# vim etc/rc.d/rc.sysinit
#!/bin/bash
#
echo -e "\tWelcome to \033[31mMagedu Team\033[0m Linux."

echo "Remount rootfs..."
mount -n -o remount,rw /

echo "Set the hostname..."
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
[ -z $HOSTNAME -o "$HOSTNAME" == '(none)' ] && HOSTNAME=localhost
/bin/hostname $HOSTNAME

echo "Initializing network device..."
/sbin/insmod /lib/modules/mii.ko                        #装载mii.ko模块#
/sbin/insmod /lib/modules/pcnet32.ko                    #装载pcnet32.ko模块#


[root@localhost sysroot]# mkdir -pv etc/sysconfig/network-scripts/
[root@localhost sysroot]# vim etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.101.155
NETMASK=255.255.255.0
GATEWAY=192.168.101.1
ONBOOT=yes

[root@localhost sysroot]# vim etc/rc.d/init.d/network     #实现自动启动ifcfg-eth0 脚本#
#!/bin/bash
#chkconfig: 35 09 90
#description: network service
#
prog=network

. /etc/rc.d/init.d/functions                        #读取functions 函数#

CONF=/etc/sysconfig/network-scripts/ifcfg-eth0

. $CONF

NETMASK=24

start() {
        ifconfig eth0 $IPADDR/$NETMASK up
        [ -z $GATEWAY ] && route add default gw $GATEWAY
}

stop() {
        ifconfig eth0 down
}

status() {
        ifconfig eth0
}

usage() {
        echo "$prog: {start|stop|restart|status}"
}

case $1 in
start)
        start
        success "Config network eth0"
        ;;
stop)
        stop
        success "Stop network card eth0"
        ;;
restart)
        stop
        start
        success "Restart network card eth0"
        ;;
status)
        status
        ;;
*)
        usage
        exit 1
        ;;
esac

[root@localhost sysroot]# chmod +x etc/rc.d/init.d/network
[root@localhost sysroot]# cd etc/rc.d/rc0.d/
[root@localhost rc0.d]# ln -sv ../init.d/network K90network
[root@localhost rc0.d]# cd ../rc6.d/
[root@localhost rc6.d]# ln -sv ../init.d/network K90network
[root@localhost rc6.d]# cd ../rc3.d/
[root@localhost rc3.d]# ln -sv ../init.d/network S09network


#显示终端提示信息#
/etc/issue 文件的内容

[root@localhost ~]# cp /etc/issue /mnt/sysroot/etc/
[root@localhost ~]# vim /mnt/sysroot/etc/issue
MagEdu Linux
Kernel \r on an \m



#rc.sysinit:挂载/etc/fstab中定义的其他文件系统#

[root@localhost ~]# cd /mnt/sysroot/
[root@localhost sysroot]# vim etc/rc.d/rc.sysinit
#!/bin/bash
#
. /etc/rc.d/init.d/functions

echo -e "\tWelcome to \033[31mMagedu Team\033[0m Linux."

echo "Remount rootfs..."
mount -n -o remount,rw /
[ $? -eq 0 ] && success "Remount rootfs" || failure "Remount rootfs"

mount -a                                                                #挂载所有文件#
[ $? -eq 0 ] && success "Mount others filesystem" || failure "Mount others filesystem"

#Set the hostname...
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
[ -z $HOSTNAME -o "$HOSTNAME" == '(none)' ] && HOSTNAME=localhost
/bin/hostname $HOSTNAME
[ $? -eq 0 ] && success "Set the hostname" || failure "Set the hostname"
    
#Initializing network device...
/sbin/insmod /lib/modules/mii.ko
/sbin/insmod /lib/modules/pcnet32.ko
[ $? -eq 0 ] && success "Set the hostname" || failure "Set the hostname"

#设定内核参数#
修改/etc/sysctl.conf
sysctl -p           #sysctl 脚本生效#

[root@localhost sysroot]# /root/bincp.sh
Your command: sysctl      
/sbin/sysctl
echo copy lib /lib/libproc-3.2.7.so finished.
copy /sbin/sysctl finished.
Continue: q
[root@localhost sysroot]# vim etc/sysctl.conf
net.ipv4.ip_forward = 1

[root@localhost sysroot]# vim etc/rc.d/rc.sysinit
!/bin/bash
#
. /etc/rc.d/init.d/functions

echo -e "\tWelcome to \033[31mMagedu Team\033[0m Linux."

echo "Remount rootfs..."
mount -n -o remount,rw /
[ $? -eq 0 ] && success "Remount rootfs" || failure "Remount rootfs"

mount -a
[ $? -eq 0 ] && success "Mount others filesystem" || failure "Mount others filesystem"

#Set the hostname...
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
[ -z $HOSTNAME -o "$HOSTNAME" == '(none)' ] && HOSTNAME=localhost
/bin/hostname $HOSTNAME
[ $? -eq 0 ] && success "Set the hostname" || failure "Set the hostname"

#Initializing network device...
/sbin/insmod /lib/modules/mii.ko
/sbin/insmod /lib/modules/pcnet32.ko
[ $? -eq 0 ] && success "Initializing network device" || failure "Initializing network device"

ifconfig lo 127.0.0.1/8
[ $? -eq 0 ] && success "Activating loopback network device" || failure "Activating loopback device"

sysctl -p &> /dev/null                             #sysctl 生效#
[ $? -eq 0 ] && success "Set kernel parameter" || failure "Set kernel parameter"

#支持用户账号#


[root@localhost ~]# cp /lib/libnss_files* /mnt/sysroot/lib/ -d
[root@localhost ~]# cp -d /usr/lib/libnss_files.so  /mnt/sysroot/usr/lib/
[root@localhost ~]# cp -d /usr/lib/libnss3.so /usr/lib/libnssckbi.so /usr/lib/libnssutil3.so /mnt/sysroot/usr/lib/
[root@localhost ~]# cp /etc/nsswitch.conf /mnt/sysroot/etc/
[root@localhost ~]# vim /mnt/sysroot/etc/nsswitch.conf
passwd:     files
shadow:     files
group:      files
hosts:      files dns


[root@localhost ~]# grep -E "^(root|hadoop)\>" /etc/passwd > /mnt/sysroot/etc/passwd    #创建root和hadoop两个用户#
[root@localhost ~]# grep -E "^(root|hadoop)\>" /etc/shadow > /mnt/sysroot/etc/shadow     #创建root和hadoop两个用户密码#
[root@localhost ~]# grep -E "^(root|hadoop)\>" /etc/group > /mnt/sysroot/etc/group      #创建root和hadoop两个用户的组#
[root@localhost ~]# ./bincp.sh
Your command: mingetty  
/sbin/mingetty
copy /sbin/mingetty finished.
Continue: useradd
/usr/sbin/useradd
echo copy lib /lib/libaudit.so.0 finished.
copy /usr/sbin/useradd finished.
Continue: passwd
/usr/bin/passwd
echo copy lib /usr/lib/libuser.so.1 finished.
echo copy lib /lib/libgobject-2.0.so.0 finished.
echo copy lib /lib/libgmodule-2.0.so.0 finished.
echo copy lib /lib/libglib-2.0.so.0 finished.
echo copy lib /usr/lib/libpopt.so.0 finished.
echo copy lib /lib/libpam_misc.so.0 finished.
echo copy lib /lib/libpam.so.0 finished.
copy /usr/bin/passwd finished.
Continue: userdel
/usr/sbin/userdel
copy /usr/sbin/userdel finished.
Continue: usermod
/usr/sbin/usermod
copy /usr/sbin/usermod finished.
Continue: groupadd
/usr/sbin/groupadd
copy /usr/sbin/groupadd finished.
Continue: q
[root@localhost ~]# cd /mnt/sysroot/
[root@localhost sysroot]# vim etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l3:3:wait:/etc/rc.d/rc 3
l6:6:wait:/etc/rc.d/rc 6

1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2

#编译login程序# 需要用到PAM,暂搁置
。。。。。

#编辑PS1,定义命令提示符前提示信息#
[root@localhost sysroot]# cd root/
[root@localhost root]# vim .bash_profile
PS1=‘[\u@\h \W]\$’
export PS1

#设定单用户模式#

[root@localhost sysroot]# vim etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l3:3:wait:/etc/rc.d/rc 3
l6:6:wait:/etc/rc.d/rc 6

1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2

[root@localhost sysroot]# cd etc/
[root@localhost etc]# cd rc.d/
[root@localhost rc.d]# mkdir rc1.d
[root@localhost rc.d]# cd rc1.d/
[root@localhost rc1.d]# ln -sv ../init.d/network K90network
创建指向“../init.d/network”的符号链接“K90network”
[root@localhost rc1.d]# ln -sv ../init.d/tserver  K33tserver
创建指向“../init.d/tserver”的符号链接“K33tserver”
[root@localhost rc1.d]# ll
总计 2
lrwxrwxrwx 1 root root 17 11-13 15:16 K33tserver -> ../init.d/tserver
lrwxrwxrwx 1 root root 17 11-13 15:15 K90network -> ../init.d/network

[root@localhost etc]# vim rc.d/init.d/single
#!/bin/bash
#
#chkconfig:
#description:
#
case $1 in
start)
        ;;
*)
        echo "Usage: single start"
        ;;
esac

exec /sbin/init S

[root@localhost etc]# chmod +x rc.d/init.d/single
[root@localhost rc1.d]# ln -sv ../init.d/single S98single
创建指向“../init.d/single”的符号链接“S98single”
[root@localhost rc1.d]# ll
总计 3
lrwxrwxrwx 1 root root 17 11-13 15:16 K33tserver -> ../init.d/tserver
lrwxrwxrwx 1 root root 17 11-13 15:15 K90network -> ../init.d/network
lrwxrwxrwx 1 root root 16 11-13 15:23 S98single -> ../init.d/single


阅读(931) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~