Windows和linux GHOST

来源:互联网 发布:matlab 植物生长算法 编辑:程序博客网 时间:2024/05/18 01:01

clonezilla官网

http://clonezilla.nchc.org.tw/

 

Clonezilla Live on USB flash drive or USB hard drive

Some machine, e.g. Asus Eee PC or Acer Aspire One, comes without CD/DVDdrive. In this case, USB flash drive or USB hard drive is the best wayto boot Clonezilla live. To make your USB flash drive or hard drivebootable, first download Clonezilla live zip file.Then you can extract the files on your USB flash drive or USB harddrive and make it bootable on a MS Windows or GNU/Linux computer by thefollowing steps (This method only works for the file system in USBflash drive or USB hard drive is FAT format. For other file system, youcan try to use grub or other bootloader):

  • On MS windows
    *****************************
    WARNING! WARNING! WARNING!
    *****************************
    WARNING!:***DO NOT RUN*** makeboot.bat from your local hard drive! It shouldonly be run from your USB flash drive or USB hard drive. Executing itincorrectly could cause your MS windows not to boot!!!
    1. Download the HP-USB Format tooland format your flash drive using the Fat or Fat32 option. This programcan be used to format USB devices that won't boot properly whenformatted with MS windows format tool.
    2. Extract all the contents of the clonezilla-live-usb.zip toyour "flash drive." Keep the directory architecture, for example, file"COPYING" should be in the USB flash drive or USB hard drive's topdirectory (e.g. G:/COPYING).
    3. Browse to your "flash drive" and enter the directory "utils",then sub-directory "win32", then click the file "makeboot.bat" toexecute it. WARNING! Makeboot.bat must be run fromyour USB flash drive or USB hard drive. Executing it incorrectly couldcause your MS windows not to boot.
    4. Follow the on-screen instructions.
    (PS: The above description was modified from:http://www.pendrivelinux.com/2007/01/02/all-in-one-usb-dsl. Thanks toPDLA from http://pendrivelinux.com)
  • On GNU/Linux
    1. Prepare an USB flash drive or USB hard drive or external disk whichhas a partition using FAT (either FAT16, FAT32) file system. If the USBflash drive or USB hard drive does not have any partition, you can usedisk tool (e.g. gparted, fdisk, cfdisk or sfdisk) to create a partitionwith size 200 MB or more, Here we assume your USB flash drive or USBhard drive is /dev/sdb (You have to comfirm your the device name, since it's _NOT_ always /dev/sdb) on your GNU/Linux, so the partition table is like:
      # fdisk -l /dev/sdb


      Disk /dev/sdb: 12.8 GB, 12884901888 bytes

      15 heads, 63 sectors/track, 26630 cylinders

      Units = cylinders of 945 * 512 = 483840 bytes

      Disk identifier: 0x000c2aa7



      Device Boot Start End Blocks Id System

      /dev/sdb1 * 1 26630 12582643+ b W95 FAT32



      Then format the partition as FAT (e.g. "mkfs.vfat -F 32 /dev/sdb1" WARNING! Executing it incorrectly could cause your GNU/Linux not to boot. Confirm the command before you run it.).
      # mkfs.vfat -F 32 /dev/sdb1


      mkfs.vfat 2.11 (12 Mar 2005)

    2. Insert your USB flash drive or USB hard drive into the USBport on your Linux machine and wait a few seconds. Next, run thecommand "dmesg" to query the device name of the USB flash drive or USBhard drive. Let's say, for example, that you find it is /dev/sdb1. Inthis example, we assume /dev/sdb1 has FAT filesystem, and it isautomatically mounted in dir /media/usb/. If it's not automaticallymounted, manually mount it by "mkdir -p /media/usb; mount /dev/sdb1/media/usb/".
    3. Unzip all the files, and copy them into your USB flash driveor USB hard drive (You can make it by the command like: "unzipclonezilla-live-1.0.10-8.zip -d /media/usb/"). Keep the directoryarchitecture, for example, file "COPYING" should be in the USB flashdrive or USB hard drive's top directory (e.g. /media/usb/COPYING).
    4. To make your USB flash drive bootable, first change theworking dir, e.g. "cd /media/usb/utils/linux", then run "bashmakeboot.sh /dev/sdb1" (replace /dev/sdb1 as your USB flash drivedevice name), and follow the prompts to finish that. WARNING! Executing it with wrong device name could cause your GNU/Linux not to boot. Confirm the command before you run it.(There is a known problem if you run makeboot.sh on Debian Etch, sincethe program utils/linux/syslinux does not work on that. Make sure yourun it on newer GNU/Linux, e.g. Debian Lenny, Ubuntu 8.04, Fedora9...).
    5. If your USB flash drive or USB hard drive is not able toboot, check (1) Is there any partition in your flash drive ? It mustcontain 1 partition at least. (2) The partition must be marked as"bootable" in the partition table. (3) The partition must be on thecylinder boundary.

附件:makeboot.sh内容:

 

#!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>
# License: GPL
# Description: Program to make USB flash drive (FAT format) bootable by syslinux

# 1. Checking if partition table correct (on boundary, bootable)
# 2. cat mbr
# 3. syslinux -fs
#
# Append PATH
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH

#
prog="$(basename $0)"

#
[ -z "$SETCOLOR_SUCCESS" ] && SETCOLOR_SUCCESS="echo -en //033[1;32m"
[ -z "$SETCOLOR_FAILURE" ] && SETCOLOR_FAILURE="echo -en //033[1;31m"
[ -z "$SETCOLOR_WARNING" ] && SETCOLOR_WARNING="echo -en //033[1;33m"
[ -z "$SETCOLOR_NORMAL"  ] && SETCOLOR_NORMAL="echo -en //033[0;39m"
BOOTUP="color"

#
msg_are_u_sure_u_want_to_continue='Are you sure you want to continue?'
msg_you_have_to_enter_yes_or_no="You have to enter 'y', 'yes', 'n' or 'no'. Please enter it again!"
msg_do_you_want_to_make_it_bootable="Do you want to mark it as bootable ?"

#
USAGE() {
   echo "Usage: $prog partition_device"
   echo "Ex:"
   echo "To make /dev/sde1 bootable on Linux:"
   echo "  $prog /dev/sde1"
}
# Check if root or not
check_if_root() {
   if [ ! "$UID" = "0" ]; then
     echo
     echo "[$LOGNAME] You need to run this script /"`basename $0`/" as root."
     echo
     exit 1
   fi
}
#
to_continue_or_not() {
  local prompt_msg="$1"
  continue_choice=""
  while [ -z "$continue_choice" ]; do
    [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
    echo "$prompt_msg"
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo -n "[y/n] "
    read continue_choice
    case "$continue_choice" in
         y|Y|[yY][eE][sS])
            echo "OK! Let's do it!" ;;
         n|N|[nN][oO])
            echo "Program terminated!"
            exit 1
            ;;
         *)
            [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
            echo "$msg_you_have_to_enter_yes_or_no!"
            [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
            echo "--------------------------------------------"
            ;;
    esac
  done
} # end of to_continue_or_not

#
export LANG=C

#
check_if_root
target_part="$1"

#
if [ -z "$target_part" ]; then
  echo "No target partition was assigned!"
  USAGE
  exit 1
fi
if ! type parted &>/dev/null; then
  echo "Parted was not found on this GNU/Linux system. Please install it."
  echo "Program terminated!"
  exit 1
fi

# Make sure target_part is partition device name, not disk device name
if [ -z "$(echo $target_part | grep -iE "/dev/[hsu][bd][a-z]+[[:digit:]]+")" ]; then
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "/"$target_part/" is NOT a valid partition name!"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  USAGE
  exit 1
fi

#
pt_dev="$(basename $target_part)"  # e.g. sdc1
hd_dev="${pt_dev:0:3}"   # e.g. sdc
target_disk="/dev/$hd_dev"  # e.g. /dev/sdc
pt_dev_no="${pt_dev/$hd_dev}"  # e.g. 1

# Get machine info:
on_this_machine=""
if type dmidecode &>/dev/null; then
  machine_name="$(LANG=C dmidecode -s system-product-name 2>/dev/null | head -n 1)"
  if [ -z "$machine_name" -o "$machine_name" = "To Be Filled By O.E.M." ]; then
    dev_model_shown="Unknown product name"
  else
    dev_model_shown="$machine_name"
  fi
fi
on_this_machine="on this machine /"$dev_model_shown/""

#
if ! grep -qEw $pt_dev /proc/partitions; then
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "$target_part was NOT found!"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  echo "Available disk(s) and partition(s) $on_this_machine :"
  echo "--------------------------------------------"
  cat /proc/partitions
  echo "--------------------------------------------"
  echo "Program terminated!"
  exit 1
fi

#
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo "This command will install MBR and syslinux bootloader on this machine"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo "--------------------------------------------"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo "Machine: $dev_model_shown:"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fdisk -l $target_disk
echo "--------------------------------------------"

to_continue_or_not "$msg_are_u_sure_u_want_to_continue"
echo "--------------------------------------------"

# 0. Check if partition is a FAT partition
# parted -s /dev/hda1 print
# Disk /dev/hda1: 8590MB
# Sector size (logical/physical): 512B/512B
# Partition Table: loop
#
# Number  Start   End     Size    File system  Flags
#  1      0.00kB  8590MB  8590MB  fat32          
if [ -z "$(LANG=C parted -s $target_disk print | grep -E "^[[:space:]]*${pt_dev_no}/>" |  grep -iE "(fat16|fat32|vfat)")" ]; then
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "$target_part: this doesn't look like a valid FAT filesystem"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  echo "Program terminated!"
  exit 1
fi

# 1. Check if partition start/end on cylinder boundary
if [ -n "$(LANG=C fdisk -l $target_disk | grep -iE "(not start on cylinder boundary|not end on cylinder boundary)")" ]; then
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "Some partition does not start or end on cylinder boundary! This disk will not be able to boot via syslinux!"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  echo "Program terminated!"
  exit 1
fi

# 2. Bootable ?
bootable="$(LANG=C fdisk -l $target_disk | grep -Ew "^$target_part" | awk -F" " '{print $2}')"
if [ "$bootable" != "*" ]; then
  echo "$pt_dev is not marked as bootable! The partition table of $target_disk:"
  echo "--------------------------------------------"
  echo $dev_model_shown:
  fdisk -l $target_disk
  echo "--------------------------------------------"
  to_continue_or_not "$msg_do_you_want_to_make_it_bootable"
  echo "Running: parted -s $target_disk set $pt_dev_no boot on"
  parted -s $target_disk set $pt_dev_no boot on
  echo "--------------------------------------------"
fi

# 3. MBR
to_continue_or_not "Do you want to install mbr on $target_disk $on_this_machine ?"
echo "Running: cat ../mbr/mbr.bin > $target_disk"
cat ../mbr/mbr.bin > $target_disk

echo "--------------------------------------------"
# 4.
to_continue_or_not "Do you want to install the SYSLINUX bootloader on $target_part $on_this_machine ?"
# Since most of the cases when makeboot.sh is run, all the files are in FAT (USB flash drive normally uses FAT), we have to make syslinux executable.
echo "We need a filesystem supporting Unix file mode for syslinux. Copying syslinux from FAT to /tmp/..."
syslinux_tmpd="$(mktemp -d /tmp/syslinux_tmp.XXXXXX)"
cp -fv syslinux $syslinux_tmpd
chmod u+x $syslinux_tmpd/syslinux
echo "Running: $syslinux_tmpd/syslinux -f $target_part "
$syslinux_tmpd/syslinux -f $target_part
echo "done!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo "//NOTE// If your USB flash drive fails to boot (maybe buggy BIOS), try to use /"syslinux -fs $target_part/", i.e. running with /"-s/"."
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
[ -d "$syslinux_tmpd" -a -n "$(echo $syslinux_tmpd | grep "syslinux_tmp" )" ] && rm -rf $syslinux_tmpd

 

 

执行过程中的LOG

[san@localhost linux]$ sudo sh makeboot.sh /dev/sdc1
This command will install MBR and syslinux bootloader on this machine
--------------------------------------------
Machine:  :

Disk /dev/sdc: 262 MB, 262012928 bytes
1 heads, 56 sectors/track, 9138 cylinders
Units = cylinders of 56 * 512 = 28672 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           2        9138      255836    6  FAT16
--------------------------------------------
Are you sure you want to continue?
[y/n] y
OK! Let's do it!
--------------------------------------------
Do you want to install mbr on /dev/sdc on this machine " " ?
[y/n] y
OK! Let's do it!
Running: cat ../mbr/mbr.bin > /dev/sdc
--------------------------------------------
Do you want to install the SYSLINUX bootloader on /dev/sdc1 on this machine " " ?

[y/n] y
OK! Let's do it!
We need a filesystem supporting Unix file mode for syslinux. Copying syslinux from FAT to /tmp/...
`syslinux' -> `/tmp/syslinux_tmp.EQcm1K/syslinux'
Running: /tmp/syslinux_tmp.EQcm1K/syslinux -f /dev/sdc1
done!
//NOTE// If your USB flash drive fails to boot (maybe buggy BIOS), try to use "syslinux -fs /dev/sdc1", i.e. running with "-s".

原创粉丝点击