学生机房虚拟化(十二)搭建Clonezilla SE

简介:

引入:

    本博文将会是学生机房中的虚拟化专题中的核心内容。因为,通过本篇博文的讲述,大家可以看到用于网络化批量部署Linux系统的Clonezilla SE搭建的全过程。注意,几乎所有命令均为在超级用户模式下执行。

何为Clonezilla SE:

    以下文字引自:http://drbl.nchc.org.tw 臺灣國家高速網路與計算中心自由軟體實驗室

    適合大量備份與還原的伺服器版再生龍Clonezilla SE(用戶端使用PXE網路開機)。Clonezilla SE適合來大量部署作業系統的時候使用,當然也適合單機備份還原使用。不過這樣的限制是一定要有一台DRBL伺服器,而且要被備份的電腦一定要能網路開機。

    Clonezilla SE就內建在DRBL環境中,因此,可以在以下的GNU/Linux套件上安裝:

Debian

Ubuntu

B2D,

RedHat Linux

Fedora Core

Mandrake, Mandriva

CentOS

Scientific Linux

SuSE, OpenSuSE

至於Clonezilla的印象檔是互通的,也就是Clonezilla live和Clonezilla SE都可以共用。

安裝Clonezilla SE:

针对Ubuntu 11.04及以上版本。

1.切换到超级用户

 
  1. shenzhi@sz0850:~$ sudo su - 
  2. [sudo] password for shenzhi: 

2.安装软件的APT-KEY

    第一种方法:

 
  1. wget -q http://drbl.nchc.org.tw/GPG-KEY-DRBL -O- | sudo apt-key add - 

    第二种方法:

 
  1. gpg --keyserver subkeys.pgp.net --recv-key D7E8DF3A 
  2. pg -a --export D7E8DF3A | apt-key add - 

3.编辑/etc/apt/sources.list

    加入如下内容:

 
  1. deb http://free.nchc.org.tw/ubuntu natty main restricted universe multiverse 
  2. deb http://free.nchc.org.tw/drbl-core drbl stable 

4.升级并安装drbl

 
  1. apt-get update 
  2. apt-get install drbl 

    由于是从台湾那里下载软件包,网速可能会慢些。

配置Clonezilla SE

    由于是在虚拟机中做的Clonezilla SE的安装实验,所以只设定一个网卡。

1.DRBL所依赖的环境配置

 
  1. shenzhi@sz0850:~$ sudo /opt/drbl/sbin/drblsrv -i  

    由于的编写的时候浏览器崩溃,没有来得及保存编辑好的网页,所以我的设置看不到了。

2.DRBL初始化配置

    以下是我的实验配置,可以做下参考。

 
  1. shenzhi@sz0850:~$ sudo /opt/drbl/sbin/drblpush -i 
  2. [sudo] password for shenzhi: 
  3. ****************************************************** 
  4. 提示!当有yes/no选项的时候,默认的值是大写的字母。例如(y/N),默认值是"N",当您按"Enter"的时候,程序使用的值就是"N"。如果您不确认选择哪个好的时候,直接按"Enter"键是一个保险的方式。 
  5. ****************************************************** 
  6. 正在搜索DRBL服务器中已经安装的相关程序...这可能需要几分钟... 
  7. 完成寻找DRBL服务器所需的相关程序。 
  8. ****************************************************** 
  9. ------------------------------------------------------ 
  10. 这是一个交互模式,在设置DRBL环境的过程中,您必须提供相关资料 
  11. ------------------------------------------------------ 
  12. ------------------------------------------------------ 
  13. 请输入域名(DNS domain),例如drbl.sf.net: 
  14. [drbl.name] shenzhi.com 
  15. 您设定的域名(DOMAIN)是 shenzhi.com 
  16. ------------------------------------------------------ 
  17. 请输入NIS/YP域名: 
  18. [penguinzilla] shenzhi 
  19. 您设定的域名(DOMAIN)是 shenzhi 
  20. ------------------------------------------------------ 
  21. 请输入客户端主机名称的前缀: 
  22. 这个前缀是用来自动生成客户端主机名称的,如果您有部分或者全部机器不使用这个自动产生的主机名称,您想自己指定用户主机名称,现在可以按Ctrl-C退出这个程序,编辑/opt/drbl/conf/client-ip-hostname后,再执行这个程序。 
  23. [sz0850] 
  24. 您设定的客户端计算机的主机名称的前缀是 sz0850 
  25. ------------------------------------------------------ 
  26. eth0: IP address 192.168.1.150, netmask 255.255.255.0 
  27. 在您的系统上找到已经设置好的以太网卡有: eth0 
  28. ------------------------------------------------------ 
  29. 没有找到这台服务器的公开IP地址, 
  30. 哪个网卡是这台服务器用来连接到互联网的,而不是给DRBL环境使用的? 
  31. 这台服务器有的以太网卡: 
  32. eth0 (192.168.1.150), 
  33. [eth0] 
  34. 您所选择连接到广域网的以太网卡是: eth0 
  35. ///警告/// 在这台机器上只有找到一个设置好的网卡,我们不建议您这样做。因为这台DRBL服务器将会提供DHCP服务,只有一个网卡可能会扰乱您现有的网络环境,特别是您一竟有一个现存的DHCP服务和这个网卡通过网络交换机连接在一起。建议您至少使用两个网卡来避免这个问题。 
  36. 您确认要继续执行? 
  37. [y/N] y 
  38. ****************************************************** 
  39. ****************************************************** 
  40. 现在我们可以收集客户端计算机网卡的MAC地址(MAC Address)! 
  41. 通过这个收集的步骤可以帮助您的DRBL环境让客户端计算机每次开机都可以取得相同的IP, 
  42. 如果您没有客户端计算机网卡的MAC地址存档时,您现在就应该做! 
  43. 如果您已经有客户端计算机网卡的MAC地址存档时,您也可以把那些MAC地址排序分组后,一行一行地填在文件中(文件的数量就是您DRBL分流网卡的个数),那么,这个步骤您就可以略过。 
  44. 这个步骤就是帮您侦测MAC地址,然后保存到文件中,省去您抄录MAC地址的时间以及可能的抄写错误 
  45. 客户端计算机的网卡MAC地址将会按照您客户端计算机的开机顺序被记录下来。 
  46. 所收集到底网卡MAC地址将会依照客户端计算机连到DRBL服务器的网卡来给文件名,保存下来的文件名如macadr-eth1.txt、macadr-eth2.txt... 您可以在/etc/drbl/目录下找到这些文件。 
  47. 请先将客户端计算机设置为网络开机(etherboot或是PXE),并依照您想要排列的顺序开机! 
  48. 您是否要收集客户端计算机的网卡MAC地址? 
  49. [y/N] 
  50. ****************************************************** 
  51. 继续... 
  52. ****************************************************** 
  53. 您是否要让DRBL服务器的DHCP服务每次都分配相同的IP给客户端计算机(要使用这个选项,您必须已经收集好客户端计算机的网卡MAC地址(如前述的步骤)并且保存在文件中),这是针对连接到DRBL服务器网卡的 eth0 ? 
  54. [y/N] 
  55. ****************************************************** 
  56. 继续...客户端计算机会采用非固定IP! 
  57. Hostmin: 192.168.1.1 
  58. ****************************************************** 
  59. 这个域的客户端计算机中,起始的IP的4组数字中,最后一组数字的起始值是(也就是IP a.b.c.d的d的起始值)?这是针对连接到DRBL服务器网卡的 eth0. 
  60. [1] 101 
  61. ****************************************************** 
  62. 有多少台DRBL客户端计算机(也就是给学生使用的电脑)连接到DRBL服务器网卡 eth0 ? 
  63. 请输入数字: 
  64. [12] 10 
  65. ****************************************************** 
  66. 这个域的客户端计算机中,起始的IP地址4组数字中,最后一组数字的最后一个为 "110". 
  67. 我们将设置这些客户端计算机的IP为,这是针对连接到DRBL服务器网卡的 eth0 因为: 192.168.1.101 - 192.168.1.110 
  68. 接受 ? [Y/n] 
  69. ****************************************************** 
  70. 继续... 
  71. ****************************************************** 
  72. 您的DRBL环境配置: 
  73. ****************************************************** 
  74.           NIC    NIC IP                    Clients 
  75. +-----------------------------+ 
  76. |         DRBL SERVER         | 
  77. |                             | 
  78. |    +-- [eth0] 192.168.1.150 +- to WAN 
  79. |                             | 
  80. |    +-- [eth0] 192.168.1.150 +- to clients group 0 [ 10 clients, their IP 
  81. |                             |            from 192.168.1.101 - 192.168.1.110] 
  82. +-----------------------------+ 
  83. ****************************************************** 
  84. Total clients: 10 
  85. ****************************************************** 
  86. 按"Enter"键来继续... 
  87. ****************************************************** 
  88. ------------------------------------------------------ 
  89. 本系统中,有3种模式可以提供无盘的Linux服务给客户端使用: 
  90. [0] 完全DRBL模式(Full DRBL mode),每个客户端都有自己的/etc和/var(基于NFS)。 
  91. [1] 单一系统映像文件模式(DRBL SSI, single system image),每个客户端都使用tmpfs(以内存来当虚拟磁盘)的/etc和/var。此模式中,Clonezilla服务器的负载和所需的硬盘空间会少一些。但是请注意!这个模式中,(a)客户端计算机的内存建议至少要256MB以上,(b)客户端计算机的系统设置并不会保存到服务器中。所有开机后的系统设置只会使用一次,关机后就会消失。此外,如果您修改过任何范本机器的设置文件(也就是位于/tftpboot/nodes下的设置文件),您要再执行/opt/drbl/sbin/drbl-gen-ssi-files来生成新的tarball范本文件于/tftpboot/node_root/drbl_ssi/中,(c)如果您要针对某些客户端设置一些特别的文件,可以参考/tftpboot/node_root/drbl_ssi/clients/00_README。 
  92. [2] 不要提供无盘Linux服务给客户端使用。 
  93. 您要选择哪一个模式? 
  94. [0] 2 
  95. 不要提供无盘Linux服务给客户端使用。 
  96. ****************************************************** 
  97. ------------------------------------------------------ 
  98. 本系统中,Clonezilla再生龙有4个模式可以选择: 
  99. [0] 完全模式(Full clonezilla mode),每个客户端都有自己的/etc和/var(基于NFS)。 
  100. [1] 
  101. [1] 再生龙盒模式(Clonezilla box mode),每个客户端都使用tmpfs(以内存来当虚拟磁盘)的/etc和/var。此模式中,Clonezilla服务器的负载和所需的硬盘空间会少一些。但是请注意!这个模式中,客户端计算机的系统设置文件并不会报存在服务器中。所有开机后的系统设置只会使用一次,然后关机后就会消失! 
  102. [2] 我不要使用再生龙。 
  103. [3] 使用Clonezilla live当作用户端做clonezilla工作时的操作系统(测试中)。 
  104. 您要选择哪一个模式? 
  105. [0] 3 
  106. 使用Clonezilla live当作用户端执行Clonezilla工作的操作系统。 
  107. ****************************************************** 
  108. ****************************************************** 
  109. 使用哪个分支的Clonezilla live? 
  110. [0]: 稳定版(Debian-based) 
  111. [1]: 测试版(Debian-based) 
  112. [2]: 稳定替代版(Ubuntu-based) 
  113. [3]: 测试替代版(Ubuntu-based) 
  114. 若不确认,选[2]: 稳定替代版 
  115. [2] 
  116. ****************************************************** 
  117. Clonezilla live分支选定为: alternative 
  118. ****************************************************** 
  119. 用户端执行Clonezilla的工作时,选用的CPU架构是: generic 
  120. ------------------------------------------------------ 
  121. 使用再生龙的时候,您要把映像文件报存在这台机器的哪个目录中(请使用绝对路径,并且不要指定在/mnt/、/media/或者/tmp/下)? 
  122. [/home/partimag] 
  123. Directory for clonezilla saved images: /home/partimag 
  124. ****************************************************** 
  125. 客户端开机后为文字模式。 
  126. ****************************************************** 
  127. 继续... 
  128. ------------------------------------------------------ 
  129. 基于安全考虑,您是否要为客户端计算机设置开机密码? 
  130. [y/N] 
  131. 继续... 
  132. ------------------------------------------------------ 
  133. 您是否要在客户端计算机开机的时候允许用户选择自己所要的操作系统? 
  134. [Y/n] 
  135. 客户端计算机开机,出现提示符时需要等待多少个0.1秒? 
  136. [70] 
  137. 继续... 
  138. ------------------------------------------------------ 
  139. ------------------------------------------------------ 
  140. 您是否要在客户端计算机开机的时候使用图形背景的菜单? 
  141. 注意!如果您的客户端使用图形背景无法正常开机,您可以使用"/opt/drbl/sbin/switch-pxe-bg-mode -m text"来切换成文字模式的背景。 
  142. [y/N] 
  143. Use text PXE Linux menu for the client. 
  144. ------------------------------------------------------ 
  145. 继续... 
  146. ------------------------------------------------------ 
  147. ------------------------------------------------------ 
  148. 您是否要让DRBL服务器也能提供NAT服务(也就是一般俗称的IP共享功能)?如果不要的话,DRBL客户端计算机将无法连接到互联网。 
  149. [Y/n] n 
  150. 这台DRB服务器未提供NAT服务(也就是一般俗称的IP共享功能),DRBL客户端计算机将无法连接到互联网。 
  151. ****************************************************** 
  152. DRBL服务器目前使用的内核支持 NFS over TCP! 
  153. 【注意】如果您改变DRBL服务器目前使用的内核版本,并且不确认那个内核是否支持基于UDP或者TCP的NFS,您最好重新执行"drblpush -i"以免客户端计算机开不了机! 
  154. 按"Enter"键来继续... 
  155. ------------------------------------------------------ 
  156. ****************************************************** 
  157. The calculated NETWORK for eth0 is 192.168.1.0. 
  158. ****************************************************** 
  159. ****************************************************** 
  160. 现在准备部署这些文件到系统中! 
  161. 您要继续执行么? 
  162. 警告!如果您继续执行,您的防火墙规则将会被改写! 
  163. 原来的规则将会被备份为iptables.drblsave于系统的设置目录中(/etc/sysconfig或者/etc/default)。 
  164. [Y/n] 
  165. ****************************************************** 
  166. 开始进行... 
  167. ------------------------------------------------------ 
  168. Checking the necessary disk space... done! 
  169. Copying the config file to /etc/drbl... done! 
  170. Backup the original /etc/hosts as /etc/hosts.drblsave... done! 
  171. Generate the /etc/hosts for clients connected to eth0... done! 
  172. Cleaning the stale files of the diskless nodes if they exist... done! 
  173. *****************************************************. 
  174. *****************************************************. 
  175. The version number for your GNU/Linux: DBN-TU 
  176. Keeping the old common root files if they exist... 
  177. Keeping old nodes if they exist... 
  178. Creating common root files... This might take several minutes........... done! 
  179. Update the kernel for client if necessary... 
  180. The DRBL client uses i686 kernel with version 3.0.0-14-generic... 
  181. Trying to update the /tftpboot/node_root/lib/modules/3.0.0-14-generic from server's /lib/modules/... This might take several minutes... 
  182. Found kernel modules in /lib/modules/3.0.0-14-generic and its arch "i686" matches client's "i686"... 
  183. Syncing /lib/modules/3.0.0-14-generic to client's common root... 
  184. Syncing /boot/*-3.0.0-14-generic* to client's common root... 
  185. Generating the /tftpboot/node_root/lib/modules/3.0.0-14-generic/modules.dep 
  186. Syncing /lib/firmware/ to client's common root... 
  187. Copying the directory /etc/ to clients common root /tftpboot/node_root... 
  188. Cleaning the ssh key file ssh_host_dsa_key copied from server... done! 
  189. Cleaning the ssh key file ssh_host_dsa_key.pub copied from server... done! 
  190. Cleaning the ssh key file ssh_host_rsa_key copied from server... done! 
  191. Cleaning the ssh key file ssh_host_rsa_key.pub copied from server... done! 
  192. Commenting the TCPwrapper related file /tftpboot/node_root/etc/hosts.deny copied from server... done! 
  193. Commenting the TCPwrapper related file /tftpboot/node_root/etc/hosts.allow copied from server... done! 
  194. The startup services for DRBL client are: 
  195. firstboot portmap nis ssh dbus drblthincli arm-wol sendsigs umountfs 
  196. Using udev for clients... The default display manager is NOT found! We can NOT set text or graphic mode for Debian DRBL client. 
  197. Deleting the accounts (except root) in the clients common root template... done! 
  198. Enabling the NIS client in the common root template... done! 
  199. Creating some necessary files in the clients common root template...... done! 
  200. Creating DRBL client: sz08500101 192.168.1.101... Generating SSH host keys for client 192.168.1.101 if they do not exist... done! 
  201. Creating DRBL client: sz08500102 192.168.1.102... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  202. Creating DRBL client: sz08500103 192.168.1.103... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  203. Creating DRBL client: sz08500104 192.168.1.104... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  204. Creating DRBL client: sz08500105 192.168.1.105... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  205. Creating DRBL client: sz08500106 192.168.1.106... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  206. Creating DRBL client: sz08500107 192.168.1.107... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  207. Creating DRBL client: sz08500108 192.168.1.108... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  208. Creating DRBL client: sz08500109 192.168.1.109... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  209. Creating DRBL client: sz08500110 192.168.1.110... Pseudo client is created for DRBL SSI or clonezilla box mode! done! 
  210. Preparing the system to use clonezilla live as the OS of clients... 
  211. Try to download Clonezilla live iso file from network... 
  212. The CPU arch for client was assigned as: generic 
  213. No Clonezilla live iso was assigned in drbl-ocs.conf or command line option. 
  214. Trying to find the available Clonezilla live iso from sourceforge... 
  215. Available Clonezilla live iso URL: http://downloads.sourceforge.net/clonezilla/clonezilla-live-20120127-oneiric.iso 
  216. Downloading the Clonezilla live iso from http://downloads.sourceforge.net/clonezilla/clonezilla-live-20120127-oneiric.iso... 
  217. --2012-03-27 14:18:14--  http://downloads.sourceforge.net/clonezilla/clonezilla-live-20120127-oneiric.iso 
  218. Resolving downloads.sourceforge.net... 216.34.181.59 
  219. Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected. 
  220. HTTP request sent, awaiting response... 301 Moved Permanently 
  221. Location: http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_alternative/20120127-oneiric/clonezilla-live-20120127-oneiric.iso [following] 
  222. --2012-03-27 14:18:17--  http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_alternative/20120127-oneiric/clonezilla-live-20120127-oneiric.iso 
  223. Reusing existing connection to downloads.sourceforge.net:80. 
  224. HTTP request sent, awaiting response... 302 Found 
  225. Location: http://cdnetworks-kr-1.dl.sourceforge.net/project/clonezilla/clonezilla_live_alternative/20120127-oneiric/clonezilla-live-20120127-oneiric.iso [following] 
  226. --2012-03-27 14:18:17--  http://cdnetworks-kr-1.dl.sourceforge.net/project/clonezilla/clonezilla_live_alternative/20120127-oneiric/clonezilla-live-20120127-oneiric.iso 
  227. Resolving cdnetworks-kr-1.dl.sourceforge.net... 211.39.135.162 
  228. Connecting to cdnetworks-kr-1.dl.sourceforge.net|211.39.135.162|:80... connected. 
  229. HTTP request sent, awaiting response... 200 OK 
  230. Length: 118489088 (113M) [application/octet-stream] 
  231. Saving to: `/tmp/ocslive_tmp.xVN32b/clonezilla-live-20120127-oneiric.iso' 
  232.  
  233.  0% [                                       ] 430,434     20.8K/s  eta 1h 40m  ^C 
  234. 注意:此处不要按下Ctrl+C键中止下载。 
  235. shenzhi@sz0850:~$ 

运行Clonezilla SE

 启动企鹅龙(DRBL)

    以下的内容将展示:1.备份客户端系统;2.分发所备份的系统。由于具体操作技术难度不大,却很占篇幅,这里仅展示主要内容。

 
  1. sudo /opt/drbl/sbin/dcs 

 启动后界面:

    All表示,在设置DRBL(即Clonezilla SE)后,将会使同一局域网内所有从网卡启动的计算机,接受DRBL的控制。[当前选择]

    Part表示控制指定的计算机,通过IP与MAC表。

    启动再生龙模式。此模式启动后,同一局域网内所有从网卡启动的计算机,将接受DRBL的控制。

    再生龙的设置界面,以前的博文中有提及。

    如果备份选择前两项,还原则选择后两项。

    以下配置略。

客户端测试

    对客户端的要求是:1、必须与服务器位于同一局域网;2、BIOS中设置通过网卡启动;    

结语

    本文内容比较松散,并没有展示一个完整实验过程,希望可以起到抛砖引玉的作用。有一点是要强调的,图形界面远远不如命令行方式简洁、强大。只是作为初步展示本文没有涉及,如果可能,会有相关的博文和大家见面。

【完成于网络实训室, 08:29 2012/3/28 】

 


本文转自tiancong 51CTO博客,原文链接:http://blog.51cto.com/tiancong/817099


相关实践学习
基于函数计算快速搭建Hexo博客系统
本场景介绍如何使用阿里云函数计算服务命令行工具快速搭建一个Hexo博客。
相关文章