Add a symbolic link to the lfs-uefi-20170207.txt hint
[linux_from_scratch_hints.git] / OLD / lfsbackup.txt
blob5f4a2e87ebd97264c229bea6d384d3ba8def4587
1 TITLE:          Making a Working Backup of an LFS system
3 LFS VERSION:    4.0, should work on all
5 AUTHOR:         Eric Miller <emiller@techskills.com>
7 SYNOPSIS:
8         This will quickly create an functioning duplicate of a finished LFS system.
10         This is useful for:
12         -  Creating a backup of an LFS system on the same physical machine.  That way
13         if something goes wrong in BLFS, users can boot into the Backup system and
14         repair thier original LFS. (or reverse the process to "restore" thier system
15         to its original state.)
17         -  Doing a quick install on another system, e.g. "ghost".  If you have two
18         identical systems with the same hardware, remove a hard drive from one, mount
19         in the LFS box, and follow the instructions here.
21 HINT:
23 Once you have finished building an LFS system, it might be a good idea to create a 
24 backup of the new system, before continuing with BLFS and other projects.  In doing
25 so, you can confidently experiment with your new system and not "buy the farm" if 
26 things go terribly wrong.  A good time to do this is right at the end of the LFS book,
27 and before moving on to BLFS.  This hint will explain how to create a dual-boot LFS system,
28 using a finished LFS system as a model, without doing another install.
30 PREREQUISITES:
32 You will need really only three things to complete this _very_ simple project:
34 - a finished LFS system
35 - access to your original host system
36 - some hard drive space, unpartitioned, at least as large as your LFS system
38 Let me take a second to further define these, for those who intend to use this for other 
39 means.  A "finished LFS system" is up to your definition.  Nothing says that you have to 
40 wait until the last page of the LFS book to do this.  Really, any point that you want to 
41 create a "restore point" will work fine.  Understand that the dual-boot functionality
42 described here will _only_ work if your original LFS system was at least bootable.  
43 Likewise, you may elect to make a backup after sucessfully finishing a big BLFS project,
44 like installing X and getting a desktop to work.  The "finished system" is up to you.
46 If you followed the LFS book, your host system (the one you built LFS from), will still
47 be available in lilo.  You may, however, have gotten rid of that puppy just as soon as
48 you logged into LFS without errors.  There are creative ways to get around the fact that 
49 you may not have access to your original host system (the one you built LFS from).  You 
50 can use the LFS boot CD, or a boot floppy with the necessary tools (post to lfs-support for 
51 the url to the CD, see other hints for making boot floppies).  
53 Finally, unpartitioned drive space canbe on _any_ installed fixed drive.  You can even 
54 install a drive from another (identical) system, make this backup, re-install the drive in 
55 the original system, and you have two LFS systems for the price of one!  (to do this, you 
56 would ignore the editing of fstab, and you would need to use a boot disk to get into
57 the system the first time and run lilo.)
59 So, if you have those three things, let's do it!  For this hint, we will use a sample
60 system that looks like:
62 /dev/hda1       Host system
63 /dev/hda2       Swap
64 /dev/hda3       LFS (the one you are making a copy of) # we will call this the source 
65 /dev/hda4       the destination of our "backup" # we will call this the target
67 Note:  If you are doing this at the end of the LFS book, or after any other big jobs,
68 you may want to get rid of /static, /usr/src, and any other big files like lfs-sources.tar
69 You may also want to run the --strip script at the end of the book (4.0).  This is not 
70 necessary, and if you are uncomfortable deleting files or running the script, then don't!
71 It will only make your backup (considerably) smaller and the process much faster. 
73 **************************************************************************
74 STEP-BY-STEP:
76 -  Boot your system into the original host linux (or Boot CD or floppy).
78 -  fdisk /dev/hda (or whatever drive you using as the target)
80 -  Create a primary partition that is at least slightly bigger than the data of 
81    the source LFS.  When in doubt, 1GB should be PLENTY for post LFS system.
83 -  mke2fs /dev/hda4 (change to your situation, use /dev/hd## of target)
85 -  mkdir /mnt/backup (also mkdir /mnt/lfs, if its not there already!)
87 -  mount /dev/hda3 /mnt/lfs (change to your situation, use /dev/hd## of source)
89 -  mount /dev/hda4 /mnt/backup (change to your situation, use /dev/hd## of target)
91 -  cd /mnt/lfs (do not forget this, seriously!!!!)
93 -  cp -Rav * /mnt/backup
95 -  Take a break.....
97 -  When cp is complete, do:
99         vim /mnt/backup/etc/fstab
100     
101    and edit the fstab to include an entry for the new partition.  Refer to the 
102    LFS book, ch6, editing FSTAB, for detailed info if you need it.
104 -  Save the new fstab, reboot the system (shutdown -r now).
106 -  At the lilo prompt, choose your original (source) LFS system.
108 -  Login as usual, and do:
110         cp /etc/lilo.conf /anydir/anywhere      
111         vim /etc/lilo.conf
113    Edit lilo to INCLUDE the new (target) system.  The LFS book gives a good example
114    of what lilo.conf should look like, do <man lilo.conf> to see a VERY good 
115    example of a dual boot lilo.conf entry.
117 -  Save the new lilo.conf
119 -  run lilo (its in your path, just type lilo and <enter>).  Watch for errors!  If 
120    lilo produces errors, do not proceed!!! Check your syntax based on the errors, 
121    and edit lilo.conf as needed.  When in doubt, replace the copy of lilo.conf to its
122    original location (/etc) and start over.
124 -  When lilo exits without error (e.g. wrote *LFS, wrote backup), reboot and choose
125    the new backup system in lilo!
127 -  login, make sure everything is cool.
129 -  reboot, choose your original LFS system, proceed to make a mess of it without fear!
131 ***************************************************************************************
133 That's it.  It's my first hint, so it's uber simple.  To "restore" your system back to 
134 the point of the backup, just reverse the process!  By reverse, I don't mean the steps.
135 Simply make a backup of the backup, on the partition where the messed up LFS is.  Don't
136 forget to either rm -r * in / _OR_ mke2fs to wipe out all the stuff on the bad partition,
137 otherwise you will just "restore" the good stuff next to bad stuff.  
139 Thanks to Chris Lingard and others for thier guidance.
141 Use the hint at your own risk. Neither the author, nor the Linux From Scratch
142 project accepts any reponsibility for anything that happens when using these
143 documents or associated files.
145 An appropriate place to discuss this hint is blfs-support MailingList/NewsGroup
146 at LinuxFromScratch.Org.
148 If I can improve this hint, or clarify in any way, let me know!
150 emiller@techskills.com