Howto Creation of a Stage 5
Table of Contents
- Context
- Differences between the Stage 4 and the Stage 5
- Creation of a Stage 5
- Creation of a Stage 5 Standard
- Creation of a Stage 5 Custom
- Advantages & Inconveniences
- Possible Options
- Copy your Stage 5 archive
- Restoration of a Stage 5
- Restoration of a Stage 5 Standard
- Restoration of a Stage 5 Custom
1) Context
Hello everyone, because of a awesome crash after a restoration of a Stage 4 archive, I decided to write this howto for those who don't wont problems.
The Stage 4 works perfectly in general, but if you are lucky like me, it will crash your Gentoo
So, if you have a Gensplash, a /mnt directory, you will have a problem with the Stage 4, because he doesn't backup these directory by default.
Here's my configuration :
Code: Select all
#
# Sample boot menu configuration file
#
# Boot automatically after 30 secs.
timeout 5
# By default, boot the first entry.
default 1
splashimage=(hd0,8)/boot/grub/splash.xpm.gz
title=GentooLinux-2.6.18-r3
root=(hd0,8)
kernel /boot/kernel-2.6.18-gentoo-r3 root=/dev/sda9 video=vesafb:mtrr,ywrap,1024x768-32@85 splash=silent,fadein,theme:livecd-2006.1 quiet CONSOLE=/dev/tty1
initrd (hd0,8)/boot/fbsplash-livecd-2006.1
#kernel /boot/kernel-2.6.18-gentoo-r3 root=/dev/sda9 video=radeonfb:mtrr,ywrap,1024x768-32@75
title=WindowsXP
rootnoverify (hd0,0)
makeactive
chainloader +1
title=GentooLinux-2.6.18-r2
root=(hd0,8)
kernel /boot/kernel-2.6.18-gentoo-r2 root=/dev/sda9 video=radeonfb:mtrr,ywrap,1024x768-32@75
Code: Select all
# This file is edited by fstab-sync - see 'man fstab-sync' for details
# /etc/fstab: static file system information.
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/fstab,v 1.14 2003/10/13 20:03:38 azarah Exp $
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed; notail increases performance of ReiserFS (at the expense of storage
# efficiency). It's safe to drop the noatime options if you want and to
# switch between notail and tail freely.
# <fs> <mountpoint> <type> <opts> <dump/pass>
/dev/sda9 / ext3 defaults,noatime 0 1
/dev/sda10 none swap sw 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs nodev,nosuid,noexec 0 0
/dev/cdroms/cdrom0 /mnt/cdrom0 auto noauto,user 0 0
/dev/cdroms/cdrom1 /mnt/cdrom1 auto noauto,user 0 0
/dev/sda8 /mnt/pont vfat defaults,rw,user,umask=0 0 0
/dev/sda1 /mnt/win_c ntfs defaults,ro,user,nls=iso8859-1,nls=utf8,umask=0 0 0
/dev/sda5 /mnt/win_d ntfs defaults,ro,user,nls=iso8859-1,nls=utf8,umask=0 0 0
/dev/sda6 /mnt/win_e ntfs defaults,ro,user,nls=iso8859-1,nls=utf8,umask=0 0 0
/dev/sda7 /mnt/win_f ntfs defaults,ro,user,nls=iso8859-1,nls=utf8,umask=0 0 0
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#/dev/BOOT /boot ext2 noauto,noatime 1 1
#/dev/ROOT / xfs noatime 0 0
#/dev/SWAP none swap sw 0 0
#/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0
#/dev/fd0 /mnt/floppy auto noauto 0 0
#
# NOTE: The next line is critical for boot!
#none /proc proc defaults 0 0
#
# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
# use almost no memory if not populated with files)
# Adding the following line to /etc/fstab should take care of this:
#
#none /dev/shm tmpfs defaults 0 0
#
#/dev/hdd /media/cdrom auto user,exec,noauto,managed 0 0
#/dev/hdc /media/cdrecorder auto user,exec,noauto,managed 0 0
#/dev/floppy/0 /media/floppy auto user,exec,noauto,managed 0 0
#/dev/sdb1 /media/sdb1 auto user,exec,noauto,managed 0 0
and it will boot perfectly without any errors.
For the record, I will list the problems that I had after a restore of Stage 4 backup:
-A lot of messages about udev.rule, UDEV-event #.
-The script didn't backup /mnt, so in my case, I had a warning about the FSTAB.
-For a unknown reason, my Gensplash didn't start, because of a missing /dev/TTY1...so my Gensplash was disable.
2) Differences between the Stage 4 and the Stage 5
First of all, you can find the excellent Stage 4 script here : http://blinkeye.ch/mediawiki/index.php/ ... 8stage4%29
The Stage 4, is a script that backup only the necessary directories to have a minimal functionable Gentoo.So, the Stage 4 doesn't take a ghost of a partition.Also, the Stage 4 never backup the directory /dev and if you have a Gensplash, you won't have /dev/console and /dev/tty1, and it will crash your Gensplash.
The Stage 5, is only uses the tar command, so you can do what you want.In fact, you can take a ghost of a partition or only take a backup of certain directory.
Like the Stage 4, the Stage 5 have a integrity check and the end of the process.
Finally, I wrote the Stage 5 for that purpose and I choosed the next number for the Stage.
3) Creation of Stage 5
Creation of a Stage 5 Standard
Code: Select all
# su -
# rm /usr/portage/distfiles/*
# mkdir /mnt/backup
# mount -o bind / /mnt/backup
# cd /mnt/backup
# tar --exclude stage5.tar.bz2 -cvvjpf stage5.tar.bz2 .
# time bzip2 -tv stage5.tar.bz2
# umount /mnt/backup
If you have a /boot, before starting your tar command, double check inside /mnt/back/boot if you have something.
If not, run this command :
Code: Select all
# mount -o bind /boot /mnt/backup/boot So, I had a / for sda8 and a /boot for sda7 for example.
The "." after the .bz2 is very important
The bzip2 command will check the integrity of the archive.
The creation of the .tar.bz2 takes some time, so be patient.
The Stage 5 act like Ghost or Acronis True Image.In fact, you can backup a complete partition.With this stage, you can backup a complete HDD and transfer it to a new one without any problems.The technique can be use by administrator, because in case of a crash, they can restore only the partition that failed.
Creation of a Stage 5 Custom
The Stage 5 custom, is a Stage 5 with parameters.
Advantages & Inconveniences
- This can backup a Gentoo installation or a complete partition and it can be use to backup only certain directories.
- It will be much faster, because it doesn't backup all the directories.
- You have to be very careful when you exclude directories, because it can crash your restoration, because you may have remove some files or directories that were essential for your Gentoo.
Here a example of a command that exclude /tmp,/var/tmp & /usr/portage/distfiles
Note that you don't have to put / before the directory, because you have binded the /
Code: Select all
# tar --exclude tmp --exclude var/tmp --exclude usr/portage/distfiles --exclude stage5.tar.bz2 -cvvjpf stage5.tar.bz2 .
Also, certain users wont to have a Stage 5 that contain only the minimum directory, so for that here an example :
Code: Select all
# rm -rf /usr/portage/distfiles/* && rm -rf /var/tmp/portage/* && rm -rf /var/log/portage/*
# tar cvvjpf --exclude=dev --exclude=proc --exclude=sys --exclude=tmp --exclude=stage5.tar.bz2 stage5.tar.bz2 .
Code: Select all
# mkdir {dev,proc,tmp,sys} && chmod 1777 tmp && cd dev && MAKEDEV generic
Code: Select all
# mount -o bind /home/$user /mnt/backup
# cd /mnt/backup
# tar --exclude stage5.tar.bz2 -cvvjpf stage5.tar.bz2 .
Code: Select all
# mount -o bind / /mnt/backup
# cd /mnt/backup
# tar --exclude stage5.tar.bz2 --exclude home/$user -cvvjpf stage5.tar.bz2 .
# time bzip2 -tv stage5.tar.bz2
# umount /mnt/backup
# mount -o bind /home/$user /mnt/backup
# cd /mnt/backup
# tar --exclude stagehome.tar.bz2 -cvvjpf stagehome.tar.bz2 .
# time bzip2 -tv stagehome.tar.bz2
# umount /mnt/backup
# mkdir /mnt/backup/full
# cd /
# cp stage5.tar.bz2 /mnt/backup/full/
# cp /home/$user/stagehome.tar.bz2 /mnt/backup/full
# tar -cvf stagefull.tar stage5.tar.bz2 stagehome.tar.bz2
Now, you can burn the .tar.bz2 with K3B or you can leave this image on a separate partition.
5)Restoration of a Stage 5
Restoration of a Stage 5 Standard
The first thing to do is to boot with the Gentoo LiveCD and use the docache option.This will be useful, because we need
to umount the LiveCD
Boot with the Gentoo LiveCD.
Code: Select all
#gentoo docache
Code: Select all
# mke2fs -j /dev/sda9 dans mon cas.
#umount /mnt/cdrom
Code: Select all
#mount /dev/cdrom /mnt/cdrom
#mount -t ext3 /dev/sda9 /mnt/gentoo dans mon cas
# cd /mnt/cdrom
# ls -la
# tar xjvpf /mnt/cdrom/stage5.tar.bz2 -C /mnt/gentoo/
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
# chroot /mnt/gentoo /bin/bash
# env-update
# source /etc/profile
# emerge --sync
# exit
# cd /
# umount /mnt/cdrom
# umount /mnt/gentoo/dev
# umount /mnt/gentoo/proc
# umount /mnt/gentoo
# reboot
Restoration of a Stage 5 Custom
The procedure of restoration of a Stage 5 Custom is almost the same as the Stage 5 Standard except some details.
But, you will have to insert your own command to be sure that everything is ok, because at the tar command you will have to adapt your command.
Exemple :
Code: Select all
#gentoo docache
# mke2fs -j /dev/sda9 dans mon cas.
#umount /mnt/cdrom
#mount /dev/cdrom /mnt/cdrom
#mount -t ext3 /dev/sda9 /mnt/gentoo dans mon cas
# cd /mnt/cdrom
# ls -la
# tar xjvpf /mnt/cdrom/stage5.tar.bz2 -C /mnt/gentoo/
# mkdir {dev,proc,tmp,sys}
# chmod 1777 tmp
# cd dev
# MAKEDEV generic
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
# chroot /mnt/gentoo /bin/bash
# env-update
# source /etc/profile
# emerge --sync
# exit
# cd /
# umount /mnt/cdrom
# umount /mnt/gentoo/dev
# umount /mnt/gentoo/proc
# umount /mnt/gentoo
# reboot




