Automated USB thumb drive using Custom-ocs
 



If you are using a USB thumb drive and all you want to do is restore your image on "sda2" back to "sda1" automatically... This is how you do it


NTFS = sda1

NTFS = sda2

 
 
#1. Your custom-ocs script should read like this.


#!/bin/bash

# Author: Steven Shiau <steven _at_ stevenshiau org>

# License: GPL

# Ref: http://sourceforge.net/forum/forum.php?thread_id=1759263&forum_id=394751

# In this example, it will allow your user to use clonezilla live to choose

# (1) backup the image of /dev/hda1 (or /dev/sda1) to /dev/hda5 (or /dev/sda5)

# (2) restore image in /dev/hda5 (or /dev/sda5) to /dev/hda1 (or /dev/sda1)

# Here we assume the filesystems are ntfs.


# When this script is ready, you can run

# /opt/drbl/sbin/ocs-iso -g en -k NONE -s -m ./custom-ocs

# to create the iso file for CD/DVD. or

# /opt/drbl/sbin/ocs-live-dev -g en -k NONE -s -c -m ./custom-ocs

# to create the zip file for USB flash drive.

#

# IF NEEDED TO MOUNT FOR NTFS USE "ntfs-3g" instead of "mount"


# Begin of the scripts:

# Load DRBL setting and functions

if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then

echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!"

exit 1

fi

. /opt/drbl/sbin/drbl-conf-functions

. /opt/drbl/sbin/ocs-functions

# load the setting for clonezilla live.

[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# Load language files. For English, use "en". For Chinese, use "tw.UTF-8"

ask_and_load_lang_set en_US.UTF-8
 
mkdir -p /home/partimag/ 
ntfs-3g /dev/sda2 /home/partimag/ 
 
opt/drbl/sbin/ocs-sr -b -g auto -e1 auto -e2 -c -j2 -k -p reboot restoreparts "Your image file here" "sda1" 
 

#2. Insert this custom-ocs script file now in your "LIVE" folder located in your USB drive.  
 

#3. Now you need to edit your "syslinux.cfg" file that is located in your "SYSLINUX" folder. 
 
Note: The syslinux.cfg file looks very similar to a GRUB menu and you will edit the menu like this. Just edit the first option in the menu with the resolution of 1024x768... 
 
kernel /live/vmlinuz1 
append initrd=/live/initrd1.img boot=live union=aufs noprompt noprompt ocs_live_run="/live/image/live/custom-ocs" ocs_live_extra_param="" ocs_live_keymap="NONE" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 ip=frommedia nolocales 
 
#4. Reboot the computer and boot to your USB and select your first menu option...  
 
That is it !!!