引入:

    在前篇思路的指导下,进行了为期三个星期的调试最终建立了一个初步成熟的,具有亲和力的配置界面,现在此虚拟系统已经初步部署了一个机房,用来学生日常上课。在本篇中,本人并不试图去花篇幅讲解彼此之间如何配合,如此设计缘由等等。因为,逻辑的东西真的不好用语言来说,只好将之以一种最直接的方式完整呈现给读者。如果你全全操作,一定会明了我的设计思路及各文档的含义的。

虚拟系统文档:

     1、管理员克隆后初次登录相关

【桌面自动运行文件autostart】

对应文件:/etc/xdg/openbox/autostart_half

注:*_half文件,以及后面要出现的*_ok,均是为区分部署给不同用户而设定的。half表示,使用此配置文件时,系统的配置尚未完成。ok表示,通过此配置文件,系统配置即将完成(结束)。这样做有一个好处,当我需要重置系统设置时,可以将所有half文件复制并覆盖对应的配置文件(如:autostart_half覆盖autostart)。而在配置完autostart_half内容的autostart,如果配置将autostart_ok覆盖autostart文件即可。最后声明一点,所有以half或ok结尾的配置文件并不起作用,它只是用来覆盖对应的无后缀文件来起作用的。


  1. #if test -x /usr/lib/openbox/gnome-settings-daemon >/dev/null; then 
  2. #  /usr/lib/openbox/gnome-settings-daemon & 
  3. #elif which gnome-settings-daemon >/dev/null; then 
  4. #  gnome-settings-daemon & 
  5. #fi 
  6.  
  7. # If you want to use XFCE config tools... 
  8. #xfce-mcs-manager & 
  9. #任务栏加载
  10. tint2 & 
  11. #自动运行终端,有时桌面会停止响应,如果终端开启,输入命令“openbox --reconfigure”刷新桌面即可。
  12. xterm & 
  13. #net.jpg这个图片,我没有提供,是机房管理员在配置系统时系统的桌面背景图片
  14. feh --bg-scale /boot/net.jpg & 
  15. #打开系统说明文档,只是起提示与说明作用的文本
  16. leafpad /etc/vmshenzhi.txt & 

/etc/vmshenzhi.txt的内容:


  1.       现在大家看到的这篇文档,是在克隆系统后交付学生使用前所需的操作 
  2. 说明。在桌面上单击右键,会有一个菜单弹出。我们可能用到的菜单均是 
  3. 含有汉字的,英文的不要操作! 
  4.      菜单的第一项:“**职教虚拟系统使用说明”,就是本文档。接下来会 
  5. 有两大步操作,依次是: 
  6. 第一大步[修改IP与主机名]: 
  7.         1.修改宿主机IP地址 
  8.         2.修改宿主机名称-1 
  9.         3.修改宿主机名称-2 
  10.  
  11. 第二大步: 
  12.         保存并重启系统 
  13.         [之后会进入虚拟机的编辑界面,设置完虚拟机后再次点选重启的菜单项就完成了所有操作] 
  14.  
  15.       如果在修改过程中出现了无法更正的错误,可以重新对系统进行设置, 
  16. 此时需要选择的菜单是其它子菜单中的"重新配置[慎重]",但要慎重进行选择,系统 
  17. 会进行重启。如果一切顺利,在设置完成后,选择最下方的菜单“设置完毕 
  18. 重启系统”! 
  19.                                                               [完]12年1月7日21:00:18 

    2、桌面菜单

对应文件:/etc/xdg/openbox/menu.xml_half


  1. <?xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <openbox_menu xmlns="http://openbox.org/" 
  4.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.         xsi:schemaLocation="http://openbox.org/ 
  6.                 file:///usr/share/openbox/menu.xsd"> 
  7.  <!--图形界面中的菜单-管理员状态 --> 
  8. <menu id="root-menu" label="Openbox 3"> 
  9.   <item label="**职教虚拟系统使用说明"> 
  10.     <action name="Execute"><execute>leafpad /etc/vmshenzhi.txt</execute></action> 
  11.   </item> 
  12.  <!--自定义 添加的配置菜单内容 --> 
  13. <separator /> 
  14.  
  15. <menu id="zheng-menu1" label="[第一步]修改IP与主机名"> 
  16.   <item label="1.修改宿主机IP地址"> 
  17.     <action name="Execute"><execute>leafpad /etc/network/interfaces</execute></action> 
  18.   </item> 
  19.   <item label="2.修改宿主机名称-1"> 
  20.     <action name="Execute"><execute>leafpad /etc/hostname</execute></action> 
  21.   </item> 
  22.   <item label="3.修改宿主机名称-2"> 
  23.     <action name="Execute"><execute>leafpad /etc/hosts</execute></action> 
  24.   </item> 
  25. </menu> 
  26.   <item label="[第二步]保存并重启系统"> 
  27.     <action name="Execute"><execute>/etc/first.sh</execute></action> 
  28.   </item> 
  29.   <separator /> 
  30. <menu id="zheng-menu3" label="其它"> 
  31.   <!-- This requires the presence of the 'menu' package to work --> 
  32.   <item label="Terminal emulator"> 
  33.     <action name="Execute"><execute>x-terminal-emulator</execute></action> 
  34.   </item> 
  35.   <item label="ObConf"> 
  36.     <action name="Execute"><execute>obconf</execute></action> 
  37.   </item> 
  38.    <item label="关机"> 
  39.     <action name="Execute"><execute>shutdown -h now</execute></action> 
  40.    </item> 
  41.   <item label="Tint2"> 
  42.     <action name="Execute"><execute>tint2</execute></action> 
  43.   </item> 
  44.   <item label="Reconfigure"> 
  45.     <action name="Reconfigure" /> 
  46.   </item> 
  47.   <item label="!!!重新配置[慎重]!!!"> 
  48.     <action name="Execute"><execute>/etc/refirst2.sh</execute></action> 
  49.   </item> 
  50.   <item label="Restart"> 
  51.     <action name="Restart" /> 
  52.   </item> 
  53.   <separator /> 
  54.   <item label="Exit"> 
  55.     <action name="Exit" /> 
  56.   </item> 
  57. </menu> 
  58.   <separator /> 
  59.  
  60. <item label="关于"> 
  61.     <action name="Execute"><execute>feh /boot/kaichuang.jpg</execute></action> 
  62.   </item> 
  63. </menu> 
  64.  
  65. </openbox_menu> 

menu.xml_half中包含的文档:

对应文件:/etc/network/interfaces由文件interfaces_half得来

作用:修改主机IP


  1. ####################本文件是用来修改机器的IP地址的 
  2. # This file describes the network interfaces available on your system 
  3. # and how to activate them. For more information, see interfaces(5). 
  4.  
  5. # The loopback network interface 
  6. auto lo 
  7. iface lo inet loopback 
  8.  
  9. # The primary network interface 
  10. auto eth0 
  11. #iface eth0 inet dhcp 
  12. iface eth0 inet static 
  13. ####下面一行修改为:192.168.208.10x 
  14. ####例如,第1个学生机为192.168.208.101,第50个为192.168.208.150 
  15. address 192.168.208.150 
  16. ##########下面不修改########## 
  17. netmask 255.255.255.0 
  18. gateway 192.168.208.254 
  19. broadcast 192.168.208.255 

对应文件:/etc/hostname由文件/etc/hostname_half得来

作用:修改主机名称


  1. ######此文件用来修改主机名称,注意sz0801表示第1个学生机, 
  2. ######sz0802表示第2个,sz0801表示第1个学生机 
  3. ######仅需将sz0850修改为对应名称, 
  4. ######其它地方不做更改,更改完毕,保存并退出! 
  5. sz0850 

对应文件:/etc/hosts由文件/etc/hosts_half得来

作用:修改主机名称


  1. ######此文件用来修改主机名称,注意sz0801表示第1个学生机, 
  2. ######sz0802表示第2个,sz0801表示第50个学生机 
  3. ######仅需将sz0850修改为对应名称, 
  4. ######其它地方不做更改,更改完毕,保存并退出! 
  5. 127.0.1.1   sz0850 
  6.  
  7. # The following lines are desirable for IPv6 capable hosts 
  8. ::1     ip6-localhost ip6-loopback 
  9. fe00::0 ip6-localnet 
  10. ff00::0 ip6-mcastprefix 
  11. ff02::1 ip6-allnodes 
  12. ff02::2 ip6-allrouters 

对应文件:/etc/first.sh

作用:将配置文件使用以“_ok”结尾的文件替代。其与接下来要展示的/etc/refirst.sh作用相反。其余细节部分不再细述。


  1. #/bin/bash 
  2. cp -f /etc/xdg/openbox/menu.xml_ok /etc/xdg/openbox/menu.xml 
  3. cp -f /etc/xdg/openbox/autostart_ok /etc/xdg/openbox/autostart 
  4. cp -f /etc/init/tty1.conf_ok /etc/init/tty1.conf 
  5. cp /boot/grub/grub.cfg_ok /boot/grub/grub.cfg 
  6. #克隆系统后往往网卡不能启动,执行下面的命令就可以了。
  7. rm /etc/udev/rules.d/70-persistent-net.rules 
  8. chmod u+w /vmos/shenzhi/Windows\ XP\ Professional.vmx 
  9. chown -R shenzhi.shenzhi /vmos/shenzhi/ 
  10. cp /home/shenzhi/.config/openbox/menu.xml_ok /home/shenzhi/.config/openbox/menu.xml 
  11. chown -R shenzhi.shenzhi /home/shenzhi/.config/openbox/ 
  12. chown -R shenzhi.shenzhi /etc/xdg/openbox/ 
  13. reboot 

对应文件:/etc/refirst2.sh

作用: 用于在配置错误后重新配置的脚本。


  1. #/bin/bash 
  2. #恢复图形界面中的菜单至管理员状态 
  3. cp -f /etc/xdg/openbox/menu.xml_half /etc/xdg/openbox/menu.xml 
  4. #恢复自启动文件 
  5. cp -f /etc/xdg/openbox/autostart_half /etc/xdg/openbox/autostart 
  6. #设置root用户开机自动登录图形界面 
  7. cp -f /etc/init/tty1.conf_half /etc/init/tty1.conf 
  8. #删除多余菜单,缩短开机时间 
  9. cp /boot/grub/grub.cfg_half /boot/grub/grub.cfg 
  10. #在删除快照前,先将虚拟主文件设置为可修改权限 
  11. chmod u+w /vmos/shenzhi/Windows\ XP\ Professional.vmx 
  12. #删除先前创建的快照00 
  13. #vmrun -T ws deletesnapshot "/vmos/shenzhi/Windows XP Professional.vmx" 00 
  14. #恢复网络配置文件到初始模板 
  15. cp /etc/network/interfaces_half /etc/network/interfaces 
  16. #恢复主机名配置文件到初始模板 
  17. cp /etc/hosts_half /etc/hosts 
  18. #恢复主机名配置文件到初始模板 
  19. cp /etc/hostname_half /etc/hostname 
  20. #恢复使用说明文件 
  21. cp /etc/vmshenzhi.txt_ok /etc/vmshenzhi.txt 
  22. #重置结束,提醒用户 
  23. echo "好了,现在可以重新开始配置了!"|leafpad  

     2、普通用户配置文件

对应文件:cat /home/shenzhi/.config/openbox/menu.xml_ok

作用: 位于普通用户“shenzhi”家目录下的菜单配置文件,用于接上面的设置后通过普通用户下的菜单再次对系统进行配置。


  1. <?xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <openbox_menu xmlns="http://openbox.org/" 
  4.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.         xsi:schemaLocation="http://openbox.org/ 
  6.                 file:///usr/share/openbox/menu.xsd"> 
  7.  
  8. <menu id="root-menu" label="Openbox 3"> 
  9.   <item label="**职教虚拟系统"> 
  10.     <action name="Execute"><execute>/home/shenzhi/.config/openbox/hello.sh</execute></action> 
  11.   </item> 
  12.  <!--自定义 添加的配置菜单内容 --> 
  13. <menu id="zheng-menu2" label="[可选]配置虚拟机"> 
  14.   <item label="修改虚拟机快照00"> 
  15.     <action name="Execute"><execute>vmrun -T ws start "/vmos/shenzhi/Windows XP Professional.vmx"</execute></action> 
  16.   </item> 
  17. </menu> 
  18.   <item label="Term"> 
  19.     <action name="Execute"><execute>xterm</execute></action> 
  20.   </item> 
  21.   <item label="[必选]保存并重启"> 
  22.     <action name="Execute"><execute>/etc/shenzhi/rebootshenzhi.sh</execute></action> 
  23.   </item> 
  24.  
  25.  
  26. <menu id="zheng3" label="其他"> 
  27.   <item label="Term"> 
  28.     <action name="Execute"><execute>xterm</execute></action> 
  29.   </item> 
  30.  
  31. <separator /> 
  32.   <!-- This requires the presence of the 'menu' package to work --> 
  33.  
  34.   <item label="刷新"> 
  35.     <action name="Reconfigure" /> 
  36.   </item> 
  37.   <separator /> 
  38. </menu> 
  39. </menu> 
  40.  
  41. </openbox_menu> 

对应文件:/etc/xdg/openbox/menu_ok

作用: 最终的菜单文件,给学生看的,屏蔽了有危害的菜单项。


  1. <?xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <openbox_menu xmlns="http://openbox.org/" 
  4.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.         xsi:schemaLocation="http://openbox.org/ 
  6.                 file:///usr/share/openbox/menu.xsd"> 
  7.  <!--图形界面中的菜单-普通用户状态 --> 
  8. <menu id="root-menu" label="Openbox 3"> 
  9.   <item label="**职教虚拟系统"> 
  10.     <action name="Execute"><execute>/home/shenzhi/.config/openbox/hello.sh</execute></action> 
  11.   </item> 
  12.  <!--自定义 添加的配置菜单内容 --> 
  13.  
  14.   <!--   <item label="Term"> --> 
  15.    <!--    <action name="Execute"><execute>xterm</execute></action> --> 
  16.    <!--  </item> --> 
  17.   <!-- This requires the presence of the 'menu' package to work --> 
  18.  
  19.   <item label="刷新"> 
  20.     <action name="Reconfigure" /> 
  21.   </item> 
  22.   <separator />   
  23. <item label="关于"> 
  24.     <action name="Execute"><execute>feh /boot/kaichuang.jpg</execute></action> 
  25.   </item> 
  26. </menu> 
  27.  
  28. </openbox_menu> 

对应文件:/home/shenzhi/.config/openbox/hello.sh

作用:欢迎信息。


  1. #/bin/bash 
  2. echo "欢迎使用深州职教开发的虚拟系统!"|leafpad 

 

对应文件:/etc/shenzhi/rebootshenzhi.sh

作用:所有的配置完毕后,保存并重启。


  1. cp /home/shenzhi/.config/openbox/menu.xml_ok2 /home/shenzhi/.config/openbox/menu.xml 
  2. cp /etc/xdg/openbox/autostart_ok2 /etc/xdg/openbox/autostart 
  3. shutdown -r now 

对应文件:/home/shenzhi/.config/openbox/menu.xml_ok2

作用:清空的菜单内容。


  1. <?xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <openbox_menu xmlns="http://openbox.org/" 
  4.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.         xsi:schemaLocation="http://openbox.org/ 
  6.                 file:///usr/share/openbox/menu.xsd"> 
  7.  
  8. <menu id="root-menu" label="Openbox 3"> 
  9.   <item label="**职教虚拟系统"> 
  10.     <action name="Execute"><execute>/home/shenzhi/.config/openbox/hello.sh</execute></action> 
  11.   </item> 
  12.  <!--自定义 添加的配置菜单内容 --> 
  13.  
  14. <separator /> 
  15.  
  16.   <!-- This requires the presence of the 'menu' package to work --> 
  17.  
  18.   <item label="刷新"> 
  19.     <action name="Reconfigure" /> 
  20.   </item> 
  21.   <separator /> 
  22. </menu> 
  23.  
  24. </openbox_menu> 

对应文件:/etc/xdg/openbox/autostart_ok2

作用:


  1. # These things are run when an Openbox X Session is started. 
  2. # You may place a similar script in $HOME/.config/openbox/autostart 
  3. # to run user-specific things. 
  4.  
  5. # If you want to use GNOME config tools... 
  6. #if test -x /usr/lib/openbox/gnome-settings-daemon >/dev/null; then 
  7. #  /usr/lib/openbox/gnome-settings-daemon & 
  8. #elif which gnome-settings-daemon >/dev/null; then 
  9. #  gnome-settings-daemon & 
  10. #fi 
  11.  
  12. # If you want to use XFCE config tools... 
  13. #xfce-mcs-manager & 
  14. tint2 & 
  15. #feh --bg-scale /boot/net.jpg & 
  16. #feh /boot/kaichuang.jpg & 
  17. feh --bg-scale /boot/kaichuang.jpg & 
  18. rm -Rf ~/* 
  19. xscreensaver -nosplash& 
  20. chmod u+w /vmos/shenzhi/Windows\ XP\ Professional.vmx 
  21. vmrun -T ws reverttosnapshot "/vmos/shenzhi/Windows XP Professional.vmx" 00 
  22. chmod u-w /vmos/shenzhi/Windows\ XP\ Professional.vmx 
  23. vmrun -T ws start "/vmos/shenzhi/Windows XP Professional.vmx" 
  24. /etc/shenzhi/vmware-shutdown 

对应文件:/etc/shenzhi/vmware-shutdown

作用:实时监控vmware是否运行,若无则自动关机


  1. #/bin/bash 
  2. while : 
  3. do 
  4.     thread_num=`ps -e |grep vmware | wc -l` 
  5.     if [ $thread_num -eq 2 ]; then 
  6.        #date >> shutdowntime.log 
  7.        shutdown -h now 
  8.        exit 
  9.     else 
  10.         echo "Sleeping 2 second..." 
  11.         sleep 2 
  12.     fi 
  13. done 

其它文件:

对应文件:/boot/grub/grub.cfg_half

作用:包含多个选项的系统菜单


  1. # DO NOT EDIT THIS FILE 
  2. # It is automatically generated by grub-mkconfig using templates 
  3. # from /etc/grub.d and settings from /etc/default/grub 
  4.  
  5. ### BEGIN /etc/grub.d/00_header ### 
  6. if [ -s $prefix/grubenv ]; then 
  7.   set have_grubenv=true 
  8.   load_env 
  9. fi 
  10. set default="0" 
  11. if [ "${prev_saved_entry}" ]; then 
  12.   set saved_entry="${prev_saved_entry}" 
  13.   save_env saved_entry 
  14.   set prev_saved_entry
  15.   save_env prev_saved_entry 
  16.   set boot_once=true 
  17. fi 
  18.  
  19. function savedefault { 
  20.   if [ -z "${boot_once}" ]; then 
  21.     saved_entry="${chosen}" 
  22.     save_env saved_entry 
  23.   fi 
  24.  
  25. function recordfail { 
  26.   set recordfail=1 
  27.   if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi 
  28.  
  29. function load_video { 
  30.   insmod vbe 
  31.   insmod vga 
  32.   insmod video_bochs 
  33.   insmod video_cirrus 
  34.  
  35. insmod part_msdos 
  36. insmod ext2 
  37. set root='(hd0,msdos3)' 
  38. search --no-floppy --fs-uuid --set=root b318e04d-999c-4f93-b1e4-0b43283d46f8 
  39. if loadfont /usr/share/grub/unicode.pf2 ; then 
  40.   set gfxmode=1024x768 
  41.   load_video 
  42.   insmod gfxterm 
  43.   insmod part_msdos 
  44.   insmod ext2 
  45.   set root='(hd0,msdos1)' 
  46.   search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  47.   set locale_dir=($root)/grub/locale 
  48.   set lang=en_US 
  49.   insmod gettext 
  50. fi 
  51. terminal_output gfxterm 
  52. if [ "${recordfail}" = 1 ]; then 
  53.   set timeout=-1 
  54. else 
  55.   set timeout=5 
  56. fi 
  57. ### END /etc/grub.d/00_header ### 
  58.  
  59. ### BEGIN /etc/grub.d/05_debian_theme ### 
  60. insmod part_msdos 
  61. insmod ext2 
  62. set root='(hd0,msdos1)' 
  63. search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  64. insmod jpeg 
  65. if background_image /kaichuang.jpg; then 
  66.   true 
  67. else 
  68.   set menu_color_normal=white/black 
  69.   set menu_color_highlight=black/light-gray 
  70. fi 
  71. ### END /etc/grub.d/05_debian_theme ### 
  72.  
  73. ### BEGIN /etc/grub.d/05_debian_theme.bak0 ### 
  74. set menu_color_normal=white/black 
  75. set menu_color_highlight=black/light-gray 
  76. ### END /etc/grub.d/05_debian_theme.bak0 ### 
  77.  
  78. ### BEGIN /etc/grub.d/10_linux ### 
  79. if [ ${recordfail} != 1 ]; then 
  80.   if [ -e ${prefix}/gfxblacklist.txt ]; then 
  81.     if hwmatch ${prefix}/gfxblacklist.txt 3; then 
  82.       if [ ${match} = 0 ]; then 
  83.         set linux_gfx_mode=keep 
  84.       else 
  85.         set linux_gfx_mode=text 
  86.       fi 
  87.     else 
  88.       set linux_gfx_mode=text 
  89.     fi 
  90.   else 
  91.     set linux_gfx_mode=keep 
  92.   fi 
  93. else 
  94.   set linux_gfx_mode=text 
  95. fi 
  96. export linux_gfx_mode 
  97. if [ "$linux_gfx_mode" != "text" ]; then load_video; fi 
  98. menuentry '**职教虚拟系统V1.0,with Linux 3.0.0-14-generic' --class ubuntu --class gnu-linux --class gnu --class os { 
  99.     recordfail 
  100.     set gfxpayload=$linux_gfx_mode 
  101.     insmod gzio 
  102.     insmod part_msdos 
  103.     insmod ext2 
  104.     set root='(hd0,msdos1)' 
  105.     search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  106.     linux   /vmlinuz-3.0.0-14-generic root=UUID=b318e04d-999c-4f93-b1e4-0b43283d46f8 ro   quiet splash vt.handoff=7 
  107.     initrd  /initrd.img-3.0.0-14-generic 
  108.  
  109. ##Clonezilla For Grub.cfg## 
  110. menuentry "Clonezilla For shenzhi" { 
  111. set root=(hd0,1) 
  112. linux /clonezilla/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" ocs_live_keymap=\"\" ocs_live_batch=\"no\" ocs_lang=\"\" ip=frommedia nosplash live-media-path=/clonezilla/live bootfrom=/dev/sda6 toram=filesystem.squashfs 
  113. initrd /clonezilla/live/initrd.img 
  114.  
  115. menuentry 'Ubuntu, with Linux 3.0.0-14-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os { 
  116.     recordfail 
  117.     insmod gzio 
  118.     insmod part_msdos 
  119.     insmod ext2 
  120.     set root='(hd0,msdos1)' 
  121.     search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  122.     echo    'Loading Linux 3.0.0-14-generic ...' 
  123.     linux   /vmlinuz-3.0.0-14-generic root=UUID=b318e04d-999c-4f93-b1e4-0b43283d46f8 ro recovery nomodeset  
  124.     echo    'Loading initial ramdisk ...' 
  125.     initrd  /initrd.img-3.0.0-14-generic 
  126. ### END /etc/grub.d/10_linux ### 
  127.  
  128. ### BEGIN /etc/grub.d/20_linux_xen ### 
  129. ### END /etc/grub.d/20_linux_xen ### 
  130.  
  131. ### BEGIN /etc/grub.d/20_memtest86+ ### 
  132. menuentry "Memory test (memtest86+)" { 
  133.     insmod part_msdos 
  134.     insmod ext2 
  135.     set root='(hd0,msdos1)' 
  136.     search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  137.     linux16 /memtest86+.bin 
  138. menuentry "Memory test (memtest86+, serial console 115200)" { 
  139.     insmod part_msdos 
  140.     insmod ext2 
  141.     set root='(hd0,msdos1)' 
  142.     search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  143.     linux16 /memtest86+.bin console=ttyS0,115200n8 
  144. ### END /etc/grub.d/20_memtest86+ ### 
  145.  
  146. ### BEGIN /etc/grub.d/30_os-prober ### 
  147. ### END /etc/grub.d/30_os-prober ### 
  148.  
  149. ### BEGIN /etc/grub.d/40_custom ### 
  150. # This file provides an easy way to add custom menu entries.  Simply type the 
  151. # menu entries you want to add after this comment.  Be careful not to change 
  152. # the 'exec tail' line above. 
  153. ### END /etc/grub.d/40_custom ### 
  154.  
  155. ### BEGIN /etc/grub.d/41_custom ### 
  156. if [ -f  $prefix/custom.cfg ]; then 
  157.   source $prefix/custom.cfg; 
  158. fi 
  159. ### END /etc/grub.d/41_custom ### 

对应文件:/boot/grub/grub.cfg_ok

作用:精简的grub配置文件


  1. # DO NOT EDIT THIS FILE 
  2. # It is automatically generated by grub-mkconfig using templates 
  3. # from /etc/grub.d and settings from /etc/default/grub 
  4.  
  5. ### BEGIN /etc/grub.d/00_header ### 
  6. if [ -s $prefix/grubenv ]; then 
  7.   set have_grubenv=true 
  8.   load_env 
  9. fi 
  10. set default="0" 
  11. if [ "${prev_saved_entry}" ]; then 
  12.   set saved_entry="${prev_saved_entry}" 
  13.   save_env saved_entry 
  14.   set prev_saved_entry
  15.   save_env prev_saved_entry 
  16.   set boot_once=true 
  17. fi 
  18.  
  19. function savedefault { 
  20.   if [ -z "${boot_once}" ]; then 
  21.     saved_entry="${chosen}" 
  22.     save_env saved_entry 
  23.   fi 
  24.  
  25. function recordfail { 
  26.   set recordfail=1 
  27.   if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi 
  28.  
  29. function load_video { 
  30.   insmod vbe 
  31.   insmod vga 
  32.   insmod video_bochs 
  33.   insmod video_cirrus 
  34.  
  35. insmod part_msdos 
  36. insmod ext2 
  37. set root='(hd0,msdos3)' 
  38. search --no-floppy --fs-uuid --set=root b318e04d-999c-4f93-b1e4-0b43283d46f8 
  39. if loadfont /usr/share/grub/unicode.pf2 ; then 
  40.   set gfxmode=1024x768 
  41.   load_video 
  42.   insmod gfxterm 
  43.   insmod part_msdos 
  44.   insmod ext2 
  45.   set root='(hd0,msdos1)' 
  46.   search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  47.   set locale_dir=($root)/grub/locale 
  48.   set lang=en_US 
  49.   insmod gettext 
  50. fi 
  51. terminal_output gfxterm 
  52. if [ "${recordfail}" = 1 ]; then 
  53.   set timeout=-1 
  54. else 
  55.   set timeout=2 
  56. fi 
  57. ### END /etc/grub.d/00_header ### 
  58.  
  59. ### BEGIN /etc/grub.d/05_debian_theme ### 
  60. insmod part_msdos 
  61. insmod ext2 
  62. set root='(hd0,msdos1)' 
  63. search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  64. insmod jpeg 
  65. if background_image /kaichuang.jpg; then 
  66.   true 
  67. else 
  68.   set menu_color_normal=white/black 
  69.   set menu_color_highlight=black/light-gray 
  70. fi 
  71. ### END /etc/grub.d/05_debian_theme ### 
  72.  
  73. ### BEGIN /etc/grub.d/05_debian_theme.bak0 ### 
  74. set menu_color_normal=white/black 
  75. set menu_color_highlight=black/light-gray 
  76. ### END /etc/grub.d/05_debian_theme.bak0 ### 
  77.  
  78. ### BEGIN /etc/grub.d/10_linux ### 
  79. if [ ${recordfail} != 1 ]; then 
  80.   if [ -e ${prefix}/gfxblacklist.txt ]; then 
  81.     if hwmatch ${prefix}/gfxblacklist.txt 3; then 
  82.       if [ ${match} = 0 ]; then 
  83.         set linux_gfx_mode=keep 
  84.       else 
  85.         set linux_gfx_mode=text 
  86.       fi 
  87.     else 
  88.       set linux_gfx_mode=text 
  89.     fi 
  90.   else 
  91.     set linux_gfx_mode=keep 
  92.   fi 
  93. else 
  94.   set linux_gfx_mode=text 
  95. fi 
  96. export linux_gfx_mode 
  97. if [ "$linux_gfx_mode" != "text" ]; then load_video; fi 
  98. menuentry '**职教虚拟系统V1.0,with Linux 3.0.0-14-generic' --class ubuntu --class gnu-linux --class gnu --class os { 
  99.     recordfail 
  100.     set gfxpayload=$linux_gfx_mode 
  101.     insmod gzio 
  102.     insmod part_msdos 
  103.     insmod ext2 
  104.     set root='(hd0,msdos1)' 
  105.     search --no-floppy --fs-uuid --set=root 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 
  106.     linux   /vmlinuz-3.0.0-14-generic root=UUID=b318e04d-999c-4f93-b1e4-0b43283d46f8 ro   quiet splash vt.handoff=7 
  107.     initrd  /initrd.img-3.0.0-14-generic 
  108.  
  109. ##Clonezilla For Grub.cfg## 
  110. menuentry "Clonezilla For shenzhi" { 
  111. set root=(hd0,1) 
  112. linux /clonezilla/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" ocs_live_keymap=\"\" ocs_live_batch=\"no\" ocs_lang=\"\" ip=frommedia nosplash live-media-path=/clonezilla/live bootfrom=/dev/sda6 toram=filesystem.squashfs 
  113. initrd /clonezilla/live/initrd.img 
  114.  
  115. ### END /etc/grub.d/20_memtest86+ ### 
  116.  
  117. ### BEGIN /etc/grub.d/30_os-prober ### 
  118. ### END /etc/grub.d/30_os-prober ### 
  119.  
  120. ### BEGIN /etc/grub.d/40_custom ### 
  121. # This file provides an easy way to add custom menu entries.  Simply type the 
  122. # menu entries you want to add after this comment.  Be careful not to change 
  123. # the 'exec tail' line above. 
  124. ### END /etc/grub.d/40_custom ### 
  125.  
  126. ### BEGIN /etc/grub.d/41_custom ### 
  127. if [ -f  $prefix/custom.cfg ]; then 
  128.   source $prefix/custom.cfg; 
  129. fi 
  130. ### END /etc/grub.d/41_custom ### 

对应文件:/etc/init/tty1.conf_half

作用: Root用户自动登录的脚本


  1. # tty1 - getty 
  2. # This service maintains a getty on tty1 from the point the system is 
  3. # started until it is shut down again. 
  4.  
  5. start on stopped rc RUNLEVEL=[2345] 
  6. stop on runlevel [!2345] 
  7.  
  8. respawn 
  9. exec /sbin/getty -8 38400 tty1 
  10.  
  11. exec /bin/login -f root < /dev/tty1 > /dev/tty1 2>&1 
  12. #exec /bin/login -f shenzhi < /dev/tty1 > /dev/tty1 2>&1 

对应文件:/etc/init/tty1.conf_ok

作用:普通用户自动登录的脚本


  1. # tty1 - getty 
  2. # This service maintains a getty on tty1 from the point the system is 
  3. # started until it is shut down again. 
  4.  
  5. start on stopped rc RUNLEVEL=[2345] 
  6. stop on runlevel [!2345] 
  7.  
  8. respawn 
  9. exec /sbin/getty -8 38400 tty1 
  10. exec /bin/login -f shenzhi < /dev/tty1 > /dev/tty1 2>&1 

注:若要实现自动登录,还需要在对应的用户家目录下的配置文件“.bashrc”中添加如下内容:


  1. if [ $(tty) == "/dev/tty1" ]; then 
  2. startx 
  3. fi 

结语:

    在我看来,本篇仅是一个罗列,将所涉及的文件陈出,而未细说其中联系,本人是想说,只是想着实在过于困难,故作罢。

【完成于网络实验室, 16:16 2012/2/18 】