LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-13-2007, 05:40 AM   #16
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682

/dev/hda3 is a device and not a directory. It is better to list each system directory you want to back up instead of using the root directory. That way you don't try to backup /mnt, /dev/, /sys, /proc, /media or /tmp.

tar cvzf /mnt/backup.tar.gz /bin/ /etc/ /root/ /usr/ /boot/ /home/ /opt/ /sbin/ /sys/ /lib/

You could have a script that creates the directories you haven't backed up and then unpacks the tarball.
You could have "-C /" after the tar command to change the directory to the homedir regardless of where she extracts it from. However in a rescue situation, the root partition will need to be mounted somewhere else, so maybe
Code:
mount -t ext3 /dev/hda2 /mnt
tar -C /mnt -xvzf backup.tar.gz
Because of the -C option, I needed to add a hyphen before the xvzf this time. This will extract the files from the backup and extract them to /mnt.

Last edited by jschiwal; 03-13-2007 at 05:46 AM.
 
Old 03-14-2007, 09:50 PM   #17
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
I made my backup by going into a command line shell of a DamnSmallLinux live disk using boot option "DSL 2".


so even though the /mnt and other folders were there on hda1, they weren't active and nothing was mounted in them.

I started out by mounting both /dev/hda1 and /dev/hda3 to /hda1 and /hda3 respectively.

Code:
mkdir /hda1
mkdir /hda3
mount /dev/hda1 /hda1
mount /dev/hda3 /hda3
I tar'ed hda1 into a file on hda3.
Code:
tar -cvzpsf hda3/hda1backup.tar.gz hda1

I rebooted to desktop to assure myself that nothing had gone wrong, and that the backup file was representative of a (still) working system. Also I moved the backup file to a new folder called /backupfile on hda3, just because it was becoming cluttered in there from other things I am doing with the partition.


I booted via a live disk again and emptied out the hda1 partition.

now my backup is /hda3/backupfile/hda1backup.tar.gz

Looking back, I should have used "-C /" to change the dir to the root directory, as it already had hda1 mounted in /hda1 and "hda1" is the first leg of the unpack paths

but what I ended up doing was unmounting hda1 and mounting it under /hda3/backupfile
Code:
umount /dev/hda1
  #note you can't remove a folder when you're inside it ;)

mkdir /hda3/backupfile/hda1

mount /dev/hda1 /hda3/backupfile/hda1

cd /hda3/backupfile

tar -xvzf hda1backup.tar.gz
no other modifiers

this put everything where it needs to go..

rebooting gave me verification that it worked


Ok. so that part of the problem is figured out.

For a recap, I made three partitions, hda1 (ext2), hda2 (swap), hda3 (ext2).

In installed DSL into hda1, and customized the hell out of it.

then I booted to the DSL live disk using the "DSL 2" option to give me a live command line interface.
Code:
mkdir hda1
mkdir hda3

mount /dev/hda1 /hda1
mount /dev/hda3 /hda3

tar -cvzpsf hda3/hda1backup.tar.gz hda1
this made my backup file



then,

to test it,
cuz I'm crazy/brave
I booted back to text mode live session, remaking and remounting the partitions as I had before.
Code:
mkdir /hda1
mkdir /hda3
mount /dev/hda1 /hda1
mount /dev/hda3 /hda3

then to remove all files on hda1...
Code:
rm -rf /hda1/*

then one of the two ways below
(keeping in mind that I had moved the backup file to /hda3/backupfile)

*******The way I did it******
Code:
umount /dev/hda1
mkdir /hda3/backupfile/hda1
mount /dev/hda1 /hda3/backupfile/hda1

cd /hda3/backupfile
tar -xvzf hda1backup.tar.gz

******the way I could have done it (checked!)*******
Code:
cd /hda3/backupfile
tar -xvzf -C / hda1backup.tar.gz

reboot to hd as normal
voila`


**if any of you are confused by the above operation, note that when unpacking the tar.gz file as i had made it, it unpacks like this
hda1/boot/
hda1/boot/grub/
etc... etc

the first leg of each unpacked file's path is /hda1/ so unpacking to the mounted directory /hda1 would have given me a folder inside that partition named "hda1" with all the original files and directories inside it.

There's probably a more eloquent way of doing this or expressing the syntax, but I'm a big fan of "if it ain't broke don't fix it" so I'll stick with this unless someone can point out a better way.


I feel like I'm sculpting a work of art, only using blunt weapons.



ok, must figure out how to get the backup file ONTO the live disk so I don't need hda3, then the hda1 partition can be much larger.

then, next step would be to figure out backing up and restoring the MBR.

In the finished item, I believe it will go like this:

restore MBR (grub will be part of the backed up mbr, as well as partition size/type info ... i think)

format hda2 to be swap and mount it as swap for use in the unpacking operation

format hda1 to ext2 filesystem (optional)
restore from backup file to hda1

reboot to HD


PS> The whole backup file is only about 150MB.



wish me luck


------------------------------------------------------
edited for cleanup purposes and to improve readability
------------------------------------------------------

Last edited by CyberCod; 03-16-2007 at 11:53 PM.
 
Old 03-15-2007, 02:10 AM   #18
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
Quote:
ok, must figure out how to get the backup file ONTO the live disk so I don't need hda3
Although I have never done it, I think you are talking
about remastering an ISO. I had a quick google look at it:

http://www.linuxforums.org/desktop/r..._preamble.html

Quite similar
http://www.damnsmalllinux.org/talk/node/160

The solution below is possibly simpler (in my bad eyesight :-)
http://www.eng.uwaterloo.ca/twiki/bi...masteringGuide
 
Old 03-15-2007, 08:21 AM   #19
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
Make CD-ROM Recovery
maybe another project worth looking at, but the doc did
not allow me to find whether it was suitable or not for you
http://mkcdrec.ota.be/

edit: Noticed you cannot use mondorescue since you need at least 64 Mb memory

Last edited by Emmanuel_uk; 03-15-2007 at 11:45 AM.
 
Old 03-15-2007, 10:14 PM   #20
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
Thanks for the excellent suggestions. I'd already looked at the first two, but the one you said looked easier to your "bad eyesight" looks better to mine as well.

I'll check out the Make CD-ROM Recovery project if I fail at using that method.

I'm going to attempt to make a live disk in vmware and export it (via samba cuz I'm not good at NFS) to the external filesystem for burning. I think this will give me the most flexible way to do this easily. I am not sure how well it would work to make a DSL live disk on an ubuntu system. So booting into dsl via vmware should alleviate any possible problems there. Saving to the virtual HD, and then exporting to the real HD after its complete.

I'm thinking it will be less messy this way, and if I screw up i can just delete the virtual HD and start over, perhaps even save snapshots of it at various stages of the process for quicker refining later, or for customizing other dsl restore disks for other machines in the future.

If anyone can think of a reason why this won't work or is a bad idea, feel free to speak up, I just came up with the idea a little while ago.

Of course I'll have to take the dd backup of the MBR from the actual device.

Hmmm... wheels are turning in my noggin.

Thanx again.

------------------
I edited my post a couple posts back to make it more readable. Hope this helps
------------------

Last edited by CyberCod; 03-15-2007 at 11:01 PM.
 
Old 03-16-2007, 02:18 AM   #21
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
Quote:
I'm going to try to make one, using the RIPlinux non-X disk (to start out with). Wish me luck
http://www.tux.org/pub/people/kent-r...looplinux/rip/ says
Quote:
You'll need at least 256MB of RAM and a 486DX CPU
to boot and use it!
have heard of rip, but I thought you had 64 MB RAM
There must be a typo somewhere. A 486 DX with 256 MB?????
 
Old 03-16-2007, 02:41 AM   #22
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
I thought the topic is interesting so I keep looking.
Plus I think the solution must already exist.
(plus I need to do some disaster backups myself one day;
I use dd and rsync and cp to another HD;
I burn /home on a dvd from time to time. But paranoia is good
and paranoia is telling me I do not have a recovery set)

I know many of the utilities / projects by name, but I never
used them so I do not know which are really practical

I had another look at http://mkcdrec.ota.be/introduction.html
There is make test that would tell you if requirements are met.

Here is my thoughts: the problem is disk space and where to create
the iso, low memory, low cpu
So how about using mondorescue? http://www.mondorescue.org/

Mondorescue add to the cd everything to make it bootable
and will skip /proc
on top it can backup nfs mounted partition!
So, you mount the laptop / as nfs as root
and run the whole backup from the desktop, you get only limited by the network and laptop HD speed
Then you can test the bootable cd in qemu or vmware (to some extent because the cpu etc are different, but at least see if it decompress to the right place)
Do not know for sure how mondo behaves with respect to the MBR when backing up the nfs partition; probably you need to do it separately
(dd the mbr to a bootable floppy and make a script that dd it back to the HD seems the simplest)
 
Old 03-16-2007, 02:15 PM   #23
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
While I appreciate all the suggestions for the various projects, I'm getting pretty good progress doing it in the fashion I've planned out. And FIGURING OUT how to do this is as important to me as the finished product.

So to anyone who finds this thread while searching for a restoration solution, there are plenty of suggestions here that you may try, some of which will undoubtably be easier than what I'm doing, so long as you have the resources to use them. But I think that figuring it out from scratch has its merits too. Its good to know whats going on under the hood.



I'm going to try to remaster a DSL disk to do this because the RIP Linux Non-X disk has disappeared from that page, and because there are plenty of DSL remastering instructions around.

For clarifcation, the machine being used has the following specs:

133Mhz Pentium Processor
32MB ram
1.6 GB harddrive
integrated 56k modem
1 USB port
assorted serial, parallel and printer ports
PS/2 port for the mouse
Integrated audio is soundblaster compatible.
two Type II PCMCIA 2.1 Cardbus slots
oh, and a dead battery.

Net connection is being accomplished via a usb wifi card.

Last edited by CyberCod; 03-17-2007 at 01:38 AM.
 
Old 03-16-2007, 07:35 PM   #24
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
I successfully managed to take my backup file and write it into a virtual machine in vmware.

I had to partition the virtual harddrive first, and then I booted up with the dsl live ISO in the virtual CD drive. I mounted the backup folder on the desktop via samba and unpacked the backup as described above to the virtual drive. Then, using an iso of the Ultimate Boot CD, I installed grub.


If anyone is curious what the deskop looks after the customizations I've made to the DSL installation, I've got the following two screenshots.

One is with the wmdrawer extended, and the other shows some of the cusomizations to the fluxbox menu.

http://i32.photobucket.com/albums/d4.../DSLRoslin.png

http://i32.photobucket.com/albums/d4...DSLRoslin2.png

I'm using Rox for the file manager, because I think it will be much easier for her to navigate. Emelfm is still there of course, but not prominently displayed.

I realize that in the grander scheme of Linux desktops, its nothing real special, but for its hardware, its pretty impressive.

Of course with such a small HD I didn't worry about any methods of downloading music, instead relying on Shoutcast for internet radio.
It does manage to run GIMP, which is delightfully surprising.

Firefox is very slow to use, but it will work if you're patient enough and Dillo just won't do the job.

Multi-tasking is seriously out of the question. Its a one-thing-at-a-time machine.

Playing a stream on xmms and even so much as opening a terminal window causes xmms to drag--not stutter--drag...like a vinyl record on the wrong speed.

Playing a nintendo rom on znes is impossible. It takes about two minutes to draw the first frame of the game.


Oh well... I should be grateful that it does what it does.

Last edited by CyberCod; 03-17-2007 at 02:14 AM.
 
Old 03-18-2007, 02:09 AM   #25
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
Ok, Its back to question time.

I've currently got DSL loaded up in VMware with two virtual drives and I'm about to make my first attempt at a restore disk, but I need to know some info on a couple things first.

I'm going to save a snapshot of how it is right at the point before burning so I can swap out other stuff later and make a restore disk like el pronto!

Question 1
Whats the syntax for the command 'grub-install' when you're installing grub to hda? Does it need to know where to find menu.lst? or is menu.lst generated? or what?

Question 2
How does one handle input from questions in a bash script?



Right now I'm in the process of building the first remastered ISO. Its only got the tar portion of the script so far, as that is all I've worked out. Mainly I'm testing to see that my changes are working, and that my remastered dsl is bootable.

If this works, I'll know its time to get busy with the other portions of the script.

I've made some changes to the install since I made the last backup, so I'll be testing this ISO in vmware first, while I make a more up-to-date backup of the real system.

Thanx again for all the help and support!


--------------------
UPDATE
--------------------

I was successful in remastering DSL tonite. In fact, due to different syntax errors in my scripts and learning my way around, i was successful five times in a row.

Of course only the last time gave me the results that I wanted.

I tested the iso by making a clean virtual machine, then installing DSL on it. The next step was to shut down and boot to my remastered ISO. On the final attempt I got it to successfully unpack into the freshly installed DSL system. Rebooting from that I came back up to my modified desktop.

I still have a ways to go to put in the dd stuff with the MBR and formatting commands... and learning how to make those things optional...but this is good progress, and I'll take it.

I will be back tomorrow to document how it was done, but for now it is 5am and I've really gotta get to sleep. This is the hour when I'm usually waking up. Not going to bed.

My head hurts ~(=-0

Last edited by CyberCod; 03-18-2007 at 05:06 AM.
 
Old 03-18-2007, 06:10 AM   #26
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
In LQ bookmark I have posted links to learning bash
Just search for bash

Grub takes the menu from /boot/grub/menu.lst
So you need to create that files; (never tried without; the distro always create one and I have the old one)
 
Old 03-18-2007, 01:51 PM   #27
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
---SUCCESS---

Ok, I ended up taking my remastering instructions from the page below.

http://www.linuxforums.org/desktop/r..._preamble.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 partition 2. 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 size of your backup file and double it, and then add another 150 to 200 megs.

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:
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.

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, open up /hdb1/souce/opt/bootlocal.sh

add the following line to it
Code:
sudo /KNOPPIX/backup/backup.sh
save then open a new file.

Here' where the backup commands come in.

in the new file put the commands:
Code:
clear
echo "Beginning restoration in 3 seconds"
sleep 3

# the next bit is similar to my earlier unpacking commands but
# reflects the new location of the backup file.

mkdir /hda1
mount /dev/hda1 /hda1
cd /KNOPPIX/backup
tar -xvzf hda1backup.tar.gz -C /

# at this point in the script the restore is complete 
# so it is time to reboot
clear 
echo "restoration complete"
sleep 3
echo "rebooting now"
sleep 1
reboot

Ok, once all that is in the untitled text file, in Beaver you need to save it as /hdb1/source/backup/backup.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:
mkisofs -R source | create_compressed_fs – 65536 > newcd/KNOPPIX/KNOPPIX
Code:
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.

Loading my iso up in vmware gives me the results I want, but it doesn't work unless dsl has been installed to hda1 already.

It never comes fully up to X, everything happens just before you'd normally log in on a HD install.

So I've got to work on the dd portion of the script and I'd like to improve the script itself with yes/no options and such.

Thats where I am right now.


I don't think I'll need to know grub after all, I hope that dd will take care of that. My head was just too scrambled last night to remember.

I'll give the bash stuff a good thorough look though.

Thanks again.

Last edited by CyberCod; 03-18-2007 at 05:18 PM.
 
Old 03-18-2007, 03:31 PM   #28
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
it just occurred to me that I could possibly make a permanent partition on hda of the laptop to hold a backup file.

And if I did that, I could make the script handle backing up to it AND restoring from it. So long as the partition was big enough to hold the backup no matter how big it turned out to be.

I wonder what percentage tar.gz can compress.

If it I can find out, and say its like 50%, then I can make the backup partition half the size of the bootable partition and there'd always be room for a backup file.

The restore disk itself could hold a backup file as well for use when the hard-drive has been wiped or the backup partition has been wiped or corrupted and the system needs fixin.

Having the backup script available that writes to a backup partition like this would allow for incremential backups, with a baseline backup on the disk for emergencies.

It would be a stable and easily fixable machine until some sort of hardware failure.

I wonder if this could be added to the mydsl repositories when its perfected....


Hmmm...

It also occurred to me that this need not be just for DSL installations. So long as the backup of the / filesystem on the install is small enough to fit on a cd (or dvd?) with the dsl files needed for the process (which is 50MB) then this would allow anyone to make a customized DSL-based backup disk for any linux installation.

If this ever makes it to the repository, then it would add some really easy and very useful functionality to the already amazing distro DamnSmallLinux.

Last edited by CyberCod; 03-18-2007 at 05:17 PM.
 
Old 03-19-2007, 02:31 AM   #29
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
Quote:
I'd like to improve the script itself with yes/no
see for example http://www.cactus.org/~dak/shellscript.html
and search in page "read ans"

In backup.sh nothing stops you from having the dd command
to restore just the 512 bytes of the MBR.
 
Old 03-22-2007, 06:44 AM   #30
CyberCod
Member
 
Registered: Jul 2006
Posts: 35

Original Poster
Rep: Reputation: 15
It'll take me a little time to digest what is goin on in that little snippet of script, but thanks a lot!!!

It gives me something to go forward from.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
back up and restore disk partitions ekdya Debian 2 10-05-2006 04:43 PM
Restore vfat disk tripmix Linux - Newbie 1 08-25-2006 07:57 AM
Is a restore disk on Linspire possible? mhucek Linspire/Freespire 1 02-03-2005 05:13 PM
Question about Restore Disk??? Typhonian Linux - General 1 04-18-2003 05:00 AM
disk data restore zeky Linux - General 0 08-05-2002 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration