2009年9月14日 星期一

利用Clonezilla成功備份3系統,redobackup或僅指令

※051012加入
取自 ubuntu12.04 安裝,更新,設定後,要如何複刻給另一台電腦?
2樓及4樓,分別摘錄如下:
... 
如果覺得再生龍太複雜,那國外有另一套更單純的叫redobackup
http://redobackup.org/
※ubuntu介面,win/linux皆可用,含Gparted等,但無法由大到小
※但也無法備份雙系統
Cloning Ubuntu Linux – The easy way

Your Ubuntu Linux installation is getting bigger and bigger and you are running out of space on your hard disk. You got your new hard drive and now you need to clone your old drive to the new one. The dreaded cloning is actually quite easy and relatively simple to do. The only thing you will need is a little patience and some typing skills. No special software just your already installed Ubuntu Linux.
The regular obligatory disclaimer: This procedure worked for me several times, I use it almost on a daily basis and I had no problems with it. Your mileage my vary. Make sure you double check all the commands that you type and that you do not format your data drive. You will end up with two empty disks. If you have any questions feel free to ask.

The very basic scenario is assumed here. You have one hard drive installed as /dev/sda and you want to replace it with a new one. You could just add the new drive and mount it to /home directory for example, but sometimes that is not what you want. I am also assuming that you have SATA drives. This procedure can also be used if you get a new computer and you do not want to bother with new installation. In this case you will have to be more careful if you are moving from one platform to another.

Step 0 – Prerequisites

First make sure that you have all the software installed:
$ sudo apt-get install grub-pc rsync
Yes, that is it.

Step 0.5 – Disk juggling

Turn off your computer, connect your new hard drive and turn your computer back on. Make sure that you do not disconnect the old drive, you still need it. ;)

Step 1 – Partitioning, formatting and mounting

Check where your new drive is, it will usually be accessible as /dev/sdb. Use fdisk to partition the hard drive and then mkfs to format it. If you created more than one partition then you will have to mount all of them. In this example the unknown user created swap, root and home partitions. Here’s how you mount them:
$ sudo mount /dev/sdb2 /mnt
$ sudo mkdir /mnt/home
$ sudo mount /dev/sdb3 /mnt
$ sudo mkswap /dev/sdb1

Step 2 – Cloning

After your new partitions are mounted you need to copy all your data to the new location. You will do this with rsync.
$ sudo rsync --exclude="mnt" --exclude="lost+found" --exclude="sys" --exclude="proc" -avP / /mnt/
$ sudo mkdir /mnt/mnt /mnt/proc /mnt/sys
No need to copy /proc and /sys, they are virtual file systems and they will be created later on. You still need to create the directories that were not copied.

Step 3 – Rescuing the system

Data is transferred and now you need to take care of few other minor details. In /mnt/etc/fstab you will have to change the UUID string for mounting the partitions. I suggest that you replace UUID with /dev/sda2 for root disk and /dev/sda3 for /home. This will vary depending on your configuration. If you are feeling adventurous you can find the UUID’s of your new partitions and replace the old ones with them. Use the blkid command to get the UUID for each partition.
$ sudo blkid -p -o full /dev/sdb2
/dev/sdb2: UUID="1a78c1f3-d9d0-4bbc-8dc2-603c2b46f5fc" VERSION="1.0" TYPE="ext4" USAGE="filesystem"
$ sudo blkid -p -o full /dev/sdb3
/dev/sdb3: UUID="7f5a59ae-43c2-4747-a369-6fc01244ee21" VERSION="1.0" TYPE="ext4" USAGE="filesystem"
Now just copy and paste the UUID into /mnt/etc/fstab.
If you are cloning your disk to be used on a different computer then you should also take care of network interfaces. Delete the last line, or the last two, depends on how many network interfaces you have, in /etc/udev/rules.d/70-persistent-net.rules file. The lines should look roughly like this:
# PCI device 0x8086:0x294c (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
I will not go into details here, let’s just say that Ubuntu will remember what names were used for your network interfaces and when you boot into the new system you will end up having eth1 instead of eth0.
Don’t worry, the lines will be back once you reboot your system. After this you can shutdown and disconnect the old drive. Now turn on your computer and boot into a non working system. Have no fear, you will get it fixed in no time.

Step 4 – First boot

Your boot loader will die. Don’t worry it was supposed to, because it doesn’t know what to boot from and where your new disk is. What you see now is a Grub rescue shell. Does it say on the screen that you can use help? Lovely, because you can’t, Grub still didn’t load the help. Now you have to boot your computer manually. Like this:
insmod /boot/grub/linux.mod
linux /vmlinuz root=/dev/sda2 ro
initrd /initrd.img
boot
First you load the Linux module so that you can tell Grub where to find Linux kernel and initial ram disk. Then you can boot. If you have your root partition on /dev/sda2 then you should see your computer rebooting. After you login, open a terminal so that you can fix Grub:
$ sudo update-grub
$ sudo grub-install /dev/sda
$ sudo reboot

Step 5 – Second Reboot & The End

After the reboot everything should be back to normal. If you are again stuck at the Grub rescue prompt, then repeat the above procedure with Grub and rerun update-grub and grub-install. As you can see, cloning disk isn’t not so hard and you don’t need any special tools or software, except your beloved Ubuntu Linux.

※未測試051012
   有關rsync請看我的(051310)rsync 這個同步備份程式 


※120511更新
能由大到小硬碟,取自
http://163.20.34.133/~rex/?p=495 
clonezilla回原映像檔於較小的分割磁區

用一台電腦做好映像檔後,如果要回原地分割區比原本製作映像檔的磁區大,回原過程中並不會出現問題
但是如果比較小,他就是不給還原。
以往遇到這個問題,只好利用開機光碟將分割區重切,這一次我決定試試看他給予的訊息,在命列列中加入-C的參數
於是就上網找相關資料
整理如下
Go to the command prompt and edit ocs-sr (vi /opt/drbl/sbin/ocs-sr) and go to line 490. You should see
PARTCLONE_RESTORE_OPT="$PARTCLONE_RESTORE_OPT_INIT -N"
Just add the -C there
PARTCLONE_RESTORE_OPT="$PARTCLONE_RESTORE_OPT_INIT -C -N"
-*—————————————————————————————————————————
記得設定之前要進行
sudo -s 切換到root
設定好後
ocs-live 在進入還原精靈介面
就可以順利還原了
參考資料
http://www.linuxquestions.org/questions/linux-software-2/running-clonezilla-from-command-line-on-live-cd-751267/
http://clonezilla-sysresccd.hellug.gr/clonezilla.html

※我還未測試 12/05/11


※101911更新
Clonzilla 20110922
Win7以後的雙系統如未先patition再裝Win7到sda3會失敗(Win7開不起來),
請詳看2010年8月的 重裝Win7後還原Grub 2

091509
xp,ubuntu, puppy
用Clonezilla 1.2.2-26
只能由小到大硬碟,在advanced parameters選Expert(再加選-r及-k1)


091709
如未選Expert則會多出一區塊,再用Gparted處理,請參考
http://drbl.nchc.org.tw/clonezilla/的FAQ的→我要怎樣才能把小一點的硬碟複製到大一點的硬碟上?
"
...你可以使gparted LiveCD..."
及http://hc.cyc.edu.tw/exe/clonezilla_live/__6.html→
對拷完成重新開機

沒有留言: