CyberCod
Group: Members
Posts: 25
Joined: Feb. 2007 |
|
Posted: Mar. 31 2007,17:01 |
|
Ok,
This restore disk works for the situation in the previous post. If you need it to work for your own custom setup, you'll have to change the script to reflect your own ideas.
I used VMware on my Ubuntu installation (on my main machine) to mess about with the remastering process so I wouldn't tank my dsl install on the old laptop.
So before I began all of this I had the following files already created and copied to a shared folder on my Ubuntu machine:
hda1backup.tar.gz ---this file is the result of doing the automatic backup on the previous post. It can be found on hda3 in the root directory.
hda3backup.tar.gz --- which I made after i had my automated system backup in place and working properly by doing the following in terminal on my hda1 dsl on the laptop.
Code Sample | sudo su mkdir /hda3 umount /dev/hda3 mount /dev/hda3 /hda3 cd / tar -cvzpsf /hda3backup.tar.gz hda3
|
MBRbackup.bin ---located on the root directory of hda1, which I made by doing the command
Code Sample | sudo dd if=/dev/hda of=/MBRbackup.bin bs=1 count=512
| from the hda1 dsl terminal of the laptop.
I ended up taking my remastering instructions from the page below. http://www.linuxforums.org/desktop....le.html
Most of the instructions weren't needed for my project, so I'll repost the steps below that I actually used.
I booted up to the dsl live disk iso in vmware with a virtual harddrive on IDE 0:1 that was formatted to ext2 for partition 1 and had enough space for the operation. As well as a swap partition for the live disk session to use on hdb2. The live disk should pick up the swap partition automatically.
I used hdb so it wouldn't confuse me with the backup operations which deal with "hda1"
To figure out how much space you need on hdb1, take the total size of your backup files and double it, and then add another 150 to 200 megs.
Here I cheated a little and did the partitioning of the virtual hard drive by loading up the virtual machine with an iso of Puppy Linux and using Gparted, but if you're familiar with partitioning using DSL, then more power to you.
If you're going to do this in a real situation (not in VMware) then you'll have to adjust the instructions below to reflect the actual partition you're going to use instead of hdb1, and the Samba portion of the instructions won't be necessary as you can just boot to your normal linux installation and burn the iso. So adjust this stuff as you need to for your specific case.
Ok... once the live disk is booted up, open up a terminal and put in the following commands.
Code Sample | sudo su mkdir /hdb1 mount /dev/hdb1 /hdb1
cd /hdb1 #note that from here on out everything is done from /hdb1 directory
mkdir source newcd newcd/KNOPPIX cp -Rp /cdrom/boot newcd cp -Rp /cdrom/lost+found newcd cp -Rp /cdrom/index.html newcd cp -Rp /KNOPPIX/* source cp -Rp /KNOPPIX/.bash_profile source
|
Ok, at this point, the /hdb1/source directory contains the same info as whats on the original live disk.
So at this point, I minimize the terminal.
I download the samba.dsl extension from MyDSL so I can copy my backup file from where I saved it on my desktop machine.
I mount up my samba share, then open emelfm in root mode. In the left panel I browse to my mounted shared folder, and in the right I go to /hdb1/source. The next step is to make a directory right pane called "backup" then enter it.
I then select my hda1backup.tar.gz file from the left pane and copy it to the right pane.
I do the same for hda3backup.tar.gz and MBRbackup.bin.
Once that is done, minimize emelfm as we'll use it again in a moment.
Now I open Beaver in root mode. Root mode may not be necessary, but it didn't hurt.
Using Beaver in root mode, open up /hdb1/souce/opt/bootlocal.sh
add the following line to it
Code Sample | sudo /KNOPPIX/backup/CDbackup.sh
|
save it, and then open a new file.
Here' where the script comes in... its pretty big AND IT IS FINALLY COMPLETE!
If you wish to customize this process, this script is where to do it.
in the new file put the following:
Code Sample |
#!/KNOPPIX/bin/bash # CD Restoration Script
initialize() { title() { clear echo " " echo " Roslins Restore Disk" echo " ver. 1.2 " echo " " echo " " echo " " echo " " echo " by Jeff Smith " echo " straightshootincomputin@yahoo.com " echo " " echo " " echo " Press Enter to continue..." read throwaway }
# this is the text that pops up when -=More Information=- # is selected from the menu. information() { clear echo " " echo " Hello, and welcome to Roslins Restore Disk! " echo " " echo " This disk will help you to restore your laptop" echo " to working condition with little hassel." echo " " echo " There are two options on the main menu for " echo " restoring. It is best to try Option 1 first and see" echo " if that gives you the results you want." echo " " echo " " echo " Press Enter to continue..." read throwaway
clear echo "Option 1 - Restore Last Backup" echo " Option 1 restores from the last backup you made" echo " using the BACKUP feature located in the right-click" echo " menu on the desktop." echo " " echo " If possible, you should use the RESTORE feature from" echo " that menu instead of using this disk." echo " " echo " Use Option 1 in the event that you cannot get to that " echo " feature in the right-click menu." echo " " echo " Press Enter to continue..." read throwaway
clear echo "Option 2 - Full Restoration" echo " Option 2 is for when you have really messed things up." echo " " echo " Option 2 will delete all information on your laptop" echo " and restore it to the way it was when you first got it." echo " " echo " All personal files and downloads will be gone" echo " but you will have a working system again." echo " " echo " Use Option 2 if Option 1 does not fix the problem." echo " " echo " Press Enter to continue..." read throwaway
clear echo "Option 2 - Full Restoration (continued)" echo " If Option 2 does not fix the problem, then you may" echo " need to first restore the Master Boot Record (MBR)," echo " which is Option 4. Then come back after rebooting " echo " and try Option 2 again, and it should work fine." echo " " echo " If none of this works, you may have a faulty" echo " harddrive." echo " " echo " " echo " " echo " Press Enter to continue..." read throwaway
clear echo "Option 3 - Make a new backup" echo " Option 3 will backup your main installation on hda1" echo " " echo " If you have lost the ability to backup via your right-click" echo " menu, you may not want to make this backup because doing" echo " so will lock in the changes you've made to the right-click menu." echo " Once you've backed up those changes, your only way of " echo " putting that option back is by doing the full restoration " echo " (Option 2) from this disk." echo " You will still be able to restore from this new backup" echo " by using this CD if you do not want the right-click option available" echo " Press Enter to continue..." read throwaway
}
mount_drives() { mkdir /hda1 mkdir /hda3 echo "Checking Filesystems" fsck /dev/hda1 fsck /dev/hda3 sleep 2 clear echo "Mounting partitions" sudo mount /dev/hda1 /hda1 sudo mount /dev/hda3 /hda3 sleep 2 }
#this is function to reboot the machine reboot_to_hd() { echo " " echo " " echo " Please press ENTER to reboot." read throwaway echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 reboot }
# this is a function to make a new backup file # on the partition hda3 backup_to_hda3() { clear echo " " echo "Performing Backup Operations..." echo "This can take up to an hour, please be patient." sleep 3 mount_drives cd / echo "Deleting previous backup file." rm -f /hda3/hda1backup.tar.gz echo "Building backup file /hda3/hda1backup.tar.gz" echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" tar -cvzpsf hda3/hda1backup.tar.gz /hda1 clear echo " " echo "Operating System on hda1 is now backed up to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " echo "You can restore this backup by using the RESTORE option" echo "located in the right-click menu, or by selecting Option 1" echo "from this disk." reboot_to_hd }
# this is a function to restore from a backup file # that is located on the partition hda3 restore_from_hda3() { clear echo " " echo "Restoring from Harddrive backup" echo "This will take a while, please be patient." echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" sleep 3 mount_drives cd /hda3 tar -xvzf hda1backup.tar.gz -C / clear echo " " echo "Operating System on hda1 is now restored from" echo "hda1backup.tar.gz on hda3." reboot_to_hd }
warning() { clear echo " " echo " Please note that this will delete everything on the drive" echo " before restoring from the original backup file." echo " " echo " Use this only if Option 1 does not work." echo " " echo "This machine will be reset to the state it was in when" echo " you received it." echo " Are you sure you want to do this?" echo " 1. Yes" echo " 2. No" echo "Enter your choice: " read warningchoice case $warningchoice in 1) restore_from_permanent ;; *) echo "Returning to main menu"; sleep 2 esac }
# this is a function to restore the MBR # from a backup file on the CD restore_mbr() { clear echo " " echo "Restoring Master Boot Record (MBR)" dd if=/KNOPPIX/backup/MBRbackup.bin of=/dev/hda bs=1 count=512 echo " " echo "Master Boot Record restored." reboot_to_hd }
restore_from_permanent() { clear echo "Will shortly begin restoring from permanent backup file " echo "located on this disk." echo " " echo "This will take a while, please be patient." echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" sleep 3 echo "Format hda1" mkfs.ext2 /dev/hda1 clear echo "Format hda3" mkfs.ext2 /dev/hda3 clear echo "Partitions formatted." mount_drives clear echo "Beginning hda1 restore" cd /KNOPPIX/backup tar -xvzf hda1backup.tar.gz -C / clear echo "hda1 restore complete." sleep 5 echo "Beginning hda3 restore" tar -xvzf hda3backup.tar.gz -C / clear echo "hda3 restore complete." sleep 5 clear echo "Copying hda1backup.tar.gz to hda3" cp /KNOPPIX/backup/hda1backup.tar.gz /hda3/hda1backup.tar.gz sleep 2 clear echo "Unmounting partitions" sudo umount /dev/hda1 sudo umount /dev/hda3 echo " " echo "Restoration Complete." reboot_to_hd }
interrupt_trapper() { echo "Cannot exit script this way." echo "To exit, select Option 5 or Option 6" echo "from the Main Menu" }
menu() { trap interrupt_trapper INT clear echo " MAIN MENU " echo " " echo "Choose from one of the options below to begin" echo " " echo "1. Restore Operating System from Harddrive Backup" echo "2. Do a Complete Restore from Backup on this disk" echo "3. Make a new backup of the system." echo "4. Restore MBR" echo "5. REBOOT" echo "6. Exit to Live session" echo " " echo " For more information on the presented options," echo " just press ENTER without any number." echo " " echo "If you're ready to begin, just type the" echo "number of your choice, and then press ENTER" read choice case $choice in 1) restore_from_hda3 ;; 2) warning ;; 3) backup_to_hda3 ;; 4) restore_mbr ;; 5) reboot_to_hd ;; 6) exit ;; *) information esac } } #below is the main flow of the script #everything else is a function. initialize title while :; do menu done
|
Ok, once all that is in the untitled text file, in Beaver you need to save it as /hdb1/source/backup/CDbackup.sh
Then bring emelfm back up and change the newly made text file's permissions to be executable by right-clicking backup.sh and selecting "Properties" then "Permissions" and pushing in the "exec" buttons and hittin apply or ok or whatever.
Now minimize emelfm again.
Ok, now its ready to be made into an ISO.
So we go back to the terminal which should still be parked at /hdb1.
put in the following two commands. be advised it takes a little while.
Code Sample |
mkisofs -R source | create_compressed_fs – 65536 > newcd/KNOPPIX/KNOPPIX
|
Code Sample | mkisofs -no-pad -l -r -J -no-emul-boot -boot-load-size 4 –boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -hide-rr-moved -o mydsl.iso newcd
|
When its done, it should poop you out a file called mydsl.iso in your /hdb1 directory.
Bring emelfm back up. The left pane should still show your samba shared folder. So just change the right pane to show /hdb1 and move your new ISO over to your shared folder.
Its is at this point that I made my snapshot in VMware.
At this point you can exit vmware and burn your new ISO.
When booting from the new disk, it never comes fully up to X, everything happens before that. You do have the option though of booting on up to the live session if you like.
The backup.sh script is pretty well commented.
If you have any more questions about it, please feel free to ask. If you discover any typos, lemme know asap if you please
In the next post I'll post every script I have that is involved with this process.
|