teppi wrote:

cha`o ca'c ba'c,




teppi ddi sa('m fla't la` vu+`a :). Thu+? ma^'y ca'i ddi'ttra^u fla't
xem sao, tha^'y a?nh chu.p ma`n hi`nh kha' dde.p


Trong ca'i distro ma` chai ru+o+.u gio+'i thie^.u:
ftp://ftp.iasi.roedu.net/mirrors/multidistro/2.0/
co' mo^.t script mkusb.sh. Su+? du.ng script na`y ta co' the^? ta.o ddu+o+.c 1 flash distro tu+` ba^'t ki` LiveCD (Di~ nhie^n vo+'i ddie^`u kie^.n la` ki'ch thu+o+'c LiveCD pha?i nho? ho+n dung lu+o+.ng Flash). Ca'ch su+? du.ng kha' ddo+n gia?n, co' hu+o+'ng da^~n kha' cu. the^? trong file na`y. (Trong ddo' RIP la` (R)ecovery (I)s (P)ossible http://www.tux.org/pub/people/kent-robotti/looplinux/rip/ ).


[Tri'ch]
Format the USB drive with a FAT16 filesystem, if not already.
  It only works with FAT16.
  # mkdosfs -F 16 /dev/sda1

  Install RIP to the USB device.

  # sh mkusb.sh RIP-11.4.iso.bin /dev/sda1 (or) /dev/sda

  The above example assumes that's the name of the RIP iso image, and
  the FAT16 formatted USB device is on /dev/sda1 or /dev/sda!

Instead of specifying an ISO image you can specify a source directory,
that contains the contents of the ISO image, laid out the same way
as the ISO image.
# sh mkusb.sh source_directory /dev/sda1 (or) /dev/sda


  If you had RIP on CD mounted under /mnt/cdrom, you could do this.

  sh mkusb.sh /mnt/cdrom /dev/sda1

  Run syslinux on the USB device, to make it bootable.
  You can get it here: http://syslinux.zytor.com

  # syslinux-nomtools /dev/sda1 (or) /dev/sda

  The mkusb.sh script will run the syslinux included with RIP,
  so you don't really need to do it yourself.
[/Tri'ch]
[OT]
   Ba'c Larry gia?m ki'ch thu+o+'c
[/OT]
#!/bin/sh
#
PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin"

help() {
  echo "
--------------------------------------------------------------------------
  This script \`$0' creates a bootable ISO image (using mkisofs),
  from the contents of the specified source directory.

  Usage: $0 grub source_directory out_directory iso_name (or)
         $0 isolinux source_directory out_directory iso_name
  
  For example, create a bootable grub ISO image named fooboo.iso in the
  /boo directory, from the contents of the /foo directory.
  sh $0 grub /foo /boo fooboo.iso 
--------------------------------------------------------------------------
"
  exit 1
}

if [ "$1" = "" -o "$2" = "" -o "$3" = "" ]; then 
  help
fi

if [ "$1" = "isolinux" ]; then 
  boot_image="isolinux/isolinux.bin"
elif [ "$1" = "grub" ]; then 
  boot_image="boot/grub/iso9660_stage1_5"
else
  help
fi

source_dir="$2"
out_dir="$3"
iso_name="$4"

if [ ! -d "$source_dir" ]; then 
  echo "ERROR: Can't find \`$source_dir' directory!"
  exit 1
elif [ ! -d "$out_dir" ]; then 
  echo "ERROR: Can't find \`$out_dir' directory!"
  exit 1
elif [ "$iso_name" = "" ]; then 
  echo "ERROR: No ISO name given!"
  exit 1
fi

if [ "$1" = "isolinux" ]; then 
if [ ! -f $source_dir/isolinux/isolinux.bin ]; then
  echo "ERROR: Can't find isolinux/isolinux.bin in $source_dir!"
  exit 1
fi  
elif [ "$1" = "grub" ]; then 
if [ ! -f $source_dir/boot/grub/iso9660_stage1_5 -o ! -f 
$source_dir/boot/grub/stage2 ]; then
  echo "ERROR: Can't find boot/grub/iso9660_stage1_5, and/or"
  echo "boot/grub/stage2 in $source_dir!"
  exit 1
fi
fi

if [ ! -x "`type -path mkisofs`" ]; then
  echo "ERROR: Can't find \`mkisofs' on the system!"
  exit 1
fi

echo fooboo >$source_dir/fooboo || exit 1
rm -f $source_dir/fooboo

echo -n "Continue and create $out_dir/$iso_name, from the
contents of the $source_dir directory? (Y/n) "
read ans
if [ "$ans" = "n" -o "$ans" = "N" ]; then
exit 0
fi

if dd if=/dev/hda of=$source_dir/hda.mbr bs=512 count=1 1>/dev/null 
2>/dev/null; then
  dev=hda
elif dd if=/dev/sda of=$source_dir/sda.mbr bs=512 count=1 1>/dev/null 
2>/dev/null; then
  dev=sda
fi

mkisofs -R -J -no-emul-boot -boot-load-size 32 -boot-info-table \
-b $boot_image -o $out_dir/$iso_name -V "MD v2_0" \
-A "RIP Linux rescue system" $source_dir || exit 1

if [ ! "$dev" = "" ]; then
  echo
  echo "I copied your hard drive MBR from \`/dev/$dev' to \`$dev.mbr' on 
$out_dir/$iso_name."
  echo "You can restore your whole MBR from the CD, like this!"
  echo "dd if=$dev.mbr of=/dev/$dev bs=512 count=1"
  echo "If you just want to restore the boot sector, do this!"
  echo "dd if=$dev.mbr of=/dev/$dev bs=446 count=1"
fi
  echo
  echo "DONE: Created $out_dir/$iso_name from the $source_dir directory!"
  exit 0
#!/bin/sh
#
# This is mkusb.sh. 10-25-2004
#
# sh mkusb.sh -h "For Help!"
#
PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin"

help() {
msg="Press enter to scroll, q to Quit!"
if [ -x "`type -path less`" ]; then
pager=less
elif [ -x "`type -path more`" ]; then
pager=more
else
pager=cat
msg=""
fi

$pager << EOF

$msg

========================================================================
          If you want to boot RIP from a USB flash drive.
========================================================================

   The USB device should be at least 26MB for RIP-11.4.iso.bin,
   and 36MB for RIP-11.4.fbsd.iso.bin. It probably won't work if
   the USB device is more than 1GB. The example below assumes
   your USB device is on /dev/sda1 or /dev/sda.

   Usually these USB devices come preformatted with a FAT16 partition.

   It's not strictly necessary to create a partition on the USB device,
   you can just put a FAT16 filesystem on it (mkdosfs -I -F 16 /dev/sda),
   and skip to installing RIP using the mkusb.sh script, described below.

   Create a FAT16 (type 6) partition on the USB drive, if not already.

# fdisk /dev/sda
Command (m for help): p

Disk /dev/sda: 128 MB, 128974848 bytes
4 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 248 * 512 = 126976 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n  (Create new partition)
p                        (Create primary partition)
Partition number (1-4): 1 
First cylinder  (enter for default) Use the whole drive, otherwise it may not
Last cylinder   (enter for default) boot! You can use space not used by RIP!
Command (m for help): t
Hex code (type L to list codes): 6
Command (m for help): a  (make active)
Partition number (1-4): 1 
Command (m for help): p

Disk /dev/sda: 128 MB, 128974848 bytes
4 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 248 * 512 = 126976 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1015      125829    6  FAT16

Command (m for help): w  (Write table to disk and exit)

   Format the USB drive with a FAT16 filesystem, if not already.
   It only works with FAT16.

   # mkdosfs -F 16 /dev/sda1

   Install RIP to the USB device.

   # sh mkusb.sh RIP-11.4.iso.bin /dev/sda1 (or) /dev/sda
 
   The above example assumes that's the name of the RIP iso image, and
   the FAT16 formatted USB device is on /dev/sda1 or /dev/sda!

   Instead of specifying an ISO image you can specify a source directory,
   that contains the contents of the ISO image, laid out the same way
   as the ISO image.
    
   # sh mkusb.sh source_directory /dev/sda1 (or) /dev/sda

   If you had RIP on CD mounted under /mnt/cdrom, you could do this.

   sh mkusb.sh /mnt/cdrom /dev/sda1 

   Run syslinux on the USB device, to make it bootable.
   You can get it here: http://syslinux.zytor.com

   # syslinux-nomtools /dev/sda1 (or) /dev/sda

   The mkusb.sh script will run the syslinux included with RIP,
   so you don't really need to do it yourself.

   If you want to change or add anything to the Linux system, do this.

   # mkdir /rip1 /rip2
   # mount -t msdos /dev/sda1 /rip1 (or) /dev/sda
   # tar xzvpf /rip1/boot/rootfs.tgz -C /rip2

   Make the changes in the /rip2 directory, then tar gzip the system.

   # rm /rip1/boot/rootfs.tgz
   /rip2# tar cvzpf /rip1/boot/rootfs.tgz *
   # rm -r /rip2
   # umount /rip1
   # rmdir /rip1

   To boot the RIP system your BIOS must support booting from a USB device.
EOF
exit 0
}

if [ "$1" = "-h" ]; then
help
fi

error() {
umount /tmp/rip1 2>/dev/null
umount /tmp/rip2 2>/dev/null
rmdir /tmp/rip1 /tmp/rip2 2>/dev/null
rm -f /tmp/rip1 2>/dev/null
exit 1
}

if [ ! "$1" = "" -a ! "$2" = "" ]; then
if [ ! -f "$1" -a ! -d "$1" ]; then
echo "ERROR: Can't find ISO image or source directory \`$1'!"
exit 1
elif [ ! -b "$2" ]; then
echo "ERROR: Can't find USB device \`$2'!"
exit 1
elif ! grep -q "loop" /proc/devices ; then
if [ ! -d "$1" ]; then
echo "ERROR: I need loop support in the kernel, or loaded as a module!"
echo "modprobe loop"
exit 1
fi
elif ! grep -q "iso9660" /proc/filesystems ; then
echo "ERROR: I need iso9660 support in the kernel, or loaded as a module!"
echo "modprobe iso9660"
exit 1
elif ! grep -v "umsdos" /proc/filesystems | grep -q "msdos" ; then
echo "ERROR: I need msdos support in the kernel, or loaded as a module!"
echo "modprobe msdos"
exit 1
fi
umount /tmp/rip1 2>/dev/null
umount /tmp/rip2 2>/dev/null
umount $2 2>/dev/null
if [ -d "$1" ]; then
rmdir /tmp/rip1 2>/dev/null
rm -f /tmp/rip1 2>/dev/null
ln -s $1 /tmp/rip1 || error
else
rmdir /tmp/rip1 2>/dev/null
rm -f /tmp/rip1 2>/dev/null
mkdir -p /tmp/rip1
mount -r -t iso9660 -o loop $1 /tmp/rip1 || error
fi
mkdir -p /tmp/rip2
mount -t msdos $2 /tmp/rip2 || error
else
echo "
----------------------------------------------------------------------
Usage: sh mkusb.sh RIP-11.4.iso.bin /dev/sda1

The above example assumes that's the name of the RIP iso image, and
the FAT16 formatted USB device is on /dev/sda1!

Instead of specifying an ISO image you can specify a source directory,
that contains the contents of the ISO image, laid out the same way
as the ISO image.

sh mkusb.sh source_directory /dev/sda1

If you had RIP on CD mounted under /mnt/cdrom, you could do this.

sh mkusb.sh /mnt/cdrom /dev/sda1 

For complete Help! type \`sh mkusb.sh -h'.
----------------------------------------------------------------------
"
exit 1
fi

rip_bat() {
cat << EOF
@echo off

if "%1"=="" goto help
if "%1"=="rescue" goto rescue
if "%1"=="linux" goto linux

:help
echo.
echo To boot the RIP rescue system from a DOS/Win9x system, do this.
echo.
echo Have the RIP USB drive plugged in, in this example it's e.
echo This only works on a DOS/Win9x system in DOS mode.
echo You have to be in DOS mode, shutdown Windows and restart in DOS mode.
echo C:\ e:
echo E:\ rip rescue
echo.
echo If you want to pass options to the kernel, do this.
echo For example, turn off acpi and apm
echo E:\ rip rescue acpi=off noapm
echo.
echo If you want to boot a Linux partition put the device it's on (/dev/xxxx).
echo E:\ rip linux root=/dev/hda2 ro
echo E:\ rip linux root=/dev/hda2 ro init=/bin/sh  "Specify init!"
echo E:\ rip linux root=/dev/hda2 ro single        "Boot to single-user mode!"
echo.
echo If you want to boot the small initrd Linux system.
echo E:\ rip small
echo.
goto exit
:rescue
loadlin kernel init=/linuxrc initrd=initrd.gz vga=normal root=/dev/ram0 rw %2%3
goto exit
:small
loadlin kernel devfs=nomount initrd=initrd.gz init=/linuxrc rip_initrd 
vga=normal root=/dev/ram0 rw %2%3
goto exit
:linux
loadlin kernel vga=normal %2%3%4%5 %6 %7%8 %9
goto exit
:exit
EOF
}

sys_cfg() {
cat << EOF
DEFAULT kernel
APPEND vga=normal devfs=nomount load_ramdisk=1 usb_device init=/linuxrc 
prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw
DISPLAY f1.txt
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt

LABEL rescue
KERNEL kernel
APPEND vga=normal devfs=nomount load_ramdisk=1 usb_device init=/linuxrc 
prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw

LABEL small
KERNEL kernel
APPEND vga=normal devfs=nomount init=/linuxrc rip_initrd load_ramdisk=1 
prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw

LABEL linux
KERNEL kernel
APPEND vga=normal load_ramdisk=0 ro

LABEL rama
KERNEL kernel
APPEND vga=normal load_ramdisk=1 prompt_ramdisk=1 root=/dev/fd0 rw

LABEL ramb
KERNEL kernel
APPEND vga=normal load_ramdisk=1 prompt_ramdisk=1 root=/dev/fd1 rw

LABEL freebsd
KERNEL memdisk
APPEND initrd=freebsd.img

LABEL memtest1
KERNEL memtest1.bin

LABEL memtest2
KERNEL memtest2.bin
EOF
}

if [ -f /tmp/rip1/boot/rootfs.tgz ]; then
echo "********** Copying, please wait... **********"
rm -f /tmp/rip2/rootfs.tgz
cp -v /tmp/rip1/boot/rootfs.tgz /tmp/rip2 || error
mkdir -p /tmp/rip2/doc
if [ -f /tmp/rip1/boot/freebsd.img ]; then
rm -f /tmp/rip2/freebsd.img
cp -v /tmp/rip1/boot/freebsd.img /tmp/rip2 || error
cp -v /tmp/rip1/doc/freebsd.txt /tmp/rip2/doc
fi
rm -f /tmp/rip2/initrd.gz
cp -v /tmp/rip1/boot/initrd.gz /tmp/rip2 || error
rm -f /tmp/rip2/kernel
cp -v /tmp/rip1/boot/kernel /tmp/rip2 || error
cp -v /tmp/rip1/boot/memdisk /tmp/rip2
cp -v /tmp/rip1/boot/loadlin.exe /tmp/rip2
cp -v /tmp/rip1/boot/memtest* /tmp/rip2
for f in copying.txt kernel.txt linux.txt memtest.txt rip.txt
do
cp -v /tmp/rip1/doc/$f /tmp/rip2/doc
done
cp -v /tmp/rip1/isolinux/f*.txt /tmp/rip2
rip_bat > /tmp/rip2/rip.bat
sys_cfg > /tmp/rip2/syslinux.cfg || error

mbr="`grep "^ " /proc/partitions | grep -E "(hd|sd)[a-z]$" | awk '{print $4}' | 
head -n 1`"

if [ -n "$mbr" -a -b "/dev/$mbr" ]; then
dd if=/dev/$mbr of=/tmp/rip2/$mbr.mbr bs=512 count=1 1>/dev/null 2>/dev/null
MBR=YES
fi

umount /tmp/rip2 2>/dev/null

#if [ -x "`type -path syslinux`" ]; then
#syslinux $2 2>/dev/null || syslinux=failed
#else
cp /tmp/rip1/boot/syslinux.bin /tmp 2>/dev/null
chmod 755 /tmp/syslinux.bin 2>/dev/null
/tmp/syslinux.bin $2 2>/dev/null || syslinux=failed
rm -f /tmp/syslinux.bin
#fi

umount /tmp/rip1 2>/dev/null
rmdir /tmp/rip1 /tmp/rip2 2>/dev/null
rm -f /tmp/rip1 2>/dev/null

if [ "$MBR" = "YES" ]; then
  echo
  echo "I copied your hard drive MBR from \`/dev/$mbr' to \`$mbr.mbr' on $2."
  echo "You can restore your whole MBR from the USB drive, like this!"
  echo "dd if=$mbr.mbr of=/dev/$mbr bs=512 count=1"
  echo "If you just want to restore the boot sector, do this!"
  echo "dd if=$mbr.mbr of=/dev/$mbr bs=446 count=1"
fi

if [ "$syslinux" = "failed" ]; then
echo "
Run syslinux on the USB device, to make it bootable!
You can get it here: http://syslinux.zytor.com
syslinux $2"
else
echo "
Ran \`syslinux $2' on the USB device, to make it bootable!
The USB device should be ready to boot!"
fi

echo "Done!"
exit 0
else
umount /tmp/rip1 2>/dev/null
umount /tmp/rip2 2>/dev/null
rmdir /tmp/rip1 /tmp/rip2 2>/dev/null
rm -f /tmp/rip1 2>/dev/null
echo "ERROR: Can't find \`/boot/rootfs.tgz' on \`$1'!"
exit 1
fi

Trả lời cho