Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
make your own Stage4 mini HOWTO
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3, 4, 5, 6  Next  
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
allucid
Veteran
Veteran


Joined: 02 Nov 2002
Posts: 1314
Location: atlanta

PostPosted: Tue Mar 09, 2004 3:45 am    Post subject: make your own Stage4 mini HOWTO Reply with quote

Custom Stage4 mini HOWTO:

NOTE:
check out the gentoo wiki for the most up to date version. I will not be maintaining this post anymore.
New Update: BlinkEye made a script that automates the process and greatly simplifies things!



old outdated stuff starts here:
I will go over the basics of creating a custom stage4 archive in this mini HOWTO. A stage4 is basically an image of your entire root partition. The primary reason I make a stage4 is to allow for a quick recovery if I have a disk failure. It is basically the same as a stage3 only you can select the CFLAGS you want to use and what other software you want installed. You can adapt this method to suit your personal uses.

If you want a more generic stage4 that you can install on multiple systems use genkernel to set up your kernel so it works like the one on the livecd. You may also want to use less-restrictive CFLAGS (mcpu instead of march). You may still have to modify the fstab and USE flags after extracting the stage4 to suit the user.

Step1:
Install Gentoo.

Step2:
Configure all drivers (sound, video, usb, etc) and install any software you want to be included on your stage4. For example, I would install X, Xfce4, Sun's JDK, CVS, Emacs, Thunderbird, and Firefox.

Step3:
Make a copy of your /boot partition:
Code:
root# mount /boot
root# cp -R /boot /bootcpy
root# umount /boot

Alternatively, you can just mount /boot before you tar everything up. There may be problems with doing this when you use this stage4 with different hardware configurations.

Step4:
Clear out temporary files in /usr/portage/distfiles and /var/tmp to save space.

Step5:
After everything is how you want it, we will create the archive:
Code:
root# tar cCjpf /path/to/save/at/stage4.tar.bz2 / --exclude=stage4.tar.bz2 --exclude=/proc

tar options we used:
c - create archive
j - use bzip2 compression
p - preserve file attributes (don't leave this out!!)
f - specify file name
Be sure to look at the tar manpage


It will probably take a long time to create the archive depending on how much you have installed. I usually save the archive on a spare disk I have in my system that I use for backups. You can also burn it to a cd or dvd. If it is too large to fit on a cd you will have to split it up. Large tar files can be split up with 'split'. The parts can be joined later with 'cat'. ('man split', and 'man cat' for more info).

To install from a stage4:
1. Boot live CD
2. Partition and mount filesystem
3. root# cd /mnt/gentoo
4. copy your stage4 archive(s) to disk
(if it is on another CD type "gentoo cdcache" at the boot prompt. Then you'll be able to umount/mount other CDs.)
5. tar xvjpf stage4.tar.bz2
6. root# cp -R bootcpy /mnt/gentoo/boot
(double check the boot dir after you copy the files over!)
root# rm -rf bootcpy
7. fstab
8. grub or lilo

That's it! I know it's not the most elegant way to do things but it should get the job done. If anyone would like to offer some input/advice I would be glad to update the HOWTO. Let me know if I made any mistakes or missed anything here...I'm just doing this from memory. ;)

Updated according to advice given by users below. Thanks for the input.


Last edited by allucid on Sun Dec 05, 2004 7:14 am; edited 7 times in total
Back to top
View user's profile Send private message
Greven
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jul 2002
Posts: 138

PostPosted: Tue Mar 09, 2004 4:52 am    Post subject: Reply with quote

Awesome...... This is like a How-To back too. If you clear your distfiles the tar will be smaller.
_________________
veritas vos liberabit...
Linux User Number: 346805
Wine-Wiki
AMD 64 3500+ | MSI "K8T NEO2-FIR" | mushkin Dual Channel DDR 400
Back to top
View user's profile Send private message
allucid
Veteran
Veteran


Joined: 02 Nov 2002
Posts: 1314
Location: atlanta

PostPosted: Tue Mar 09, 2004 5:23 am    Post subject: Reply with quote

Greven wrote:
Awesome...... This is like a How-To back too. If you clear your distfiles the tar will be smaller.


good idea. updated.
Back to top
View user's profile Send private message
StringCheesian
l33t
l33t


Joined: 21 Oct 2003
Posts: 887

PostPosted: Tue Mar 09, 2004 9:23 am    Post subject: Reply with quote

Deleting the GRP packages in /usr/portage/packages (if any were copied over during installation) can save a lot of space too.
Back to top
View user's profile Send private message
Greven
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jul 2002
Posts: 138

PostPosted: Wed Mar 10, 2004 12:57 am    Post subject: Reply with quote

I get the broken pipe error. Help??
_________________
veritas vos liberabit...
Linux User Number: 346805
Wine-Wiki
AMD 64 3500+ | MSI "K8T NEO2-FIR" | mushkin Dual Channel DDR 400
Back to top
View user's profile Send private message
Greven
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jul 2002
Posts: 138

PostPosted: Wed Mar 10, 2004 1:42 am    Post subject: Reply with quote

I may of found the problem..... I was trying to dump to a FAT32 FS. I will try the -L flag.
_________________
veritas vos liberabit...
Linux User Number: 346805
Wine-Wiki
AMD 64 3500+ | MSI "K8T NEO2-FIR" | mushkin Dual Channel DDR 400
Back to top
View user's profile Send private message
markedmann
n00b
n00b


Joined: 09 Feb 2004
Posts: 18

PostPosted: Tue Mar 16, 2004 12:30 pm    Post subject: Reply with quote

Hey all:
When I try to do this, tar keeps complaining about changing filesizes and padding extra zeros. It also exits due to previous errors after about 450 megs. Is there anything I can do about this?
Thanks,
-Mark
Back to top
View user's profile Send private message
icywolf
n00b
n00b


Joined: 19 Jul 2003
Posts: 52

PostPosted: Tue Mar 16, 2004 12:37 pm    Post subject: Reply with quote

good howto thanks,

Which directory shouln'd be tar?

I know /proc /dev

Am I right? any other?
Back to top
View user's profile Send private message
bmichaelsen
Veteran
Veteran


Joined: 17 Nov 2002
Posts: 1277
Location: Hamburg, Germany

PostPosted: Tue Mar 16, 2004 1:02 pm    Post subject: Reply with quote

How about adding this HOWTO to:
http://gentoo-wiki.com
Back to top
View user's profile Send private message
Jarrod
n00b
n00b


Joined: 31 Aug 2003
Posts: 26
Location: Missouri

PostPosted: Tue Apr 06, 2004 7:18 am    Post subject: Reply with quote

To avoide having to copy /boot back and forth, I just do it this way...

Backup...

1. Boot from Live CD
2. Mount my partitions
3. tar cCjpf /mnt/gentoo/ /mnt/gentoo/stage4_backup.tar.bz2 * --exclude=stage4_backup.tar.bz2


Restore...

1. Boot from Live CD
3. create & mount partitions
4. tar -xvjpf /mnt/cdrom/stage4_backup.tar.bz2 -C /mnt/gentoo
5. chroot and Run grub or lilo depending on what you use


I actually got this from another thread in these forums, but they did not include the "--exclude" part so it would create a backup as well as include the backup file in the backup and also give you tar errors... ROFL... I just added the "--exclude" so it does not pick up the file you specify, so do not specify a name that would be used by gentoo! :)
Back to top
View user's profile Send private message
Cocker68
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 227
Location: Germany

PostPosted: Tue Apr 06, 2004 8:18 am    Post subject: Reply with quote

To make a big TAR-archive to fit onto Your CDs, try the split command:
Code:
# split -db 700m stage4.tar.bz2 stage4.tar.bz2.split
will create 700 MB-chunks, and
Code:
# cat stage4.tar.bz2.split* > stage4.tar.bz2
will put them back together.

- Cocker :wq


Last edited by Cocker68 on Tue Oct 05, 2004 5:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
kamilian
n00b
n00b


Joined: 23 Jun 2003
Posts: 59
Location: Sydney, Australia

PostPosted: Tue Apr 06, 2004 12:59 pm    Post subject: Reply with quote

I've been using a simple backup script, may be useful to tar the system for the Stage 4 tarball:

Code:
Cobra root # cat backup.sh

dirs="/mnt/* /proc /sys /tmp /usr/portage/distfiles /var/tmp/*"
tar $(for i in $dirs; do if [ -d $i ]; then echo -n " --exclude=$i/*"; fi; done) -cvjspf /tmp/system_backup-$(date +%Y-%m-%d).tar.bz2 /* > /tmp/backup.log 2> /tmp/backup_errors.log

Simply add directories you don't want in the tar archive (I normally add my home directory as well for a system backup) and away you go...

EDIT: Updated thanks to wallace1819!
_________________
May contain traces of nuts.
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Fri Apr 09, 2004 4:21 pm    Post subject: Re: make your own Stage4 mini HOWTO Reply with quote

allucid wrote:
Step5:
After everything is how you want it, we will create the archive:
Code:
root# tar cjpf /path/to/save/at/stage4.tar.bz2 /

tar options we used:
c - create archive
j - use bzip2 compression
p - preserve file attributes (don't leave this out!!)
f - specify file name
Be sure to look at the tar manpage (the --exclude option may be useful to some people).


I get tar erroring out with the above command
currentyl trying it with
Code:
tar cCPjpf / /path_to_tar * --exclude=tar_name --exclude=dev/* --exclude=proc/* --exclude=sys/*


anyone have some improvements? maybe a -W ?
Back to top
View user's profile Send private message
fdavid
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2003
Posts: 82
Location: Graz, Austria, EU

PostPosted: Mon Apr 12, 2004 7:08 am    Post subject: Reply with quote

It's a really good howto, I use a very similar method to backup my /home onto cd-s.

Some remarks:
1. The trick with /boot is unneeded. Just mount it before you make the backup, and umount it afterwards.

2. The large tar files can be splitted with a small utility called split. The parts can be joined later with cat.

3. The exclude option of tar must be heavily utilized, because there are many directories, which must be excluded, when backing up your root. Exclude can also go for /usr/portage, if yo want a smaller archive. Why delete it?
The directories I exclude when backing up my root:
/mnt
/proc
/sys
/tmp
+ any directory, which is backed up separately.

4. Ok, and a small script, which I use for making backup of my /home.

(The /dev/hdX corresponds to the /mnt/tarbackup directory in /etc/fstab.)

Code:

#! /bin/bash
# Backup script for Gentoo Linux
# Author: fdavid
# Date: 2003.11.29.

# Making backup of home partition to cds

# options for the archive
tarOptions="--create --absolute-names -- preserve-permissions --gzip --file"

# name of the archive
archive=/mnt/tarbackup/$(date +%Y%m%d)home.tar.gz

# mount the backup partition
mount /dev/hdaX
sleep 5

# create the archive
tar ${tarOptions} ${archive} /home/;
echo archive is done

# split the archive to cd size (use: "cat ${archive}.* >> ${archive}" to join the parts)
split --bytes=700000000 ${archive} ${archive}.
echo splitting is done

# unmount
sleep 5
umount /dev/hdaX
Back to top
View user's profile Send private message
CharlieS
Tux's lil' helper
Tux's lil' helper


Joined: 06 Nov 2003
Posts: 146
Location: Texas, USA

PostPosted: Thu Apr 15, 2004 4:50 pm    Post subject: Reply with quote

if you exclude directories like /home /dev /proc /mnt and /sys , wouldnt you need to create them manually after you extract the backup file? otherwise when u boot up the computer it wont have a place for what is needed in those...

If i could program i would write out a script to do all of these things.. tar (with exclude functionality) then split.. then untar.. (and automake excluded directories as mentioned above)

Anyone up for the challenge?
Back to top
View user's profile Send private message
Delirium
n00b
n00b


Joined: 04 Jan 2003
Posts: 29
Location: Brisbane

PostPosted: Mon Apr 19, 2004 2:20 am    Post subject: laptop install Reply with quote

I'm using this method to install onto a toshiba laptop that doesn't have network support. Installing into vmware on my main computer (windows) then moving the install onto the laptop. It also speeds up the install time and doesn't stress out the laptop.

This is the perfect how to that I needed to finish the task, thanks all for the info. :D
Back to top
View user's profile Send private message
odessit
Apprentice
Apprentice


Joined: 01 Feb 2004
Posts: 180
Location: Current Residency - Server Room - Caution - Frostbite Imminent!

PostPosted: Tue Apr 20, 2004 12:49 am    Post subject: Re: laptop install Reply with quote

Delirium wrote:
I'm using this method to install onto a toshiba laptop that doesn't have network support. Installing into vmware on my main computer (windows) then moving the install onto the laptop. It also speeds up the install time and doesn't stress out the laptop.


neat trick, going to try it for my lappy (limited HD space, OO needs 4Gig free just to build)
Back to top
View user's profile Send private message
shanenin
Guru
Guru


Joined: 28 Nov 2003
Posts: 578
Location: Rochester, MN U.S.A

PostPosted: Thu Apr 22, 2004 4:24 pm    Post subject: Reply with quote

Quote:
To install from a stage4:
1. Boot live CD
2. Partition and mount filesystem
3. root# cd /mnt/gentoo
4. copy your stage4 archive(s) to disk
5. tar xvjpf stage4.tar.bz2


I am probably missing something obvious. If you are booting with the gentoo live cd, how can you take it out and insert another disk? Can the gentoo live cd be unmounted, then mount your cd that contains your system tar file?
_________________
http://brighteyedcomputer.com
Back to top
View user's profile Send private message
Iroko
n00b
n00b


Joined: 27 Jan 2004
Posts: 15
Location: Madison, WI USA

PostPosted: Wed Apr 28, 2004 11:05 am    Post subject: Reply with quote

shanenin wrote:
I am probably missing something obvious. If you are booting with the gentoo live cd, how can you take it out and insert another disk? Can the gentoo live cd be unmounted, then mount your cd that contains your system tar file?


When booting the LiveCD, type "gentoo cdcache" at the boot prompt. Then you'll be able to umount/mount other CDs.
Back to top
View user's profile Send private message
shanenin
Guru
Guru


Joined: 28 Nov 2003
Posts: 578
Location: Rochester, MN U.S.A

PostPosted: Wed Apr 28, 2004 2:19 pm    Post subject: Reply with quote

cool. thank you
_________________
http://brighteyedcomputer.com
Back to top
View user's profile Send private message
robfantini
Tux's lil' helper
Tux's lil' helper


Joined: 10 Jan 2004
Posts: 106
Location: Boston, Massachusetts

PostPosted: Fri Apr 30, 2004 1:42 am    Post subject: Reply with quote

regarding restoring /boot .

in my limited experience this can cause problems.

if the new/target computer has differences in scsi adapters, partitions or filesystem types then restoring /boot can cause problems. if the hardware is the same then there should not be a problem.

i'd suggest doing the save ot boot to bootcpy as allucid suggests.

then cp over System.map and kernel [init image also if you usee one].

let grub or lilo setup /boot/grub . use your /bootcpy/grub/grub.conf .
Back to top
View user's profile Send private message
AgentSmith
n00b
n00b


Joined: 06 Apr 2004
Posts: 5

PostPosted: Sat May 01, 2004 2:06 am    Post subject: Reply with quote

This is exactly what I needed to build an entire gentoo system on my athlon xp for my parent's pentium3 which is much slower and lacks broadband internet access. I made a base system, emerged xfree, kde (almost all kde packages), 2 extra games (digger and frozen bubble :)), mozilla firefox and thunderbird and installed openoffice binaries. This finally gave a gzipped tar of about 498 MB. Still considerably less than what fits on a cd, so why warn to not install too much? I have yet to transfer the system to the pentium3, but I am confident it will work.

Making a .tar.gz2 I used this:
Code:
tar cjpf /stage4.pentium3.tar.bz2 --exclude=stage4.pentium3.tar.bz2 --exclude=/proc

Both excludes are needed to avoid errors, so adding these to the HOW-TO would be a good idea.
Back to top
View user's profile Send private message
mahir
l33t
l33t


Joined: 05 Dec 2003
Posts: 725
Location: London

PostPosted: Sun May 09, 2004 7:53 pm    Post subject: help plz Reply with quote

Code:

root@en3 / # tar cCjpf /home/stage4.tar.bz2 / --exclude=stage4.tar.bz2 --exclude=/proc
tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
root@en3 / #


this is what i get?
any ideas?
_________________
"wa ma tawfiqi illah billah"
Mahir Sayar
Back to top
View user's profile Send private message
mahir
l33t
l33t


Joined: 05 Dec 2003
Posts: 725
Location: London

PostPosted: Mon May 10, 2004 12:40 am    Post subject: revised entry Reply with quote

Code:

mahir@en3 home $ sudo tar cjpf /home/Stage4.tar.bz2 / --exclude=Stage4.tar.bz2 --
-exclude=/proc --exclude=/dev --exclude=/sys --exclude=/mnt/*



is this fine?
removing dev and sys shouldnt cause any problems should it?
and i have my ntfs drives in mnt/
so i dont want them.
sounds ok right?
_________________
"wa ma tawfiqi illah billah"
Mahir Sayar
Back to top
View user's profile Send private message
househead
n00b
n00b


Joined: 30 Oct 2003
Posts: 70
Location: Manchester, UK

PostPosted: Wed May 12, 2004 8:01 pm    Post subject: Reply with quote

mahir wrote:
Code:

root@en3 / # tar cCjpf /home/stage4.tar.bz2 / --exclude=stage4.tar.bz2
--exclude=/proc
tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
root@en3 / #


this is what i get?
any ideas?


I get the same, but I removed the 'C' switch, and added a 'v' so I can
see what its doing. It seems to run ok.

Code:

etc/conf.d/gpm
etc/conf.d/net
etc/conf.d/usb
etc/conf.d/xfs
etc/conf.d/.keep
etc/conf.d/local.stop
etc/conf.d/firebird
etc/conf.d/esound
etc/conf.d/hdparm


You get the picture...

Does anyone know of a script that will verify this backup?
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
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