Sunday, October 28, 2012

Customizing clonezilla iso for creating automatic backup image


This is part-1 of "Nightly clonezilla backup imaging for ubuntu server".

This tutorial explains how to create customized clonezilla iso image.


Clonezilla is an open source disk cloning tool, I assume you already know enough about clonezilla.

If you startup your system with this result iso file, you will get an compressed harddisk backup image in the target partition you want.
This can be used as a snapshot, so you can restore your server if there is any problem.

Unlike the other method, this does not require any key input , when everything is finished, it will be rebooted automatically.


To make this, you will need,

 - Clonezilla iso image (http://clonezilla.org/downloads.php)
 Stable releases 1.2.12-67 is used in this tutorial

 - ISO Master (http://www.littlesvr.ca/isomaster/)
 This is for edit ISO file. you can install in on Ubuntu Software Center.

 - Two files : isolinux.cfg, mystartup.
 will be created in this tutorial

 1. Prepare clonezilla live ISO file.

http://clonezilla.org/downloads.php


 2. Install ISO master.

 Find and click install in Ubuntu Software Center.
 or just type "sudo apt-get install isomaster" in terminal.

 3. Define source and target partition.

yananet@server:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1        35G  6.0G   27G  19% /
udev           1000M  4.0K 1000M   1% /dev
tmpfs           403M  1.1M  402M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none           1007M  332K 1007M   1% /run/shm
/dev/sda1       459G  367G   69G  85% /media/MEDIA1
/dev/sdb3       193G   79G  105G  44% /media/EXT1

My home server has 3 partitions.
Ubuntu server 12.04, lubuntu-desktop, all server daemons are installed in /dev/sdb1.
What I want to do is to make clone image of this partition, and save this on /dev/sda1.

  • src_part=sdb1
  • tgt_part=sda1

The actual size of image file is about 3~4G.
The backup image will be stored in /clone of sda1

 4. Create mystartup script.

After clonezilla is started, this script will be excuted.
Most important part of this script is following.

ocs-sr -q2 -j2 -z1p -p command saveparts "$_filename" "$src_part"

ocs-sr is one of Clonezilla's command which enables you to save or restore a partition or whole disk.

All of option is explained here.


Make sure that you need to modify your own src_part and tgt_part.
This is based on /opt/drb1/samples/custom-ocs in clonezilla live.

 #!/bin/bash  
 # Author: Steven Shiau <steven _at_ nchc org tw>  
 # License: GPL  
 # Ref: http://sourceforge.net/forum/forum.php?thread_id=1759263&forum_id=394751  
 # followings are essential for initial startup  
 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"  
 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions  
 . $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf  
 . $DRBL_SCRIPT_PATH/sbin/ocs-functions  
 [ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf  
 ask_and_load_lang_set en_US.UTF-8  
 # From here, you can write your own scripts.  
 # functions  
 decide_sda_or_hda() {  
 # define your source and target parition  
  src_part=sdb1  
  tgt_part=sda1  
 }  
 action_backup() {  
  mkdir -p $ocsroot  
  part_fs="$(LANG=C ocs-get-part-info /dev/$tgt_part filesystem)"  
  case "$part_fs" in  
   ntfs) ntfs-3g /dev/$tgt_part $ocsroot   
      RETV=$? ;;  
   *) mount /dev/$tgt_part $ocsroot  
     RETV=$? ;;  
  esac  
  if [ "$RETV" -eq 0 ]; then  
   # define target directory name  
   _now=$(date +"%m_%d_%Y")  
   _filename="/clone/img_$_now"  
   # If you want to run it in batch mode, add option "-b" in the ocs-sr command  
   # For more options about ocs-sr, run "ocs-sr -h"  
   # or http://allthatnetwork.blogspot.jp/2012/10/clonezilla-ocs-sr-options.html  
   ocs-sr -q2 -j2 -z1p -p command saveparts "$_filename" "$src_part"  
  else  
   [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE  
   echo "Fail to mount /dev/$tgt_part as $ocsroot!"  
   echo "Program terminated!"  
   [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL  
  fi  
  umount $ocsroot &>/dev/null  
 }  
 ##################  
 ###### MAIN ######  
 ##################  
 # Find the device and partition  
 decide_sda_or_hda  
 # Start backup  
 action_backup  
 # Force restart (no key input required for restart)  
 reboot -f  


 5. Extract and modify isolinux.cfg file

the syntax of isolinux.cfg is very simular with grup configration.
This setup creates new menu entry in clonezilla live, and runs mystartup script you just created before.

First, extract isolinux.cfg file from clonezilla live iso file.

ISO master can do this or Ubuntu Archive Manager also can do this easily.

isolinux.cfg is under /isolinux.

Second, open it with a text editor, find following block.
This is the default boot option of clonezilla live.


 label Clonezilla live  
  MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (Default settings, VGA 800x600)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 ip=frommedia nosplash  
  TEXT HELP  
  * Clonezilla live version: 1.2.12-67-i686-pae. (C) 2003-2012, NCHC, Taiwan  
  * Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY  
  ENDTEXT  


Comment out "MENU DEFAULT".

 MENU DEFAULT  

Finally, add your new boot option as following.

 label Clonezilla customize  
  MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla customize (Default settings, VGA 800x600)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="/live/image/live/mystartup" ocs_live_extra_param="" ocs_live_keymap="NONE" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=788 ip=frommedia nosplash  
  TEXT HELP  
  * Clonezilla live version: 1.2.12-67-i686-pae. (C) 2003-2012, NCHC, Taiwan  
  * Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY  
  ENDTEXT  


Find full isolinux.cfg in here.
If you correctly create this file, clonezilla will show you following menu at the begin of boot up process.



6. Create new clonezilla ISO image

Open clonezilla ISO file with ISO master.

Copy myscript to /live
Delete the original and copy isolinux.cfg to /isolinux
Save ISO file as new name.



That's it!

You may use this ISO file to make CD or bootable USB or whatever you want.
This ISO file will make snapshot of your server automatically.


In my next post, I will explain how to backup your server in specific night time by using grup2 and crontab.


Saturday, October 27, 2012

Modified isolinux.cfg for customized clonezilla live

/isolinux/isolinux.cfg

 # Created by generate-pxe-menu! Do NOT edit unless you know what you are doing!   
 # Keep those comment "MENU DEFAULT" and "MENU HIDE"! Do NOT remove them.  
 # Note!!! If "serial" directive exists, it must be the first directive  
 default vesamenu.c32  
 timeout 300  
 prompt 0  
 noescape 1  
 MENU MARGIN 5  
  MENU BACKGROUND ocswp.png  
 # Set the color for unselected menu item and timout message  
  MENU COLOR UNSEL 7;32;41 #c0000090 #00000000  
  MENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000  
  MENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000  
  MENU COLOR HELP 7;32;41 #c0000090 #00000000  
 # MENU MASTER PASSWD  
 say **********************************************************************  
 say Clonezilla, the OpenSource Clone System.  
 say NCHC Free Software Labs, Taiwan.  
 say clonezilla.org, clonezilla.nchc.org.tw  
 say THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!   
 say **********************************************************************  
 # Allow client to edit the parameters  
 ALLOWOPTIONS 1  
 # simple menu title  
 MENU TITLE clonezilla.org, clonezilla.nchc.org.tw  
 label Clonezilla customize  
  MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla customize (Default settings, VGA 800x600)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="/live/image/live/mystartup" ocs_live_extra_param="" ocs_live_keymap="NONE" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=788 ip=frommedia nosplash  
  TEXT HELP  
  * Clonezilla live version: 1.2.12-67-i686-pae. (C) 2003-2012, NCHC, Taiwan  
  * Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY  
  ENDTEXT  
 label Clonezilla live  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (Default settings, VGA 800x600)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 ip=frommedia nosplash  
  TEXT HELP  
  * Clonezilla live version: 1.2.12-67-i686-pae. (C) 2003-2012, NCHC, Taiwan  
  * Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY  
  ENDTEXT  
 MENU BEGIN Other modes of Clonezilla live  
 label Clonezilla live 1024x768  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (Default settings, VGA 1024x768)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=791 ip=frommedia nosplash  
  TEXT HELP  
  VGA mode 1024x768. OK for most of VGA cards.  
  ENDTEXT  
 label Clonezilla live 640x480  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (Default settings, VGA 640x480)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=785 ip=frommedia nosplash  
  TEXT HELP  
  VGA mode 640x480. OK for most of VGA cards.  
  ENDTEXT  
 label Clonezilla live (To RAM)  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (To RAM. Boot media can be removed later)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" noprompt vga=788 toram=filesystem.squashfs ip=frommedia nosplash  
  TEXT HELP  
  All the programs will be copied to RAM, so you can  
  remove boot media (CD or USB flash drive) later  
  ENDTEXT  
 label Clonezilla live without framebuffer  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (Safe graphic settings, vga=normal)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" ip=frommedia nomodeset vga=normal nosplash  
  TEXT HELP  
  Disable console frame buffer support  
  ENDTEXT  
 label Clonezilla live failsafe mode  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Clonezilla live (Failsafe mode)  
  # MENU PASSWD  
  kernel /live/vmlinuz  
  append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip=frommedia nomodeset vga=normal nosplash  
  TEXT HELP  
  acpi=off irqpoll noapic noapm nodma nomce nolapic   
  nosmp nomodeset vga=normal nosplash  
  ENDTEXT  
 MENU END  
 label local  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Local operating system in harddrive (if available)  
  # MENU PASSWD  
  # 2 method to boot local device:  
  # (1) For localboot 0, it is decided by boot order in BIOS, so uncomment the follow 1 line if you want this method:  
  # localboot 0  
  # (2) For chain.c32, you can assign the boot device.  
  # Ref: extlinux.doc from syslinux  
  # Syntax: APPEND [hd|fd]<number> [<partition>]  
  # [<partition>] is optional.  
  # Ex:  
  # Second partition (2) on the first hard disk (hd0);  
  # Linux would *typically* call this /dev/hda2 or /dev/sda2, then it's "APPEND hd0 2"  
  #  
  kernel chain.c32  
  append hd0  
  TEXT HELP  
  Boot local OS from first hard disk if it's available  
  ENDTEXT  
 MENU BEGIN Memtest & FreeDOS  
 # Note! *.bin is specially purpose for syslinux,   
 # Do NOT use memtest.bin, use memtest instead of memtest.bin  
 label memtest  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Memory test using Memtest86+  
  # MENU PASSWD  
  kernel /live/memtest  
  TEXT HELP  
  Run memory test using Memtest86+  
  ENDTEXT  
 label FreeDOS  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL FreeDOS  
  # MENU PASSWD  
  kernel memdisk  
  append initrd=/live/freedos.img  
  TEXT HELP  
  Run FreeDOS  
  ENDTEXT  
 MENU END  
 label iPXE  
  # MENU DEFAULT  
  # MENU HIDE  
  MENU LABEL Network boot via iPXE  
  # MENU PASSWD  
  kernel /live/ipxe.lkn  
  TEXT HELP  
  Run iPXE to enable network (PXE) boot  
  ENDTEXT  
 MENU END  

Friday, October 26, 2012

Clonezilla ocs-sr options

 Setting the TERM as linux  
 /opt/drbl/sbin/ocs-sr: -h: invalid option  
 Usage:  
 To save or restore image  
 ocs-sr [OPTION] {savedisk|saveparts|restoredisk|restoreparts} IMAGE_NAME DEVICE  
  Options for saving:  
  -fsck-src-part, --fsck-src-part Run fsck interactively on the source file system before saving it.  
  -fsck-src-part-y, --fsck-src-part-y Run fsck automatically on the source file system before saving it. This option will always attempt to fix any detected filesystem corruption automatically. //NOTE// Use this option in caution.  
  -gm, --gen-md5sum  Generate the MD5 checksum for the image. Later you can use -cm|--check-md5sum option to check the image when restoring the image. Note! It might take a lot of time to generate if the image size is large.  
  -gs, --gen-sha1sum Generate the SHA1 checksum for the image. Later you can use -cs|--check-sha1sum option to check the image when restoring the image. Note! It might take a lot of time to generate if the image size is large.  
  -j2, --clone-hidden-data Use dd to clone the image of the data between MBR (1st sector, i.e. 512 bytes) and 1st partition, which might be useful for some recovery tool.  
  -ntfs-ok, --ntfs-ok   Assume the NTFS integrity is OK, do NOT check again (for ntfsclone only)  
  -rm-win-swap-hib, --rm-win-swap-hib Try to remove the MS windows swap file in the source partition.  
  -q, --use-ntfsclone   If the partition to be saved is NTFS, use program ntfsclone instead of partimage (i.e. Priority: ntfsclone > partimage > dd)  
  -q1, --force-to-use-dd  Force to use dd to save partition(s) (inefficient method, very slow, but works for all the file system).  
  -q2, --use-partclone   Use partclone to save partition(s) (i.e. partclone > partimage > dd).  
  -rescue, --rescue Turn on rescue mode, i.e. try to skip bad sectors.  
  -sc, --skip-check-restorable By default Clonezilla will check the image if restorable after it is created. This option allows you to skip that.  
  -z0, --no-compress    Don't compress when saving: very fast but very big image file (NOT compatible with multicast restoring!!!)  
  -z1, --gzip-compress   Compress using gzip when saving: fast and small image file (default)  
  -z1p, --smp-gzip-compress Compress using parallel gzip program (pigz) when saving: fast and small image file, good for multi-core or multi-CPU machine  
  -z2, --bz2-compress   Compress using bzip2 when saving: slow but smallest image file  
  -z2p, --smp-bzip2-compress Compress using parallel bzip2 program (pbzip2) when saving: faster and smallest image file, good for multi-core or multi-CPU machine  
  -z3, --lzo-compress   Compress using lzop when saving: similar to the size by gzip, but faster than gzip.  
  -z4, --lzma-compress   Compress using lzma when saving: slow but smallest image file, faster decompression than bzip2.  
  -z5, --xz-compress    Compress using xz when saving: slow but smallest image file, faster decompression than bzip2.  
  -z5p, --smp-xz-compress Compress using parallel xz when saving: slow but smallest image file, faster decompression than bzip2.  
  -z6, --lzip-compress   Compress using lzip when saving: slow but smallest image file, faster decompression than bzip2.  
  -z6p, --smp-lzip-compress Compress using parallel lzip when saving: slow but smallest image file, faster decompression than bzip2.  
  -z7, --lrzip-compress   Compress using lrzip when saving.  
  -i, --image-size SIZE  Set the split image file volume size SIZE (MB). When ocs-sr is run with -x, the default SIZE is set as 2000, if without -x, we will not split it.  
  Three words are reserved for IMAGE_NAME, "ask_user" is used to let user to input a name when saving an image. "autoname" is used to automatically generate the image name based on network card MAC address and time. "autohostname" is used to automatically generate the image name based on hostname.  
  A word is reserved for DEVICE, "ask_user" could be used to let user to select the source device when saving an image.  
  Options for restoring:  
  -g, --grub-install GRUB_PARTITION   Install grub in the MBR of the disk containing partition GRUB_PARTITION with root grub directory in the same GRUB_PARTITION when restoration finishs, GRUB_PARTITION can be one of "/dev/hda1", "/dev/hda2"... or "auto" ("auto" will let clonezilla detect the grub root partition automatically). If "auto" is assigned, it will work if grub partition and root partition are not in the same partition.  
  -r, --resize-partition  Resize the partition when restoration finishes, this will try to fix the problem when small partition image is restored to larger partition. Warning!!! Use this carefully... Backup your data first  
  -k, --no-fdisk, --no-create-partition  Do NOT create partition in target harddisk. If this option is set, you must make sure there is an existing partition table in the current restored harddisk. Default is to create the partition table.  
  -icrc, --icrc      Skip Partclone CRC checking.  
  -irhr, --irhr      Skip removing the Linux udev hardware records on the restored GNU/Linux.  
  -ius, --ius       Skip updating syslinux-related files on the restored GNU/Linux.  
  -icds, --ignore-chk-dsk-size-pt Skip checking destination disk size before creating the partition table on it. By default it will be checked and if the size is smaller than the source disk, quit.  
  -k1,           Create partition table in the target disk proportionally.  
  -k2,           Enter command line prompt to create partition table manually before restoring image.  
  -t, --no-restore-mbr Do NOT restore the MBR (Mater Boot Record) when restoring image. If this option is set, you must make sure there is an existing MBR in the current restored harddisk. Default is Yes  
  -u, --select-img-in-client Input the image name in clients  
  -e, --load-geometry Force to use the saved CHS (cylinders, heads, sectors) when using sfdisk  
  -e1, --change-geometry NTFS-BOOT-PARTITION Force to change the CHS (cylinders, heads, sectors) value of NTFS boot partitoin after image is restored. NTFS-BOOT-PARTITION can be one of "/dev/hda1", "/dev/hda2"... or "auto" ("auto" will let clonezilla detect the NTFS boot partition automatically)  
  -e2, --load-geometry-from-edd Force to use the CHS (cylinders, heads, sectors) from EDD (Enhanced Disk Device) when creating partition table by sfdisk  
  -y, -y0, --always-restore, --always-restore-default-local Let Clonezilla server as restore server, i.e. client will always has restore mode to choose (However default mode in PXE menu is local boot)  
  -y1, --always-restore-default-clone Let Clonezilla server as restore server, i.e. client will always has restore mode to choose (The default mode in PXE menu is clone, so if client boots, it will enter clone always, i.e. clone forever)  
  -j, --create-part-by-sfdisk Use sfdisk to create partition table instead of using dd to dump the partition table from saved image (This is default)  
  -j0, --create-part-by-dd Use dd to dump the partition table from saved image instead of sfdisk. ///Note/// This does NOT work when logical drives exist.  
  -j1, --dump-mbr-in-the-end Use dd to dump the MBR (total 512 bytes, i.e. 446 bytes (executable code area) + 64 bytes (table of primary partitions) + 2 bytes (MBR signature; # 0xAA55) = 512 bytes) after disk image was restored. This is an insurance for some hard drive has different numbers of cylinder, head and sector between image was saved and restored.  
  -j2, --clone-hidden-data Use dd to clone the image of the data between MBR (1st sector, i.e. 512 bytes) and 1st partition, which might be useful for some recovery tool.  
  -hn0 PREFIX   Change the hostname of M$ Windows based on the combination of hostname prefix and IP address, i.e. PREFIX-IP  
  -hn1 PREFIX   Change the hostname of M$ Windows based on the combination of hostname prefix and NIC MAC address, i.e. PREFIX-MAC  
  --max-time-to-wait TIME  When not enough clients have connected (but at least one), start anyways when TIME seconds since first client connection have pased. This option is used with --clients-to-wait  
  -cm, --check-md5sum  Check the MD5 checksum for the image. To use this option, you must enable -gm|--gen-md5sum option when the image is saved. Note! It might take a lot of time to check if the image size is large.  
  -cs, --check-sha1sum Check the SHA1 checksum for the image. To use this option, you must enable -gs|--gen-sha1sum option when the image is saved. Note! It might take a lot of time to check if the image size is large.  
  --mcast-port  NO   Assign the udp port number for multicast restore. This is used by clonezilla server. Normally it's not necessary to manually assign this option.  
  A word is reserved for IMAGE_NAME, "ask_user" is used to let user to input a name when saving an image.  
  A word is reserved for DEVICE, "ask_user" could be used to let user to select the source device when saving an image.  
  General options:  
 -l, --language INDEX Set the language to be shown by index number:  
     [0|en_US.UTF-8]: English,  
     [1|zh_TW.BIG5]: Traditional Chinese (Big5) - Taiwan,  
     [2|zh_TW.UTF-8]: Traditional Chinese (UTF-8, Unicode) - Taiwan  
     [a|ask]: Prompt to ask the language index  
  -b, -batch, --batch   (DANGEROUS!) Run program in batch mode, i.e. without any prompt or wait for pressing enter key. //NOTE// You have to use '-batch' instead of '-b' when you want to use it in the boot parameters. Otherwise the program init on system will honor '-b', too.  
  -c, --confirm      Wait for confirmation before saving or restoring  
  -d, --debug-mode     Enter command mode to debug before saving/restoring  
  --debug=LEVEL      Output the partimage debug log in directory /var/log/ with debug LEVEL (0,1,2... default=0)  
  -m, --module MODULE   Force to load kernel module MODULE, this is useful when some SCSI device is not detected. NOTE! Use only one module, more than one may cause parsing problem.  
  -o0, --run-prerun-dir  Run the script in the direcoty /opt/drbl/share/ocs/postrun before clone is started. The command will be run before MBR is created or saved.  
  -o1, -o, --run-postrun-dir  Run the script in the direcoty /opt/drbl/share/ocs/postrun when clone is finished. The command will be run before that assigned in -p or --postaction.  
  -w, --wait-time TIME   Wait for TIME secs before saving/restoring  
  --nogui         Do not show GUI of partimage, use text only  
  -a, --no-force-dma-on  Do not force to turn on HD DMA  
  -mp, --mount-point MOUNT_POINT Use NFS to mount MOUNT_POINT as directory ocsroot (ocsroot is assigned in drbl.conf)  
  -or, --ocsroot DIR    Specify DIR (absolute path) as directory ocsroot (i.e. overwrite the ocsroot assigned in drbl.conf)  
  -p, --postaction [choose|poweroff|reboot|command|CMD]   When save/restoration finishs, choose action in the client, poweroff, reboot (default), in command prompt or run CMD  
  -ns, --ntfs-progress-in-image-dir Save the ntfsclone progress tmp file in the image dir so that if cloning is in DRBL client, the progress can be check in the server (Default in to be put in local /tmp/, which is local tmpfs).  
  -um, --user-mode [beginner|expert]   Specify the mode to use. If not specified, default mode is for a beginner.  
  -v, --verbose      Prints verbose information  
  -d0, --dialog     Use dialog  
  -d1, --Xdialog    Use Xdialog  
  -d2, --whiptail    Use whiptail  
  -d3, --gdialog    Use gdialog  
  -d4, --kdialog    Use kdialog  
  -x, --interactive   Interactive mode to save or restore.  
 Example:  
   To save or restore image in client (Only that DRBL client will join, and its local partitions is NOT mounted). NOTE!!! You should run the command in DRBL client or you have to make sure the target device is NOT busy!.  
   To save all the data in local first IDE harddrive 'hda' as image 'IMAGE1', use ntfsclone instead of partimage, and lzop compression (NOTE!!! You should run the command in DRBL client or make sure hda is NOT busy/mounted!):  
   ocs-sr --use-ntfsclone -z3 savedisk IMAGE1 hda  
   To save the data in first and second partitions in local first IDE harddrive 'hda' as image 'IMAGE2', use ntfsclone instead of partimage, and lzop compression (NOTE!!! You should run the command in DRBL client, or make sure hda is NOT busy/mounted!):  
   ocs-sr --use-ntfsclone -z3 saveparts IMAGE2 "hda1 hda2"  
   To restore image IMAGE1 to local hda. grub-install will be run after cloning (image IMAGE1 is already in DRBL server. NOTE!!! You should run the command in DRBL client or make sure hda is NOT busy/mounted!):  
   ocs-sr -g auto restoredisk IMAGE1 hda  
   To restore image first and second partitions from IMAGE2 to local hda1 and hda2. grub-install will be run after cloning (image IMAGE2 is already in DRBL server. NOTE!!! You should run the command in DRBL client or make sure hda is NOT busy/mounted!):  
   ocs-sr -g auto restoreparts IMAGE2 "hda1 hda2"  
   To save disk(s)/partitition(s) as an image or restore an image to disk(s)/partitition(s) interactively, use:  
   ocs-sr -x  

Sunday, August 5, 2012

Fixing Zentyal 2.3 NO_PUBKEY error in apt-get update

Zentyal-2.3 requires following repository, and automatically adds this on your source.list.

 #/etc/apt/source.list.d/zentyal-archive.list
deb http://archive.zentyal.org/zentyal 2.3 main extra

This will automatically be added after you install "zentyal-core" package, or you add the repository using "add-apt-repository".

You will see following error in apt-get update.

W: GPG error: http://archive.zentyal.org 2.3 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY BE3CB0952C31765E

You can not find any public key for this.

You can fix this by one of followings

- comment out zentyal's repository in source.list (/etc/apt/source.list.d/zentyal-archive.list)

- adding key of "archive.zentyal.org" with following commend if you trust them.


wget http://keys.zentyal.org/zentyal-2.3-archive.asc

sudo apt-key add zentyal-2.3-archive.asc && sudo apt-get update


Thursday, June 21, 2012

Open 2 Ports in Ubuntu Apache Web Server

Basically, it is impossible to open 2 ports at same time in an Apache process.
You need to understand that you will create a "virtual" web server to answer multiple ports.

Anyway, let's open the ports.


/etc/apache2/ports.conf

NameVirtualHost *:80
NameVirtualHost *:8000
Listen 80
Listen 8000

port 80 and port 8000 are opened, but port 8000 will not work even though you may see it as opened.

Create a "virtual" web server to answer port 8000.

Edit following;

/etc/apache2/sites-enabled

You may see a long configuration like...


<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks

        ...........................

</VirtualHost>

Copy all text, and paste it at the bottom of the file.
And change the second virtual host's port as 8000.

 
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www

        ...........................

</VirtualHost>
< VirtualHost *:8000>
        ServerAdmin webmaster@localhost


        ...........................

</VirtualHost>

That's it.

You can access 2 port after a restart.

sudo service apache2 restart



Saturday, November 19, 2011

Ubuntu as a wireless speaker of iPhone using Airport (ShAirPort)

What I wanted to do at first was to use my PC speaker as a wireless speaker to play music from iPhone directly without any wiring.

My first idea was to use bluetooth.
I had a hard time to set this up and finally succeeded to make an audio sink from iPhone using bluez(http://www.bluez.org/).
I could listen music with desktop speaker via bluetooth, but it was not so easy to make it running every time I want.

So I bought a bluetooth receiver.
(http://www.belkin.com/IWCatProductPage.process?Product_Id=508754)

This was very compatible and easy to use.
It automatically turned on only when it pairs with my iphone.
But I have not been using this because I was disappointed its sound quality.


Finally, I could do this with Apple's Airplay (http://www.apple.com/itunes/airplay/).
ShAirPort (https://github.com/albertz/shairport) can make Ubuntu to emulate airplay speaker.
It seems to me that ShAirPort was implemented to use Apple's private key(http://en.wikipedia.org/wiki/AirPlay#Reverse_engineering_AirTunes_and_AirPlay), so please use this at your own risk.
Also note that this instruction is from INSTALL.md in ShAirPort source.

1. download source of ShAirPort

https://github.com/albertz/shairport
Just click 'ZIP' icon, then you can download all source files in one zip archive.

*UPDATE*
I confirmed new version of shairport does not work with my fresh ubuntu 12.04.
I am not sure what has been changed, but old version of shairport still works on my fresh ubuntu 12.04.
If you don't mind, you may download old version of shairport below.
<http://www.mediafire.com/file/9pvazneb15hgxbm/albertz-shairport-83c1b71.zip>
You may compile and run it as described below.


2. unzip

Open terminal, go to the directory where you stored the source file and unzip.

$ cd Downloads
$ unzip albertz-shairport-83c1b71.zip
$ cd albertz-shairport-83c1b71

3. Install followings

$ sudo apt-get install build-essential libssl-dev libcrypt-openssl-rsa-perl libao-dev libio-socket-inet6-perl libwww-perl avahi-utils pkg-config

4. Compile

$ make

Make sure that you have no error.

5. Run

$ ./shairport.pl


That's it.
Now see your iPhone and make sure that you have ios version 5 or later.
You may play it with iPad, iPod and iTunes also.

You should see a new icon when you play a music,
just select new speaker in that menu.


Pros :
- All you need is just local network between iPhone and Ubuntu
- No quality loss
- Easy to configure
- Only few resource consumption

Cons :
- Consumes wireless bandwidth (802.11n is recommended)

uploading file to tftp server on ubuntu 10.04

It was strange for me that I had no problem on using tftp server earlier than Ubuntu 10.04.
I just could upload and download whatever I want only if I get enough permission.
However, it did not work as I expected on Ubuntu 10.04.
I got 'Permission Denied', 'File Not Found' or 'Forbidden directory' error with tftpd + xinetd, tftpd + openbsd-inetd or tftpd-hda.


I had to know that uploading file to a tftp server is not allowed for security reason.


The use of tftp(1) does not require an account or password on the remote system.  Due to the lack of authentication information, tftpd will allow only publicly readable files to be accessed.  Files containing the string ``/../'' or starting with ``../'' are not allowed.  Files may be written only if they already exist and are publicly writable.

So if you want to upload any file to tftp server without any limitation, use following configuration with tftpd-hda.


# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure --create"

 '--create' option will let you upload anything without limitation, but you should pay enough attention for the security.