Xu Xiaodong avatar Xu Xiaodong committed ee329af

add part* scripts

Comments (0)

Files changed (9)

 用途:
 =====
 
-利用 ucloner 备份/还原 ubuntu 系统.
+  利用 ucloner 备份/还原 ubuntu 系统.
 
 用法:
 =====
 
-双击 run_bak.sh 或 run_res.sh 执行即可.
+  * run_bak.sh 备份
+  * run_reshdd.sh 针对传统硬盘还原
+  * run_resssd.sh 针对固态硬盘还原
+  * run_resufd.sh 针对优盘进行还原
+#!/bin/sh
+#
+# description:  针对 320G 硬盘进行自动分区
+#               / 10G, /tmp 5G, /var 25G, /home
+# author:       Xu Xiaodong <xxdlhy@gmail.com>
+# modified:     2011 Jul 24
+#
+
+CMD=fdisk
+DEVICE=/dev/sda
+
+sudo $CMD $DEVICE <<'EOF'
+n
+p
+1
+
++10000M
+n
+p
+2
+
++5000M
+n
+p
+3
+
++25000M
+n
+p
+
+
+
+a
+1
+w
+EOF
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh
+#!/bin/sh
+#
+# description:  针对 30G 固态硬盘进行自动分区
+#               / 5G, /tmp 1G, /var 4G, /home
+# author:       Xu Xiaodong <xxdlhy@gmail.com>
+# modified:     2011 Jul 24
+#
+
+CMD=fdisk
+DEVICE=/dev/sda
+
+sudo $CMD $DEVICE <<'EOF'
+n
+p
+1
+
++5000M
+n
+p
+2
+
++1000M
+n
+p
+3
+
++4000M
+n
+p
+
+
+
+a
+1
+w
+EOF
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh
 #
 # description:  利用 ucloner 还原 ubox 系统
 # author:       Xu Xiaodong <xxdlhy@gmail.com>
-# modified:     2011 Jun 14
+# modified:     2011 Jul 24
 #
 
-BASE_PATH=$HOME/ucloner
-PROG=$BASE_PATH/program
-IMAGE=$BASE_PATH/ubox.squashfs
+BASE=$HOME/ucloner
+PROG=$BASE/program
+SH=$HOME/resbox
+IMAGE=$BASE/ubox.squashfs
+NAME=$(date +%Y-%m-%d)
 
 cd $PROG
 
 case "$1" in
   backup)
-    sudo ./ucloner_cmd.py mode=backup backup_to=$BASE_PATH/$(date +%Y-%m-%d).squashfs
+    sudo ./ucloner_cmd.py mode=backup backup_to=$BASE/"$NAME".squashfs
     ;;
   restore)
-    sudo ./ucloner_cmd.py mode=restore restore_from=$IMAGE /=/dev/sda1 /_fs=ext4 grubdev=/dev/sda
+    $SH/part_"$2".sh >/dev/null
+    sudo ./ucloner_cmd.py mode=restore restore_from=$IMAGE /=/dev/sda1 /_fs=ext4 /tmp=/dev/sda2 /tmp_fs=ext4 /var=/dev/sda3 /var_fs=ext4 /home=/dev/sda4 /home_fs=ext4 grubdev=/dev/sda
+    ;;
+  udisk)
+    sudo ./ucloner_cmd.py mode=restore restore_from=$IMAGE /=/dev/sdb1 /_fs=ext4 grubdev=/dev/sdb
     ;;
   *)
-    echo "$0 <backup | restore>"
-    exit
+    echo "$0 backup | restore <hdd | ssd> | udisk"
+    exit 0
     ;;
 esac
 
 if [ $? -eq 0 ]; then
-  echo '已成功备份/还原系统. [OK]'
+  echo "系统安装成功, 将在 10 秒后自动重启."
+  sleep 10s
+  sudo reboot
+else
+  echo "系统安装失败."
 fi
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh
 #!/bin/sh
 #
-# description:  利用 ucloner 还原 ubox 系统
+# description:  利用 ucloner 备份 ubox 系统
 # author:       Xu Xiaodong <xxdlhy@gmail.com>
-# modified:     2011 Jun 14
+# modified:     2011 Jul 24
 #
 
+PROG=$HOME/resbox
+
+cd $PROG
 ./resbox backup
-sleep 1h
+sleep 30m
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh

run_res.sh

-#!/bin/sh
-#
-# description:  利用 ucloner 还原 ubox 系统
-# author:       Xu Xiaodong <xxdlhy@gmail.com>
-# modified:     2011 Jun 14
-#
-
-./resbox restore
-sleep 1h
+#!/bin/sh
+#
+# description:  利用 ucloner 还原 ubox 系统 (传统硬盘)
+# author:       Xu Xiaodong <xxdlhy@gmail.com>
+# modified:     2011 Jul 24
+#
+
+PROG=$HOME/resbox
+
+cd $PROG
+./resbox restore hdd
+sleep 30m
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh
+#!/bin/sh
+#
+# description:  利用 ucloner 还原 ubox 系统 (固态硬盘)
+# author:       Xu Xiaodong <xxdlhy@gmail.com>
+# modified:     2011 Jul 24
+#
+
+PROG=$HOME/resbox
+
+cd $PROG
+./resbox restore ssd
+sleep 30m
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh
+#!/bin/sh
+#
+# description:  利用 ucloner 还原 ubox 系统 (优盘)
+# author:       Xu Xiaodong <xxdlhy@gmail.com>
+# modified:     2011 Jul 24
+#
+
+PROG=$HOME/resbox
+
+cd $PROG
+./resbox udisk
+sleep 30m
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=sh
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.