View previous topic :: View next topic |
Author |
Message |
thebigslide l33t
Joined: 23 Dec 2004 Posts: 792 Location: under a car or on top of a keyboard
|
Posted: Wed Mar 09, 2005 6:28 am Post subject: Howto make a restore DVD |
|
|
Did you finally get your system installed the way you like it?
Now it's time to break your system and you don't want to waste a bunch of time reinstalling?
Got a DVD burner?
If you answered yes to the above 3 questions, this it for you.
** The link to the copybins script used below is here
** You need grub 0.95 or later to boot from CD
Code: | mkdir /tmp/autoinstaller
##The first thing we need to do is make an image of your system
##shut down X and log into a TTY as root.
##Stop all services except what you need to burn a DVD
##If your filesystem size is less than 4GB (hopefully most of you),
##take out the -j switch from the tar command below as it will only slow you down.
##If your filesystem is 4-5GB, try the -z switch instead of -j.
##I left the verbose option in there because you might want to watch it.
##If it is going to include a bunch of archives or something else you don't want,
##just --exclude it.
##If you have a windows partition (hopefully NTFS), you can back it up too!
df -h
cd /
tar cvjpf /tmp/autoinstaller/stage4.tar.bz2 * --exclude=dev/* --exclude=proc/* \
--exclude=sys/* --exclude=tmp/*
ntfsclone --output - /dev/hda1 | bzip2 -c > /tmp/autoinstaller/ntfs.img.bz2
cd /tmp/autoinstaller
##Copy over the kernel and grub.
##You MIGHT want to recompile the kernel for this.
mkdir boot
cp -a /boot/grub boot/
cp /boot/bzImage boot/
touch boot/initrd
dd if=/dev/zero of=boot/initrd bs=1024 count=4
losetup /dev/loop0 boot/initrd
mke2fs /dev/loop0
mkdir initrd
mount /dev/loop0 initrd
##The initrd needs to contain the files binaries, and device nodes
##needed to format your partitions and extract the tarball.
cd initrd
mkdir bin lib lib/tls
cp /bin/busybox bin/
cp /lib/ld-linux.so.2 lib/
##I'm going to use my copybins script for the sake of simplicity,
##but feel free to just ldd the binaries and copy everything by hand
copybins tar bunzip2 mkreiserfs
##Now we will make the devices that you need
cd dev
mknod /mnt/initrd/dev/console c 5 1
mknod /mnt/initrd/dev/null c 1 3
mknod /mnt/initrd/dev/hda b 3 0
mknod /mnt/initrd/dev/hdb b 3 64
mknod /mnt/initrd/dev/hdc b 22 0
mknod /mnt/initrd/dev/hdd b 22 64
mknod /mnt/initrd/dev/tty c 4 0
mknod /mnt/initrd/dev/loop0 b 7 0
##Please see /usr/src/linux/Documentation/devices.txt for more info
cd ..
##Now we make the script that executes at boot time right after the kernel is done loading.
touch linuxrc
chmod +x linuxrc
|
Code: | ##linuxrc
export PATH=/bin
# Get kernel CMDLINE
/bin/busybox mount -t proc none /proc
CMDLINE=`/bin/busybox cat /proc/cmdline
umount /proc`
# Mount CD device
CDROM=""
for x in hdd hdc;
do
/bin/busybox mount -t iso9660 -r /dev/$x /cdrom # > /dev/null 2>&1
if [ "$?" = "0" ]
then
CDROM="${x}"
break
fi
done
# CD not found
if [ "${CDROM}" = "" ]
then
exec /bin/busybox sh 2>&1
exit
fi
/bin/busybox echo "Reinstall Windows (y/n)?"
read WINYES
/bin/busybox echo "Reinstall Linux (y/n)?"
read LINYES
/bin/busybox mount -t proc none /proc
if [ $LINYES = "y" ]; then
/bin/busybox echo Formatting Linux
/bin/mkreiserfs /dev/hda6 -q
/bin/busybox mount -t reiserfs /dev/hda6 /newroot
/bin/busybox echo Filling Linux Filesystem - Do not interrupt this process...
cd newroot
/bin/tar xjpf /cdrom/stage4.tar.bz2
fi
if [ $WINYES = "y" ]; then
/bin/busybox echo "Formatting C:"
/bin/mkntfs /dev/hda1
/bin/busybox echo Filling Windows Filesystem - Do not interrupt this process...
/bin/bunzip2 -c /cdrom/ntfs.img.bz2 | /bin/dd of=/dev/hda1 bs=8192
/bin/ntfsfix /dev/hda1
fi
/bin/busybox umount /cdrom
exec /bin/busybox chroot / /bin/busybox sh
|
The grub.conf should look like this:
Code: |
title=Gentoo Linux Restore DVD
root (cd)
kernel (cd)/boot/bzImage video=vesafb:ywrap,pmipal,1024x768-24@85 root=/dev/ram0 rw init=/linuxrc
initrd (cd)/boot/initrd
|
Now we have all this put together in /tmp/autoinstaller.
Time to burn it to disk
Code: |
##Make sure this in unmounted first
umount /tmp/autoinstaller/initrd
growisofs -speed=2 -Z /dev/hdc -R -N -J -v -d -dvd-compat -hide-rr-moved \
-no-emul-boot -boot-info-table -b boot/grub/stage2_eltorito \
-boot-load-size 4 -hide boot.catalog -V "Gentoo Restore" \
-A "Gentoo Restore DVD" /tmp/autoinstaller/
|
Giver a test.
Here's the contents of my initrd, just for comparison:
Code: | ls -R
.:
bin cdrom dev etc lib linuxrc lost+found newroot proc usr
./bin:
bunzip2 busybox bzip2 dd mkdosfs mkntfs mkreiserfs ntfsfix tar
./cdrom:
./dev:
console hda hda1 hda4 hda5 hda6 hdb hdc hdd loop0 null tty
./etc:
fstab mtab
./lib:
ld-2.3.4.so ld-linux.so.1.9.11 libdl-2.3.4.so libuuid.so.1 tls
ld-linux.so.1 ld-linux.so.2 libdl.so.2 libuuid.so.1.2
./lib/tls:
libc-2.3.4.so libc.so.6 libpthread-2.3.4.so libpthread.so.0 librt-2.3.4.so librt.so.1
./lost+found:
./newroot:
./proc:
./usr:
lib sbin
./usr/lib:
libntfs.so.5 libntfs.so.5.0.0
./usr/sbin:
ntfsclone
| But I have some things on there for diagnostics purposes that really aren't necessary. |
|
Back to top |
|
|
Hauser l33t
Joined: 27 Dec 2003 Posts: 650 Location: 4-dimensional hyperplane
|
Posted: Wed Mar 09, 2005 1:27 pm Post subject: |
|
|
You can also transform a Gentoo LiveCD into a LiveDVD:https://forums.gentoo.org/viewtopic-t-293580-highlight-dvd.html _________________ AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl
Do I like to compile everything?
Positive definite! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|