Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Howto make a restore DVD
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message

Joined: 23 Dec 2004
Posts: 790
Location: under a car or on top of a keyboard

PostPosted: Wed Mar 09, 2005 6:28 am    Post subject: Howto make a restore DVD Reply with quote

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

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/ 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

export PATH=/bin

# Get kernel CMDLINE
/bin/busybox mount -t proc none /proc
CMDLINE=`/bin/busybox cat /proc/cmdline
umount /proc`

# Mount CD device
for x in hdd hdc;
  /bin/busybox mount -t iso9660 -r /dev/$x /cdrom # > /dev/null 2>&1
  if [ "$?" = "0" ]

# CD not found
if [ "${CDROM}" = "" ]
  exec /bin/busybox sh 2>&1

/bin/busybox echo "Reinstall Windows (y/n)?"
/bin/busybox echo "Reinstall Linux (y/n)?"
/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

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
/bin/busybox umount /cdrom
exec /bin/busybox chroot / /bin/busybox sh

The grub.conf should look like this:

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


##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:
 ls -R
bin  cdrom  dev  etc  lib  linuxrc  lost+found  newroot  proc  usr

bunzip2  busybox  bzip2  dd  mkdosfs  mkntfs  mkreiserfs  ntfsfix  tar


console  hda  hda1  hda4  hda5  hda6  hdb  hdc  hdd  loop0  null  tty

fstab  mtab

./lib:    tls





lib  sbin


But I have some things on there for diagnostics purposes that really aren't necessary.
Back to top
View user's profile Send private message

Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Wed Mar 09, 2005 1:27 pm    Post subject: Reply with quote

You can also transform a Gentoo LiveCD into a LiveDVD:
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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
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