Clonezilla 實務課程 孫振凱 http://drbl.nchc.org.tw, http://drbl.sourceforge.net http://clonezilla.nchc.org.tw, http://clonezilla.org.tw 國家高速網路與計算中心 National Center for High-Performance Computing (NCHC) Q2, 2014
Outline (Day 1) Time: 09:30 ~ 16:30 Clonezilla 簡介 / 備份原理 Clonezilla 系統流程架構 / 映像檔介紹 Clonezilla unicast, multicast, broadcast clone 介紹與注意事項 Clonezilla On-the-fly 實做 硬碟 / 磁區差性問題與實務處理 使用多重開機硬像檔佈署實務操作 2
Outline (Day 2) Time: 09:30 ~ 16:30 大量佈署 Windows 相關問題與解決 大量佈署 Linux/Unix 相關問題與解決 製作 Clonezilla Live 可開機隨身碟 ( 學員具自備 USB 隨身碟, 建議 512 MB 以上 ) 使用 Clonezilla Live 作為緊急救援工具 客制化 Clonezilla Live 開機碟與進階使用 3
4 Exercise Index Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast Bigger size hard-drive restore : 40G GParted resize/create partition On-the-fly:disk to disk, disk to remove disk 大量佈署 Windows: DRBL-winroll 大量佈署 Linux/Unix Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
Polling 是電腦教室或網路管理員? 曾經使用 Linux 經驗? 桌面使用? 伺服器使用? 曾經使用過硬碟備份工具? 曾經安裝使用 Clonezilla SE? Clonezilla Live? 5
參考文件 DRBL/Clonezilla 進階使用 http://drbl.nchc.org.tw/advanced Clonezilla Live 文件集 http://clonezilla.nchc.org.tw/clonezilla-live/doc/ Clonezilla 相關文章與報導 http://clonezilla.nchc.org.tw/related_article/ 6
Clonezilla( 再生龍 ) 簡介 / 備份原理
再生龍 Clonezilla Clonezilla [OCS (Opensource Clone System)] Clonezilla 是一完整的硬碟資料複製的工具, 類似 Ghost (Symantec) 或是 Rembo(Acquired by IBM Tivoli software)/ Acronis (True Image) 整合 partclone(http://partclone.org/),partimage (http://www.partimage.org), ntfsclone 與 udpcast 1 (http://udpcast.linux.lu/) 處理元件包含 : 實體資料 : 分割區資料 LVM2 開機載入 (MBR:446+64+2 EFI+GPT) 註 1: 使用在 Server edition 隱藏磁區 用於裸機 (bare material) 還原, 不同於 與以檔案為基礎的備份方式 : 差異備份 增異備份 還原卡模式 兩種釋出版本 Live edition : 合單機 個人使用, 作為備份 還原單一機器使用 Server edition (SE) : 適合大量批次還原, 集中式管理, 如 : 電腦教室管理 大量出機生產線... 8
Terminology 技術用詞 Raw copying* A possibility to perform sector-by-sector copying of a whole partition Smart copying* A possibility to distinguish which portions of the partition really contain data and to copy these only Live copying* A drive or volume can be copied/imaged while it is in use, avoiding the need for booting into a separate operating system or Live CD. Smart copy full disk A possibility to distinguish which portions of the disk really contain data and to copy these only Possible to skip swap, pagefile... * The descriptions are from http://en.wikipedia.org/wiki/comparison_of_disk_cloning_software 9
再生龍 Clonezilla GPL 支援儲存與還原不同作業系統 [ 檔案系統 ] GNU/Linux, MS Windows [ext2/3/4, reiserfs3/4, xfs, jfs, btrfs 1 ], Mac OS [HFS+], Free BSD [UFS], VMWare ESX(i) [VMFS(v3,v5)], Minix [Minix] (2013) Supports LVM2 無法辨識之檔案系統 (ex: zfs..,) 使用 dd Block base 備份方式 只備份有使用之區塊, 提高備份還原效能 Smart copying 支援 Grub 1/2 ( 恢復 重建 ) 支援 serial console 檔案式架構之印象檔 : 格式通透 公開 標準格式 ; 易於彈性調整 支援 Multicast1: 適合大量佈署 能結合使用 Live edition 1 註 1: 使用在 Server edition 10
What's New Fit the program path with Linux concept Add -k1 -icds option for big source to small dist (with -C for partclone ) Post-action with TUI : poweroff/reboot/cmd/rerun1 Minix support Multipath devices, e.g. /dev/cciss/c0d0, are now supported natively. No more linking them to /dev/sd[a-z]. Therefore now LVM on cciss device are supported. Add more information about hardware and partition via lsblk and parted command within Cloneizlla image Xen disk (/dev/xvd[a-z]) was added as a supported device. Three log files, /var/log/clonezilla.log, /var/log/ocs-netcfg.log and /var/log/ocs-mount.log are used to save the logs 11
再生龍 Clonezilla 限制 目的硬碟 ( 分割區 ) 大小至少需等於 ( 或大於 ) 來源硬碟 ( 分割區 ) 不支援差異 (Differential 1 ) 備份 / 增異 (Incremental 1 ) 備份 不支援線上 (Online) 備份 / 回覆 不完全支援 Software RAID/Firmware(Fake) RAID 2 需額外手動步驟調整 印象檔無法支援分片回存 需先將分片檔案集合在同一儲藏空間 註 1: http://en.wikipedia.org/wiki/incremental_backup 註 2:http://en.wikipedia.org/wiki/RAID 12
相關工具 GParted Free partition editor for graphically managing disk and partition http://gparted.sourceforge.net Tuxboot 幫助你建立可開機的 USB 隨身碟, 它支援 Clonezilla live, DRBL live, GParted live 與 Tux2live http://tuxboot.nchc.org.tw/ DRBL-winroll 大量佈署 M$ windows 系統的自動設定輔助工具 (1) 還原後自動修改 M$ Windows 的機器名稱, 群組,(SID)(2) 接受來至 DRBL server 的指令 server 的指令 http://drbl-winroll.nchc.org.tw/ 13
實做環境 Server site Ubuntu Clonezilla SE enable Virtualbox Client site OS-installed/PXE booting/cd/usb drive Linux/Windows Virtual machine(maybe) Clonezilla SE eth0 dhcp Gateway-> Internet Clonzilla client eth1 192.168.25.254 Network link eth0 192.168.25.x 14
15 Exercise Task 安裝 Clonezilla SE 確認網路 Scenario 佈署 Clonezilla SE 環境 DRBL SSI/Clonezilla full mode 使用 server 核心 DHCP use range mode $ sudo drblsrv -i $ sudo drblpush -i $ sudo drbl4imp -r 0 -z 0 -p 6 (-k 2) Client : 實體機器 Check point 確認 client 能以 Clonezilla select-in-client 模式開啟 Hint: use dcs
Clonezilla SE: Full/Box/Live mode /etc, /var, /root of client Files in /etc and /var of client after reboot Extra space in server/client Max client #/ethernet card in server Adv./Dis Full Clonezilla Clonezilla Box Clonezilla Live NFS-based Tmpfs-based Use squashfs Kept Gone Gone ~ 50-100 MB* 0 0 253 253 253 可個別設定 client 組態 / Server 負載較重 Server 負載較輕 / 無法個別設定 client 組態 Server 負載最輕, 較易相容於異質 client 硬體環境 / udpcast 套件版本可能不同 * depends on the packages installed in the server 16
17 Exercise Task 確認以 Full Clonezilla 模式 /etc, /var, /root 等檔案系統格式 以 dcs 切換 Clonezilla Box 模式 確認以 Clonezilla box 模式 /etc, /var, /root 等檔案系統格式 Check point 確認 client 能以 Clonezilla select-inclient 模式開啟
Clonezilla 原理架構 / 硬像檔介紹
Clonezilla 備份流程 Start Parse partition table Save MBR/GPT data Save partition table YES Find the file system of device Find the Device (partition/lv ) NO Smart copying? Decide device imaging engine YES partclone partimage ntfsclone NO Use dd to save image to stdout Save hardware info Save device image to stdout Decide compressing engine gzip bzip2 lzma lzip xz End Save stdin as file in the image dir 19
20 Exercise Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast Use Clonezilla live on SE Run Clonezilla live via PXE Bigger size hard-drive restore GParted resize/create partition On-the-fly:disk to disk, disk to remove disk 大量佈署 Windows: DRBL-winroll 大量佈署 Linux/Unix Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
Clonezilla 映像檔說明 root@debian:~# ls -alfh /home/partimag/precise-img/ Total 1.7G image name -rw-r--r-- 1 root root 366 5 月 27 02:35 blkdev.list -rw-r--r-- 1 root root 4.0K 5 月 27 02:47 clonezilla-img -rw-r--r-- 1 root root 4 5 月 27 02:42 disk -rw-r--r-- 1 root root 1.8K 5 月 27 02:42 Info-dmi.txt -rw-r--r-- 1 root root 9.6K 5 月 27 02:42 Info-lshw.txt -rw-r--r-- 1 root root 1.5K 5 月 27 02:42 Info-lspci.txt Hardware/software -rw-r--r-- 1 root root 171 5 月 27 02:42 Info-packages.txt information -rw-r--r-- 1 root root 86 5 月 27 02:47 Info-saved-by-cmd.txt -rw-r--r-- 1 root root 5 5 月 27 02:42 parts real data of -rw------- 1 root root 1.7G 5 月 27 02:42 sda1.ext4-ptcl-img.gz.aa partition sda1 -rw-r--r-- 1 root root 36 5 月 27 02:35 sda-chs.sf disk C.H.S. value -rw-r--r-- 1 root root 1.0M 5 月 27 02:35 sda-hidden-data-after-mbr Use dd to save -rw-r--r-- 1 root root 512 5 月 27 02:35 sda-mbr MBR and other -rw-r--r-- 1 root root 385 5 月 27 02:35 sda-pt.parted hidden data -rw-r--r-- 1 root root 346 5 月 27 02:35 sda-pt.parted.compact partition info from parted and sfdisk -rw-r--r-- 1 root root 310 5 月 27 02:35 sda-pt.sf UUID and label info of -rw-r--r-- 1 root root 53 5 月 27 02:42 swappt-sda5.info sda2 (swap partition) 21
Clonezilla 還原流程 Start Read image Create partition table Create LV if LV image found in image dir Find the image of device NO Tune the file file system size to fit partition size YES Decide device imaging engine partclone partimage ntfsclone Reinstall grub if assigned End Restore the image of device to device 22
23 Exercise Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast Use Clonezilla live on SE Run Clonezilla live via PXE Bigger size hard-drive restore GParted resize/create partition On-the-fly:disk to disk, disk to remove disk 大量佈署 Windows: DRBL-winroll 大量佈署 Linux/Unix Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
硬碟大小不同的處理方式 原則 : 目的分割區必須等於或大於來源分割區 小硬碟 -> 大硬碟 : 與原始硬碟分割區規劃相同 : 自行處理後段未始用空間 按比例放大 : 只適用於 MBR 分割格式, 不適用 GPT 大硬碟 -> 小硬碟 : 決定部份分割區回覆與否 Restore partition 需要整顆硬碟 restore 事先調整來源分割區大小 : GParted, Partition magic, EASEUS Partition Master 24
25 Exercise Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast Use Clonezilla live on SE/via PXE Different size hard drive restoring Small to bigger:manually/ proportionally Big to smaller: GParted resize/create partition On-the-fly:disk to disk, disk to remove disk 大量佈署 Windows: DRBL-winroll 大量佈署 Linux/Unix Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
Clone without image Use clone on-the-fly Server : OCS -> select in client Client : select Device-device 兩種 device to device 方式 : Device to local device 確認 source/destination device Device to remote device 1. 設定好來源端 2. 目的端進入 console 確認網路 Ocs-onthefly -s [source ip] -t [device id] $ ocs-onthefly -s 192.168.1.1 -t sda 26
Clonezilla SE via DRBL Live 使用 DRBL Live 建置再生龍伺服器 不需要安裝, 只需要配置定後即可使用再生龍伺服器版本功能 Download: http://drbl.nchc.org.tw 下載 DRBL live ISO 檔 (CD/DVD 用 ), 或者 zip 檔 (USB 隨身碟或硬碟用 ) 使用 Live CD 開機 執行 再生龍伺服器 掛載印像檔儲存空間 佈署並啟動再生龍 SE 27
28 Exercise Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast Use Clonezilla live on SE Run Clonezilla live via PXE Bigger size hard-drive restore GParted resize/create partition On-the-fly:disk to disk, disk to remove disk 大量佈署 Windows: DRBL-winroll 大量佈署 Linux/Unix Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
MBR vs GPT 比較 MBR GPT 名稱 Master Boot Record GUID Partition Table 可切割數量 4(3+1) 128 (unlimited, base on OS ) 單一分割區最大容量 2T 18 EB 最大規劃硬碟 <4T 9.4ZB Master Boot Record 29
先進格式硬碟 Advanced Format Technology 30
先進格式硬碟 儲存密度的上升會明顯降低磁頭讀取磁碟的信噪比, 雖然可以用 ECC 校驗保證資料可靠性, 但消耗的空間會抵消儲存密度上升帶來的多餘空間 在 x86 架構下, 通常內部記憶體分頁容量為 4KB 許多磁碟檔案系統 ( 如 NTFS ext3 HFS+ 等 ) 的簇容量 也為 4KB 早期 512byte 磁區需要另外 40byte 作為 ECC 校驗空間 而 4kbyte 磁區只需要 100byte 減少 ECC 的佔用和提升 ECC 校驗效率 同樣提供 4kbyte 磁區空間, 使用先進格式化能節約出 220byte http://zh.wikipedia.org/wiki/%e5%85%88%e9%80%b2%e6%a0%bc%e5%bc%8f%e5%8c%96 31
與 WD 先進格式化 (WD Advanced Format) 硬碟相容性 Advanced Format 互相 clone 不會有問題 Advanced Format 硬碟 clone 到沒有 Advanced Format 的硬 碟也沒有問題 會有問題的方式 : 在舊硬碟 (160G) 安裝 XP, clone 起來, 還原到新硬碟 1.5T(WD15EARS) 用 wd align 工具去修復 用 clonezilla + 手動調整 http://drbl.nchc.org.tw/fine-print.php? path=./faq/1_drbl_common/53_wd_advanced_format_disk.faq#53_wd_adv anced_format_disk.faq 32
多重開機環境探討 Boot loader 運作模式 : Windows XP, Win7 : ntldr/bootmgr Linux : Grub1/2 Restore 可能問題探討 33
Restore single partition Restore partition : sda1 Use 8G hard drive, use source partition table How to : Modify partition table Add advanced parameters : -idcs Restore done but boot failed!! 34
35 Exercise Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast On-the-fly:disk to disk, disk to remove disk Use Clonezilla live on SE Run Clonezilla live via PXE Bigger size hard-drive restore GParted resize/create partition 大量佈署 Linux/Unix : use pre-run/post-run 大量佈署 Windows: DRBL-winroll Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
佈署 Linux 之探討 硬體差異度 範本機處理 驅動程式預載 硬體設定檔 網路 顯示卡 硬碟 分割區代號影響... 系統安全與軟體 非必要之紀錄檔 (log, root history) 個人相關安全紀錄檔 (web account/passwd) 集中式管理 36
佈署 Windows 之探討 硬體差異度 範本機處理 驅動程式預載 Sysprep 硬體設定檔 網路... 系統安全與軟體 非必要之紀錄檔 (log) 個人相關安全紀錄檔 (web account/passwd) 集中式管理 輔助工具 : DRBL-winroll 37
38 Exercise Setup Clonezilla SE Save/Restore image via Clonezilla SE Select-in-client/Multicast On-the-fly:disk to disk, disk to remove disk Use Clonezilla live on SE Run Clonezilla live via PXE Bigger size hard-drive restore GParted resize/create partition 大量佈署 Linux/Unix : use pre-run/post-run 大量佈署 Windows: DRBL-winroll Advanced restore for dualboot Clonezilla on USB flash Clonezilla Live 客制化
Clonezilla Live 發行版 (Debian based) : 穩定版 / 測試版 ; 替代版 (Ubuntu based) : 穩 定版 / 測試版 光碟版 (iso 檔案 ) 下載後, 把該 ISO 檔案燒到光碟片上 ( 記得要選用燒錄映象檔的方式, 舉例而言, 在 MS Windows 下, 以 Nero Burning ROM 為例, 你要選 ' 燒錄映像檔 " 來燒這個 iso 檔 ), 就可以用它來開機 USB 隨身碟或隨身硬碟版 (zip 檔案 ) 硬碟版 將 Clonezilla live 放在一個已經有作業系統存在的硬碟中 PXE 版 將 Clonezilla live 放在 PXE 伺服器上來讓用戶端電腦透過 PXE 網路開機使用 Clonezilla live 詳情參考 : http://clonezilla.nchc.org.tw/clonezilla-live/ 39
Clonezilla Live 版本差異 差異穩定版 / 測試版替代版 OS baesd Debian-based Ubuntu-based iso/zip 檔案大小 大約小 10 MB 大約大 10 MB 是否包含不自由的軟體 ( 例如 firmware) 對 486 CPU 的支援 多核心 / 多處理器的支援 否 486 版的 iso/zip 有支援 (CONFIG_M486=y) 686 版有支援, 486 版不支援 是 不支援 (CONFIG_M586=y and CONFIG_X86_GENERIC=y) 有 40
Exercise Setup Clonezilla SE Save/Restore/Select-in-client image via Clonezilla SE On-the-fly:disk to disk, disk to remove disk Use Clonezilla live on SE/ Run Clonezilla live via PXE Bigger size hard-drive restore / GParted resize/create partition 大量佈署 Linux/Unix : use pre-run/post-run 大量佈署 Windows: DRBL-winroll Advanced restore for dualboot Clonezilla Live 應用 1. Save/restore disk via network fs: sshfs, samba 2. Save/restore partitions from local disk 3. Create Clonezilla recover CD/DVD 4. install live into usb, hd 5. Customize Clonezilla live 6. Insert customized Clnezilla live into hd 41
測驗練習
43 練習 1. 利用 dual boot 印象檔, 將其中的 Linux (sda5) 部份 restore 到實體機器中 2. 利用 dual boot 印象檔, 將其中的 XP (sda1) 部份 restore 到虛擬機器中 條件 : 目的硬碟分割表只留下 sda1 分割區, 並確定能夠正確啟動 Windows XP
DRBL-winroll 架構與功能簡介 http://drbl-winroll.nchc.org.tw/ http://www.drbl-winroll.org/
Clonezilla 進階使用 附錄
進階使用 : Clonezilla SE /Clonezilla Live 附錄 Clonezilla live 與 Clonezilla SE (Server Edition) 原理與架構介紹 Clonezilla box mode 介紹 Unicast, multicast, broadcast clone 介紹與注意事項 如何轉換印象檔中的硬碟代號 PXE 開啟 Clonezilla live 作法 如何製作 clonezilla live 開機 usb 隨身碟或硬碟 我要怎麼自己從無到有做一個 Clonezilla live? 客製化 Clonezilla live 製作 有沒有可能把 Clonezilla Live 放到硬碟中來執行? 利用 virtualbox 來做 Clonezilla 開發與測試環境 46
Note 至 text console 端以 root 登入 drbladm/ilovedrbl 如果要新增帳號 加入 admin 群組 export LC_ALL=C adduser [your acount] adduser [your account] admin 至 GDM 使用一般使用者登入 確認網路線連接至學生機 auto eth1 iface eth1 inet static address 192.168.101.254 netmask 255.255.255.0 47
Note http://drb.nchc.org.tw Clonezilla live 使用 save/restore Onethefly 網路芳鄰 :192.168.167.11 Path: share administrator/[ 空 ] Clonezilla live 客制化 Include image Include without image, customized pre-run Debian live templet customize 48