I've a small PC building bussines and I'd like to provide a Restore CD with my systems, It's possible to use Partimage to generate Image CDs for windows XP, and later the user can rebuild the original configuration just booting that Image CD?
I've being doing this with ghost, but I can't afford it anymore.
Thanks
Alfredo
Clone Windows XP Disk
Moderator: feffer
restoring XP
Sure do this it will take a lot of work but it give u free "ghosting for windows boxes" It involves changing www.damnsmalllinux.org cd, a tiny version of knoppix 50 MB to boot in text mode. run some shells scripts to cfdisk > partimage > ntfsresize > reboot . the partimage image resides on the CD. You can run it pulling the .000 image from a samba share also.
cfdisk can be automated with expect autoexpect script.
You'll need to research remastering knoppix, bulding shell scripts, apt-get update to put the necessary tools on the damnsmalllinux CD to create a standalone Ghostlike CD but it is Possible. It allows me to ssh to a remote pc and restore a pc. partimage on NTFS is experimental but it works for me about 100 times a month rebuilding laptops/desktops with win2k and XP. I promise to do a writeup of exactly how to do it. I'll post it here but I need a couple of hours to write it up.
things that are needed on the knoppix cd are
smbfs
partimage allready on it.
cfdisk allready
ntfstools
expect
autexpect script came from expect web site. to automate cfdisk.
mkisofs
the trick to getting the xp.000 image small. go the the registry and force it to delete the pagefile.sys on shutdown, on reboot change runonce ket to have it change the registry back to regular setting. Delete the hibernate file if possible(bad maybe). You can create a rebuild on a dvd to have a larger image. 4.3gb plenty of space.
I promise to do a writeup of exactly how to do it. I'll post it here but I need a couple of hours to write it up. It has been an ongoing project for about a year that has paid off.
cfdisk can be automated with expect autoexpect script.
You'll need to research remastering knoppix, bulding shell scripts, apt-get update to put the necessary tools on the damnsmalllinux CD to create a standalone Ghostlike CD but it is Possible. It allows me to ssh to a remote pc and restore a pc. partimage on NTFS is experimental but it works for me about 100 times a month rebuilding laptops/desktops with win2k and XP. I promise to do a writeup of exactly how to do it. I'll post it here but I need a couple of hours to write it up.
things that are needed on the knoppix cd are
smbfs
partimage allready on it.
cfdisk allready
ntfstools
expect
autexpect script came from expect web site. to automate cfdisk.
mkisofs
the trick to getting the xp.000 image small. go the the registry and force it to delete the pagefile.sys on shutdown, on reboot change runonce ket to have it change the registry back to regular setting. Delete the hibernate file if possible(bad maybe). You can create a rebuild on a dvd to have a larger image. 4.3gb plenty of space.
I promise to do a writeup of exactly how to do it. I'll post it here but I need a couple of hours to write it up. It has been an ongoing project for about a year that has paid off.
Clone Windows XP Disk
Thanks for replying to my question, I'll wait for your writeup thanks for it.
One more question how long could take the restore process for a Windows XP with MS Office and some drivers installed?
Thanks again
One more question how long could take the restore process for a Windows XP with MS Office and some drivers installed?
Thanks again
Clone Windows XP Disk
It takes about 15 minutes on a pentium 2 300 mhz laptop 128mb ram. The speed of the restore process goes like this the first part is real quick until I guess it fills the ram(knoppix filesystem) with partimage data. Then it just reads from the cd and dumps, reads dumps, etc.
This is the way I restore windows xp/2000 to a pc from partimage.
You will need
Working windows pc to allow network shares on. An account called root with rights to add to the share should be added.
Pc that you can install linux on.
Cdburner
Network between the 2 pcs
Internet access
install DSL to a PC so we can remaster it
1. download www.damnsmalllinux.org iso 0.6.3 image
2. burn iso to cd
Have a windows Pc on the network. In this case allow us to access this share via samba at \\Windowspc\linux
Now boot with cd in the pc that you don't need the harddrive contents on.
5. At penguin splash screen type in knoppix 2 to get to text prompt.
6. Type in dsl-hdinstall.
Install DSL to hda1.
Do mkliloboot.
When it asks to reboot don't.
10. Here we change both the hard drive install of dsl and the Master copy of the Knoppix filesystem (/mnt/hda1/files) to not run x and login
Type:
mount -o rw /dev/hda1 /mnt/hda1
mkdir /mnt/hda1/files
cp -Rp /KNOPPIX/* /mnt/hda1/files
cd /mnt/hda1/files/etc
vi inittab
change the default runlevel to 2 from 5 id:2:initdefault:
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/etc
vi inittab
change the default runlevel to 2 from 5 id:2:initdefault:
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/files/etc/default
vi rcS change the SULOGIN=no to SULOGIN=yes
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/etc/default
vi rcS change the SULOGIN=no to SULOGIN=yes
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/files
rm -rf root
mkdir root
cd /mnt/hda1
rm -rf root
mkdir root
cd /
umount /dev/hda1
Basically we are copying the Knoppix filesystem to the hard drive and making a login prompt and runlevel 2 change and we are removing x from starting both on the dsl install and the copy of the knoppix system files in /mnt/hda1/files.
11. Now Reboot with cdrom removed.
Creating the remaster
We need to get some debian packages installed in order to create a rebuild system. We will also be copying over some files that allow us to restore windows boxes.
Login and setup the passwords for root and damnsmall. You should be at a prompt.
Set cd password
go to /etc
vi shadow. Look at the first line this is roots password encrypted write this line down on paper. Go to the line for the damnsmall account. Copy this line down. No go to
/files/etc. vi shadow. Reproduce both of the root and damnsmall lines to this file.
12. Here we are going to fix the installed dsl on hd to mount samba/windows shares. Also copying over the actual script files to restore machines with.
Type:
dpkg-restore
apt-get install smbfs
Mkdir /mnt/win
mount -t smbfs //windowspc/linux /mnt/win -o username:root
Now give the password for the root account on the windowspc box
We need to copy over some files from the Windows pc to the linux pc
cp /mnt/win/restore.sh /files/usr/bin
We need the following. You could skip this coptying from the window share by just manually creating these files with vi and put them in
/files/usr/bin
restoresh
restorexp.sh
remaster.sh
script.exp
remaster2.sh
chmod +x /files/usr/bin/restore.sh
chmod +x /files/usr/bin/restorexp.sh
chmod +x /files/usr/bin/remaster2.sh
chmod +x /files/usr/bin/script.exp
umount /mnt/win
reboot no cd
Login again
cd /files
chroot .
mount -t proc /proc proc
dpkg-restore
apt-get install smbfs
apt-get install expect
apt-get install parted
umount proc
hit Control+D
reboot, login
We are going to get some different debian packages now.
cd /files/etc/apt
vi sources.list
take out the first 2 lines and replace with these
deb http://http.us.debian.org/debian unstable main contrib non-free
deb http://http.us.debian.org/debian testing main contrib non-free
quit vi and Save by hitting Esc and typing: wq!
cd /files
chroot .
mount -t proc /proc proc
apt-get update
apt-get install ntfstools
apt-get install partimage
umount proc
hit Control+D
reboot with cd in the drive. Login
mount -o rw /dev/hda1 /mnt/hda1
cp /mnt/hda1/files/usr/bin/remaster2.sh /tmp
cd /tmp
/tmp/remaster2.sh windowspc linux root
Give your windows pc root password. Now the rebuild of the iso file will start. When done, Go to you windows pc and on the \\windowspc\linux directory should be newdsl.iso
burn to cd. Now
create your perfect windows build on a box.
Boot with newdsl cd in
login
remaster.sh
new laptop.iso file should be on windows PC
How to edit boot process to personalize and edit to boot in text mode always.
1. Put CD in Windows box and find the boot.img file on the cd under knoppix folder.
2. Use rawwrite.exe to make a boot diskette.
3. Now you can edit some boot files. You can edit them in windows using vim or under this iso mount the floppy disk in the drive and edit with vi
4. edit syslinux.cfg file so that the default is to boot into text mode. Notice knoppix 2
DEFAULT vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
TIMEOUT 300
PROMPT 1
DISPLAY boot.msg
F1 boot.msg
F2 f2
LABEL knoppix
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL knoppix-txt
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=normal initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL expert
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 initrd=miniroot.gz nomce BOOT_IMAGE=expert 2
LABEL fb1280x1024
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=794 xmodule=fbdev initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL fb1024x768
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 xmodule=fbdev initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL fb800x600
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=788 xmodule=fbdev initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL failsafe
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init vga=normal noscsi nodma noapm nousb nopcmcia nofirewire noagp nomce xmodule=vesa initrd=miniroot.gz BOOT_IMAGE=knoppix 2
LABEL userdef
KERNEL vmlinuz
APPEND ###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
5. Edit boot.msg this will give you text under the splash logo.
This cd is from Knoppix and Damnsmalllinux which is Debian based.
6. logo.16 is the splash image file you can create your own splash screen with your own logo or whatever.
Now copy the files back to the diskette(windows)
Use rawrite to read it back to boot.img save it on a windows share somewhere on your network that you can share out later.
restorexp.sh This will restore a windows XP PC from scratch
#!/bin/bash
# remove all partitions
dd if=/dev/zero of=/dev/hda bs=512 count=1
# fdisk automatically
expect -f script.exp
# mount cd to get image file
mount -t iso9660 /dev/sr0 /mnt/cdrom
# run Partimage
partimage -b -f3 restore /dev/hda1 /mnt/cdrom/win.000
# resize hard drive to maximize use of drive
ntfsresize -f /dev/hda1
# cp reboot from cd
cp /sbin/shutdown /tmp
# Eject the CD
cdrecord -eject dev=0,0,0
# reboot
/tmp/shutdown -nr no
remaster.sh This is used to create a remastered CD. It will allow you to set the hostname of the boot DSL CD. It is a desctructive process because it first copies the Master pc windows files to the Windowspc and then if cfdisks the drive. Remasters the iso and copies the iso to the Windows PC.
When cfdisk -z comes up setup a new primary Linux partion. Hit n>p>Enter>W>yes>q.
#!/bin/bash
# 1 is the name of the knoppix cd whenitboots. 2 is the hostname of the pc to temporarily hold your files. 3 is the share name.
# 4 is the windows PC domain username
test=$4
if [ -a $test ]
then
echo "variable assignements:"
echo "remaster.sh add variables 1-4 to run the script properly"
echo "1 = hostname of the cd when it boots"
echo "2 is hostname of the Windows pc to temp hold your files"
echo "3 is the Windows pc sharename"
echo "4 is the Domain user account"
else
mkdir /mnt/win
mount -t iso9660 /dev/sr0 /mnt/cdrom
mount -t smbfs //$2/$3 /mnt/win -o username=$4
partimage -b -f3 save /dev/hda1 /mnt/win/win
cfdisk -z
mkfs /dev/hda1
mount -o rw /dev/hda1 /mnt/hda1
mkdir /mnt/hda1/files
mkdir /mnt/hda1/openfiles
mkdir /mnt/hda1/cd
extract_compressed_fs /mnt/cdrom/KNOPPIX/KNOPPIX > /mnt/hda1/files.iso
mount -o loop /mnt/hda1/files.iso /mnt/hda1/files
cp -a /mnt/hda1/files/* /mnt/hda1/openfiles
cd /mnt/hda1/openfiles/etc/init.d
perl -lpi -e '$_ =~ s/hostname Knoppix/hostname '$1'/' knoppix-autoconfig
cp -a /cdrom /mnt/hda1/cd
rm -f /mnt/hda1/cd/cdrom/win.000
cp /mnt/win/win.000 /mnt/hda1/cd/cdrom
cd /mnt/hda1/cd
rm -f /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -R -l -V "KNOPPIX iso9660 filesystem" -hide-rr-moved -v \/mnt/hda1/openfiles | create_compressed_fs - 65536 > /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -r -J -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -o /mnt/hda1/laptop.iso cdrom
cp /mnt/hda1/laptop.iso /mnt/win
fi
remaster2.sh This is used in creating a remaster of dsl
#!/bin/bash
# 1 is the hostname of the windows pc to temporarily hold your files
# 2 is the Windows share name
# 3 is the windowsPC username
test=$3
if [ -a $test ]
then
echo "variable assignements:"
echo "remaster.sh add variables 1-4 to run the script properly"
echo "1 is hostname of the Windows pc to temp hold your files"
echo "2 is the Windows pc sharename"
echo "3 is the Domain user account"
else
mkdir /mnt/win
mount -t iso9660 /dev/sr0 /mnt/cdrom
mount -t smbfs //$1/$2 /mnt/win -o username=$2
mkdir /mnt/hda1/cd
cp -a /cdrom /mnt/hda1/cd
cd /mnt/hda1/cd
rm -f /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -R -l -V "KNOPPIX iso9660 filesystem" -hide-rr-moved -v \/mnt/hda1/openfiles | create_compressed_fs - 65536 > /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -r -J -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -o /mnt/hda1/newdsl.iso cdrom
cp /mnt/hda1/newdsl.iso /mnt/win
fi
restore.sh This is for restoring windows 2k boxes. It different than XP but it works for me
#!/bin/bash
# get HD size
hd=`sfdisk -s /dev/hda`
# convert to MB
mbs=`expr $hd / 1024`
# remove all first disk partitions
dd if=/dev/zero of=/dev/hda bs=512 count=1
# make a label
parted -s /dev/hda mklabel msdos
# repartition
parted -s /dev/hda mkpart primary 0 $mbs
# boot flag
parted -s /dev/hda set 1 boot on
# NTFS container
mkntfs -Q /dev/hda1
# mount cd to get image file
mount -t iso9660 /dev/sr0 /mnt/cdrom
# Partimage
partimage -b -f3 restore /dev/hda1 /mnt/cdrom/win.000
# resize hard drive to maximize use of drive
ntfsresize -f /dev/hda1
# cp reboot from cd
cp /sbin/shutdown /tmp
# Eject the CD
cdrecord -eject dev=0,0,0
# reboot
/tmp/shutdown -nr now
script.exp This is an autoexpext script that will automatically cdfdisk you first HD. We use Expect because it seems to be the only fdisk that will create an ntfs “type”.
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Fri Mar 26 09:12:25 2004
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don
set timeout -1
spawn cfdisk -z
match_max 100000
expect -exact "Print help screen"
send -- "n"
expect -exact "Create a new primary partition"
send -- "\r"
sleep 5
expect -exact "Size (in MB):"
send -- "\r"
expect -exact "Toggle bootable flag of the current partition"
send -- "b"
expect -exact "Boot"
send -- "t"
expect -exact "Enter filesystem type: 82"
send -- "7"
expect -exact "7#\[K"
send -- "\r"
expect -exact "Toggle bootable flag of the current partition"
send -- "W"
expect -exact "This may destroy data on your disk!"
send -- "yes\r"
expect -exact "Toggle bootable flag of the current partition"
send -- "q"
expect eof
Create your perfect windows build
In order to make a resore cd that reimages faster. It is best to remove unnecessary files and make it easier for you to reimage machines by making the partimage file smaller.
windows 200/xp with all the patches software you want.
When you first setup the partition during the Windows OS install size give it about 3 GB, we will resize that partion during the restore process.
Make a bat script to run at runonce key to run newsid.exe to rename the machine
make a bat script to change this registry key to 0 at next reboot.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"ClearPageFileAtShutdown"=dword:00000000
set this key to 1 before your last reboot before we create and image of this machine.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"ClearPageFileAtShutdown"=dword:00000001 I think.
5. Disable hibernation. It needs a file that is as big as your RAM on the cd drive. To disable it, open the "Power Options"
> control panel, select the "Hibernate" tab, and un-tick "Enable Hibernation" this gets rid of hiberfil.sys
You will need
Working windows pc to allow network shares on. An account called root with rights to add to the share should be added.
Pc that you can install linux on.
Cdburner
Network between the 2 pcs
Internet access
install DSL to a PC so we can remaster it
1. download www.damnsmalllinux.org iso 0.6.3 image
2. burn iso to cd
Have a windows Pc on the network. In this case allow us to access this share via samba at \\Windowspc\linux
Now boot with cd in the pc that you don't need the harddrive contents on.
5. At penguin splash screen type in knoppix 2 to get to text prompt.
6. Type in dsl-hdinstall.
Install DSL to hda1.
Do mkliloboot.
When it asks to reboot don't.
10. Here we change both the hard drive install of dsl and the Master copy of the Knoppix filesystem (/mnt/hda1/files) to not run x and login
Type:
mount -o rw /dev/hda1 /mnt/hda1
mkdir /mnt/hda1/files
cp -Rp /KNOPPIX/* /mnt/hda1/files
cd /mnt/hda1/files/etc
vi inittab
change the default runlevel to 2 from 5 id:2:initdefault:
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/etc
vi inittab
change the default runlevel to 2 from 5 id:2:initdefault:
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/files/etc/default
vi rcS change the SULOGIN=no to SULOGIN=yes
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/etc/default
vi rcS change the SULOGIN=no to SULOGIN=yes
quit vi and Save by hitting Esc and typing: wq!
cd /mnt/hda1/files
rm -rf root
mkdir root
cd /mnt/hda1
rm -rf root
mkdir root
cd /
umount /dev/hda1
Basically we are copying the Knoppix filesystem to the hard drive and making a login prompt and runlevel 2 change and we are removing x from starting both on the dsl install and the copy of the knoppix system files in /mnt/hda1/files.
11. Now Reboot with cdrom removed.
Creating the remaster
We need to get some debian packages installed in order to create a rebuild system. We will also be copying over some files that allow us to restore windows boxes.
Login and setup the passwords for root and damnsmall. You should be at a prompt.
Set cd password
go to /etc
vi shadow. Look at the first line this is roots password encrypted write this line down on paper. Go to the line for the damnsmall account. Copy this line down. No go to
/files/etc. vi shadow. Reproduce both of the root and damnsmall lines to this file.
12. Here we are going to fix the installed dsl on hd to mount samba/windows shares. Also copying over the actual script files to restore machines with.
Type:
dpkg-restore
apt-get install smbfs
Mkdir /mnt/win
mount -t smbfs //windowspc/linux /mnt/win -o username:root
Now give the password for the root account on the windowspc box
We need to copy over some files from the Windows pc to the linux pc
cp /mnt/win/restore.sh /files/usr/bin
We need the following. You could skip this coptying from the window share by just manually creating these files with vi and put them in
/files/usr/bin
restoresh
restorexp.sh
remaster.sh
script.exp
remaster2.sh
chmod +x /files/usr/bin/restore.sh
chmod +x /files/usr/bin/restorexp.sh
chmod +x /files/usr/bin/remaster2.sh
chmod +x /files/usr/bin/script.exp
umount /mnt/win
reboot no cd
Login again
cd /files
chroot .
mount -t proc /proc proc
dpkg-restore
apt-get install smbfs
apt-get install expect
apt-get install parted
umount proc
hit Control+D
reboot, login
We are going to get some different debian packages now.
cd /files/etc/apt
vi sources.list
take out the first 2 lines and replace with these
deb http://http.us.debian.org/debian unstable main contrib non-free
deb http://http.us.debian.org/debian testing main contrib non-free
quit vi and Save by hitting Esc and typing: wq!
cd /files
chroot .
mount -t proc /proc proc
apt-get update
apt-get install ntfstools
apt-get install partimage
umount proc
hit Control+D
reboot with cd in the drive. Login
mount -o rw /dev/hda1 /mnt/hda1
cp /mnt/hda1/files/usr/bin/remaster2.sh /tmp
cd /tmp
/tmp/remaster2.sh windowspc linux root
Give your windows pc root password. Now the rebuild of the iso file will start. When done, Go to you windows pc and on the \\windowspc\linux directory should be newdsl.iso
burn to cd. Now
create your perfect windows build on a box.
Boot with newdsl cd in
login
remaster.sh
new laptop.iso file should be on windows PC
How to edit boot process to personalize and edit to boot in text mode always.
1. Put CD in Windows box and find the boot.img file on the cd under knoppix folder.
2. Use rawwrite.exe to make a boot diskette.
3. Now you can edit some boot files. You can edit them in windows using vim or under this iso mount the floppy disk in the drive and edit with vi
4. edit syslinux.cfg file so that the default is to boot into text mode. Notice knoppix 2
DEFAULT vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
TIMEOUT 300
PROMPT 1
DISPLAY boot.msg
F1 boot.msg
F2 f2
LABEL knoppix
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL knoppix-txt
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=normal initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL expert
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 initrd=miniroot.gz nomce BOOT_IMAGE=expert 2
LABEL fb1280x1024
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=794 xmodule=fbdev initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL fb1024x768
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=791 xmodule=fbdev initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL fb800x600
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init apm=power-off hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi vga=788 xmodule=fbdev initrd=miniroot.gz nomce quiet BOOT_IMAGE=knoppix 2
LABEL failsafe
KERNEL vmlinuz
APPEND lang=us ramdisk_size=100000 init=/etc/init vga=normal noscsi nodma noapm nousb nopcmcia nofirewire noagp nomce xmodule=vesa initrd=miniroot.gz BOOT_IMAGE=knoppix 2
LABEL userdef
KERNEL vmlinuz
APPEND ###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
5. Edit boot.msg this will give you text under the splash logo.
This cd is from Knoppix and Damnsmalllinux which is Debian based.
6. logo.16 is the splash image file you can create your own splash screen with your own logo or whatever.
Now copy the files back to the diskette(windows)
Use rawrite to read it back to boot.img save it on a windows share somewhere on your network that you can share out later.
restorexp.sh This will restore a windows XP PC from scratch
#!/bin/bash
# remove all partitions
dd if=/dev/zero of=/dev/hda bs=512 count=1
# fdisk automatically
expect -f script.exp
# mount cd to get image file
mount -t iso9660 /dev/sr0 /mnt/cdrom
# run Partimage
partimage -b -f3 restore /dev/hda1 /mnt/cdrom/win.000
# resize hard drive to maximize use of drive
ntfsresize -f /dev/hda1
# cp reboot from cd
cp /sbin/shutdown /tmp
# Eject the CD
cdrecord -eject dev=0,0,0
# reboot
/tmp/shutdown -nr no
remaster.sh This is used to create a remastered CD. It will allow you to set the hostname of the boot DSL CD. It is a desctructive process because it first copies the Master pc windows files to the Windowspc and then if cfdisks the drive. Remasters the iso and copies the iso to the Windows PC.
When cfdisk -z comes up setup a new primary Linux partion. Hit n>p>Enter>W>yes>q.
#!/bin/bash
# 1 is the name of the knoppix cd whenitboots. 2 is the hostname of the pc to temporarily hold your files. 3 is the share name.
# 4 is the windows PC domain username
test=$4
if [ -a $test ]
then
echo "variable assignements:"
echo "remaster.sh add variables 1-4 to run the script properly"
echo "1 = hostname of the cd when it boots"
echo "2 is hostname of the Windows pc to temp hold your files"
echo "3 is the Windows pc sharename"
echo "4 is the Domain user account"
else
mkdir /mnt/win
mount -t iso9660 /dev/sr0 /mnt/cdrom
mount -t smbfs //$2/$3 /mnt/win -o username=$4
partimage -b -f3 save /dev/hda1 /mnt/win/win
cfdisk -z
mkfs /dev/hda1
mount -o rw /dev/hda1 /mnt/hda1
mkdir /mnt/hda1/files
mkdir /mnt/hda1/openfiles
mkdir /mnt/hda1/cd
extract_compressed_fs /mnt/cdrom/KNOPPIX/KNOPPIX > /mnt/hda1/files.iso
mount -o loop /mnt/hda1/files.iso /mnt/hda1/files
cp -a /mnt/hda1/files/* /mnt/hda1/openfiles
cd /mnt/hda1/openfiles/etc/init.d
perl -lpi -e '$_ =~ s/hostname Knoppix/hostname '$1'/' knoppix-autoconfig
cp -a /cdrom /mnt/hda1/cd
rm -f /mnt/hda1/cd/cdrom/win.000
cp /mnt/win/win.000 /mnt/hda1/cd/cdrom
cd /mnt/hda1/cd
rm -f /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -R -l -V "KNOPPIX iso9660 filesystem" -hide-rr-moved -v \/mnt/hda1/openfiles | create_compressed_fs - 65536 > /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -r -J -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -o /mnt/hda1/laptop.iso cdrom
cp /mnt/hda1/laptop.iso /mnt/win
fi
remaster2.sh This is used in creating a remaster of dsl
#!/bin/bash
# 1 is the hostname of the windows pc to temporarily hold your files
# 2 is the Windows share name
# 3 is the windowsPC username
test=$3
if [ -a $test ]
then
echo "variable assignements:"
echo "remaster.sh add variables 1-4 to run the script properly"
echo "1 is hostname of the Windows pc to temp hold your files"
echo "2 is the Windows pc sharename"
echo "3 is the Domain user account"
else
mkdir /mnt/win
mount -t iso9660 /dev/sr0 /mnt/cdrom
mount -t smbfs //$1/$2 /mnt/win -o username=$2
mkdir /mnt/hda1/cd
cp -a /cdrom /mnt/hda1/cd
cd /mnt/hda1/cd
rm -f /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -R -l -V "KNOPPIX iso9660 filesystem" -hide-rr-moved -v \/mnt/hda1/openfiles | create_compressed_fs - 65536 > /mnt/hda1/cd/cdrom/KNOPPIX/KNOPPIX
mkisofs -r -J -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -o /mnt/hda1/newdsl.iso cdrom
cp /mnt/hda1/newdsl.iso /mnt/win
fi
restore.sh This is for restoring windows 2k boxes. It different than XP but it works for me
#!/bin/bash
# get HD size
hd=`sfdisk -s /dev/hda`
# convert to MB
mbs=`expr $hd / 1024`
# remove all first disk partitions
dd if=/dev/zero of=/dev/hda bs=512 count=1
# make a label
parted -s /dev/hda mklabel msdos
# repartition
parted -s /dev/hda mkpart primary 0 $mbs
# boot flag
parted -s /dev/hda set 1 boot on
# NTFS container
mkntfs -Q /dev/hda1
# mount cd to get image file
mount -t iso9660 /dev/sr0 /mnt/cdrom
# Partimage
partimage -b -f3 restore /dev/hda1 /mnt/cdrom/win.000
# resize hard drive to maximize use of drive
ntfsresize -f /dev/hda1
# cp reboot from cd
cp /sbin/shutdown /tmp
# Eject the CD
cdrecord -eject dev=0,0,0
# reboot
/tmp/shutdown -nr now
script.exp This is an autoexpext script that will automatically cdfdisk you first HD. We use Expect because it seems to be the only fdisk that will create an ntfs “type”.
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Fri Mar 26 09:12:25 2004
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don
set timeout -1
spawn cfdisk -z
match_max 100000
expect -exact "Print help screen"
send -- "n"
expect -exact "Create a new primary partition"
send -- "\r"
sleep 5
expect -exact "Size (in MB):"
send -- "\r"
expect -exact "Toggle bootable flag of the current partition"
send -- "b"
expect -exact "Boot"
send -- "t"
expect -exact "Enter filesystem type: 82"
send -- "7"
expect -exact "7#\[K"
send -- "\r"
expect -exact "Toggle bootable flag of the current partition"
send -- "W"
expect -exact "This may destroy data on your disk!"
send -- "yes\r"
expect -exact "Toggle bootable flag of the current partition"
send -- "q"
expect eof
Create your perfect windows build
In order to make a resore cd that reimages faster. It is best to remove unnecessary files and make it easier for you to reimage machines by making the partimage file smaller.
windows 200/xp with all the patches software you want.
When you first setup the partition during the Windows OS install size give it about 3 GB, we will resize that partion during the restore process.
Make a bat script to run at runonce key to run newsid.exe to rename the machine
make a bat script to change this registry key to 0 at next reboot.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"ClearPageFileAtShutdown"=dword:00000000
set this key to 1 before your last reboot before we create and image of this machine.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"ClearPageFileAtShutdown"=dword:00000001 I think.
5. Disable hibernation. It needs a file that is as big as your RAM on the cd drive. To disable it, open the "Power Options"
> control panel, select the "Hibernate" tab, and un-tick "Enable Hibernation" this gets rid of hiberfil.sys
restorexp.sh neeed s tweak
cfdisk bootable marking was not working so
add
parted -s /dev/hda set 1 boot on
restorexp.sh This will restore a windows XP PC from scratch
#!/bin/bash
# remove all partitions
dd if=/dev/zero of=/dev/hda bs=512 count=1
# fdisk automatically
expect -f script.exp
# mount cd to get image file
mount -t iso9660 /dev/sr0 /mnt/cdrom
# run Partimage
partimage -b -f3 restore /dev/hda1 /mnt/cdrom/win.000
# resize hard drive to maximize use of drive
ntfsresize -f /dev/hda1
# set bootable
parted -s /dev/hda set 1 boot on
# cp reboot from cd
cp /sbin/shutdown /tmp
# Eject the CD
cdrecord -eject dev=0,0,0
# reboot
/tmp/shutdown -nr no
add
parted -s /dev/hda set 1 boot on
restorexp.sh This will restore a windows XP PC from scratch
#!/bin/bash
# remove all partitions
dd if=/dev/zero of=/dev/hda bs=512 count=1
# fdisk automatically
expect -f script.exp
# mount cd to get image file
mount -t iso9660 /dev/sr0 /mnt/cdrom
# run Partimage
partimage -b -f3 restore /dev/hda1 /mnt/cdrom/win.000
# resize hard drive to maximize use of drive
ntfsresize -f /dev/hda1
# set bootable
parted -s /dev/hda set 1 boot on
# cp reboot from cd
cp /sbin/shutdown /tmp
# Eject the CD
cdrecord -eject dev=0,0,0
# reboot
/tmp/shutdown -nr no