Partimage-HOWTO
Partimage
Version: 0.1
ÀÛ¼ºÀÚ: À̵·Çö(ȯ°ñÅ»ÅÂ) http://blog.easysw.net
1. Partimage¶õ ¶ÆÄƼ¼Ç º°·Î ¹é¾÷ ¹× º¹±¸¸¦ °¡´ÉÇÏ°Ô ÇØ ÁÖ´Â ÇÁ·Î±×·¥ÀÌ´Ù.
ÇÁ·Î±×·¥À» ¼³Ä¡Çؼ »ç¿ëÇصµ µÇ°í, partimage °³¹ßÀÚ°¡ ¸¸µç º¹±¸¿ë Á¾ÇÕ¼±¹° ¼¼Æ®ÀÎ systemrescuecdÀÇ iso ÆÄÀÏÀ» ´Ù¿î¹Þ¾Æ¼ º¹±¸ CD¸¦ ¸¸µå´Â °Íµµ ÁÁ´Ù.
ÀϹÝÀûÀ¸·Î µÎ¹ø° HDD¿¡ ¹é¾÷À» Çϱ⵵ ÇÏÁö¸¸, ³×Æ®¿öÅ©¸¦ ÅëÇؼµµ °¡´ÉÇϹǷΠpartimage ¹é¾÷¼¹ö¸¦ ±¸ÃàÇؼ ¹é¾÷/º¹±¸¸¦ ÇÏ´Â °Íµµ ÁÁ°Ú´Ù.
ÀÌ ÇÏ¿ìÅõ ¹®¼¿¡¼´Â ¼¹ö »óȲÀ» °í·ÁÇÑ ¿¹Á¦³ª ½ºÅ©¸³Æ®¸¦ ´Ù·ç°íÀÚ ÇÑ´Ù.
2. Partimage »ç¿ë ½Ã³ª¸®¿À ¶¸î°¡Áö ¿¹¸¦ µé¾îºÃ´Âµ¥ ´õ ´Ù¾çÇÑ »óȲÀÌ ÀÖÀ» °Å¶ó »ý°¢µÈ´Ù.
3. Partimage Áغñ ¶
wget http://jaist.dl.sourceforge.net/sourceforge/systemrescuecd/systemrescuecd-x86-1.0.2.iso wget http://nchc.dl.sourceforge.net/sourceforge/systemrescuecd/systemrescuecd-x86-1.0.2.iso
4.2. MBR ¹é¾÷ ¶MBRÀ» ¹é¾÷ÇÑ´Ù.
mkdir /mnt/sdb1 mount -t ext3 /dev/sdb1 /mnt/sdb1 mkdir /mnt/sdb1/080329 cd /mnt/sdb1/080329 dd if=/dev/sda of=/mnt/sdb1/080329/080329-sda.mbr count=1 bs=512 4.3. ÆÄƼ¼Ç Á¤º¸ ¹é¾÷ ¶ÆÄƼ¼Ç Á¤º¸¸¦ ¹é¾÷ÇÑ´Ù.
cd /mnt/sdb1/080329/ sfdisk -d /dev/sda > 080329-sda.sf 4.4. ÆÄƼ¼Ç º° ¹é¾÷ ¶* Partition to save/restore sda1 ¼±Åà * Image file to create/use /mnt/sdb1/080329/080329-sda1.partimg.gz * Action to be done: (*) Save partition into a new image file * Compression Level (*) Gzip (.gz; medium speed + small image file) * Options [X] Check partition before saving [X] Enter Description * Image split mode (*) Into files whose size is:...... 2037 MiB * If finished successfully: (*) Wait 5.1. MBR º¹±¸ ¶ÇÊ¿äÇÏ´Ù¸é MBRÀ» º¹±¸ÇÑ´Ù.
mount -t ext3 /dev/sdb1 /mnt/sdb1 dd if=/mnt/sdb1/080329/080329-sda.mbr of=/dev/sda 5.2. ÆÄƼ¼Ç Á¤º¸ º¹±¸ ¶ÆÄƼ¼ÇÀÌ ±úÁ³°Å³ª HDD°¡ ±³Ã¼µÇ¾úÀ» °æ¿ì¿¡´Â ÆÄƼ¼ÇÀ» º¹±¸/»ý¼ºÇÑ´Ù.
mount -t ext3 /dev/sdb1 /mnt/sdb1 sfdisk /dev/sda < /mnt/sdb1/080329/080329-sda.sf¸¸¾à ÆÄƼ¼ÇÀ» º¹±¸Çß´Ù¸é ÀçºÎÆà Çϵµ·Ï ÇÑ´Ù. 5.3. ÆÄƼ¼Ç º° º¹±¸ ¶* Partition to save/restore º¹±¸ÇÒ sda1 ¼±Åà * Image file to create/use /mnt/sdb1/080329/080329-sda1.partimg.gz.000 * Action to be done: (*) Restore partion from an image file * Options º¹±¸ Å×½ºÆ®¸¦ ¿øÇÑ´Ù¸é ½Ã¹°·¹ÀÌ¼Ç ¸ðµå·Î ÇÑ´Ù. [ ] Simulation of the restoration (nothing is written) [ ] Erase free blocks with zero values * If finished successfully: (*) Wait ( ) Halt ( ) Reboot ( ) Quit 6.1. ¹é¾÷ ½ºÅ©¸³Æ® (pisave.sh) ¶¿©·¯°³ÀÇ µð½ºÅ©µé°ú ÆÄƼ¼ÇµéÀ» ÇѲ¨¹ø¿¡ ¹é¾÷ÇÏ´Â ½ºÅ©¸³Æ®ÀÌ´Ù.
º¸Åë ¼¹ö±¸ÃàÀÌ ¿Ï·áµÈ ÈÄ¿¡ Çѹø ÇØ ³õÀ¸¸é ÁÁ´Ù.
BackupDisks¿Í BackupParts, SaveDir1¸¸ ¼öÁ¤Çؼ »ç¿ëÇÏ¸é µÈ´Ù.
# by try365 ## ¼öÁ¤ÇÒ ºÎºÐ #################################### # MBR°ú ÆÄƼ¼Ç ´ýÇÁÇÒ µð½ºÅ©µé (ex: sda sdb...) BackupDisks="sda" # ¹é¾÷ÇÒ ÆÄƼ¼Çµé (ex: sda1 sda2 sda5 sda6 sda7 sda8 sda9 sda10 sda11 sdb1 sdb2 sdb5....) BackupParts="sda1 sda2 sda5" # ¹é¾÷ÇÑ À̹ÌÁö°¡ ÀúÀåµÉ µð·ºÅ丮 (ex: /mnt/sdc1) : ³â¿ùÀÏ·Î µð·ºÅ丮°¡ »ý¼ºµÇ°í ±× ¾È¿¡ ¹é¾÷µÊ SaveDir1="/mnt/sdb1" ## ¼öÁ¤ÀÌ ºÒÇÊ¿äÇÑ ºÎºÐ ############################# DATE=`date +%y%m%d` SaveDir2="${SaveDir1}/$DATE" # -b : batch mode: the GUI won't wait for an user action # -z1 : compress using gz # -o : overwrite the existing image file without confirmation # -d : don't ask any description for the iamge file PM="partimage -b -z1 -o -d " ##################################################### if [ ! -d $SaveDir1 ]; then echo "$SaveDir1 not found" exit else mkdir -p $SaveDir2 chmod 700 $SaveDir2 fi # MBR ¹é¾÷ for i in $BackupDisks; do dd if=/dev/${i} of=$SaveDir2/${DATE}-${i}.mbr count=1 bs=512 done # ÆÄƼ¼Ç Á¤º¸ ´ýÇÁ for i in $BackupDisks; do sfdisk -d /dev/${i} > $SaveDir2/${DATE}-${i}.sf done # ÆÄƼ¼Ç ¹é¾÷ for i in $BackupParts ; do echo "$PM save /dev/${i} ${SaveDir2}/$DATE-${i}.partimg.gz" $PM save /dev/${i} ${SaveDir2}/$DATE-${i}.partimg.gz done # ¹é¾÷µÈ À̹ÌÁö Á¤º¸ º¸±â for i in $BackupParts ; do echo "partimage imginfo ${SaveDir2}/$DATE-${i}.partimg.gz.000" done # vi: set ts=2 sts=2 sw=2 ¹é¾÷ È®ÀÎ
[root@localhost root]# ls -l /mnt/sdb1/080329/ -rw-r--r-- 1 root root 512 3¿ù 29 17:54 080329-sda.mbr -rw-r--r-- 1 root root 514 3¿ù 29 17:54 080329-sda.sf -rw------- 1 root root 36631185 3¿ù 29 17:54 080329-sda1.partimg.gz.000 6.2. º¹±¸ ½ºÅ©¸³Æ® (pirestore.sh) ¶Àå¾Öº¹±¸½Ã ¿©·¯°³ÀÇ ÆÄƼ¼ÇÀ» ºü¸¥ ½Ã°£³»¿¡ º¹±¸Çϱâ À§ÇÑ ½ºÅ©¸³Æ®·Î¼ À̹ÌÁö ¹é¾÷½Ã ³¯Â¥¸¦ ÂüÁ¶ÇÏ¿© ¹Ì¸® º¹±¸ ½ºÅ©¸³Æ®¸¦ ¼¼ÆÃÇØ µÎ¸é Àå¾Ö½Ã µµ¿òÀÌ µÉ °Å °°´Ù.
¸¸¾à sfdisk¸¦ »ç¿ëÇÏ¿© ÆÄƼ¼ÇÀ» º¹±¸Çß´Ù¸é ÀçºÎÆà Çϵµ·Ï ÇÑ´Ù.
# by try365 ## ¼öÁ¤ÇÒ ºÎºÐ #################################### # MBR°ú ÆÄƼ¼ÇÀ» º¹±¸ÇÒ µð½ºÅ©µé (ex: sda sdb...) RestoreDisks="sda" # º¹±¸ÇÒ ÆÄƼ¼Çµé (ex: sda1 sda2 sda5 sda6 sda7 sda8 sda9 sda10 sda11 sdb1..) RestoreParts="sda1" # ¹é¾÷µÈ ³¯Â¥ (µð·ºÅ丮 À̸§°ú ÆÄÀϸíÀÇ ±¸ºÐÀÚ·Î ¾²ÀÓ) Date="080329" # ¹é¾÷µÈ À̹ÌÁö°¡ ÀúÀåµÇ¾î ÀÖ´Â µð·ºÅ丮 ImageDir="/mnt/sdb1/$Date" # PartimageÀÇ º¹±¸ ¿É¼Ç (-S : simulation of restoration mode) # º¹±¸¸¦ ½Ã¹Ä·¹ÀÌ¼Ç ÇÏ°íÀÚ ÇÑ´Ù¸é -S ¿É¼ÇÀ» Ãß°¡ÇÏ¸é µÈ´Ù. PM="partimage -b" # MBR º¹±¸ ¿©ºÎ [0|1] RestoreMBR="0" # ÆÄƼ¼Ç º¹±¸ ¿©ºÎ [0|1] RestoreSFDISK="0" ##################################################### if [ ! -d $ImageDir ]; then echo "$ImageDir not found" exit fi # MBR º¹±¸ (ex: dd if=/mnt/sdb1/080329/080329-sda.mbr of=/dev/sda) if [ "x${RestoreMBR}" = "x1" ]; then for i in $RestoreDisks; do echo "dd if=$I{mageDir}/${Date}-${i}.mbr of=/dev/${i}" dd if=${ImageDir}/${Date}-${i}.mbr of=/dev/${i} sleep 1 done fi # ÆÄƼ¼Ç Å×ÀÌºí º¹±¸ (ex: sfdisk /dev/sda < /mnt/sdb1/080329/080329-sda.sf) if [ "x${RestoreSFDISK}" = "x1" ]; then for i in $RestoreDisks; do echo "sfdisk /dev/${i} < ${ImageDir}/${Date}-${i}.sf" sfdisk /dev/${i} < ${ImageDir}/${Date}-${i}.sf sleep 1 done echo -n "If you finished an extended partitions recovery, " echo "you will have to reboot your computer." echo -n "reboot ? (y/n) : " read yesorno if [ "x$yesorno" = "xy" ]; then echo "Do the unmounting and rebooting directly." exit else echo "continue" fi fi # Partimage·Î ÆÄƼ¼Ç º¹±¸ for i in $RestoreParts ; do if [ -f ${ImageDir}/$Date-${i}.partimg.gz.000 ]; then #partimage -b -S restore /dev/sda1 /PATH/080329-sda1.partimg.gz.000 echo "$PM restore /dev/${i} ${ImageDir}/$Date-${i}.partimg.gz.000" $PM restore /dev/${i} ${ImageDir}/$Date-${i}.partimg.gz.000 else echo "error : ${ImageDir}/$Date-${i}.partimg.gz.000 not found" fi done # vi: set ts=2 sts=2 sw=2 |
Money will say more in one moment than the most eloquent lover can in years. |