LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-19-2004, 08:01 PM   #1
Irf
Member
 
Registered: May 2004
Posts: 30

Rep: Reputation: 15
Hard disk backup/copy....


Hi all,

This is the scenario: I have a dual boot file server which has recently been made Samba capable. The intention is to abandon Windows and stick with Suse9 on this machine.

I need to swap the HD, because the original one makes strange noises occasionally and sometimes PC activity freezes for minutes. I bought a new drive and tried to use Norton Ghost to copy across the whole disk. The new disk won't get past a screen where just GRUB is written all across the screen. I'd guess that the boot sector didn't make it across, though in my case there was lovely sun and greenery outsi. Let me know what I have to do to get GRUB loading and running un
 
Old 05-19-2004, 11:03 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,589

Rep: Reputation: 187Reputation: 187
" I bought a new drive and tried to use Norton Ghost to copy across the whole disk."

If the new disk and the old disk have different geometries then a direct disk copy will cause you all kinds of problems, grub just being the first of many.

So, partition the new disk. Format the file systems on the new disk. Use mkswap to format the swap partition on the new disk.

Now boot a rescue CD and copy every partition except swap using a command sequence similar to this:

mkdir /sparrow
mkdir /oriole
mount -t ext3 /dev/hda1 /sparrow
mount -t ext3 /dev/hdb1 /oriole
cp -pR /sparrow/* /oriole
umount /sparrow
umount /oriole

Now you have everything set up on the new disk except the MBR. Remove the old disk and install the new disk as /dev/hda. Boot a rescue CD and:
mkdir /crow
mount -t ext3 /dev/hda1 /crow
chroot /crow
grub-install
shutdown -r now

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Last edited by jailbait; 05-19-2004 at 11:47 PM.
 
Old 05-20-2004, 07:00 AM   #3
Irf
Member
 
Registered: May 2004
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks jailbait.

Because I'm a newbie to Suse (and Linux in general), could I get an explanation of what you're suggesting. It would help me learn!

It seems to me that your 1st procedure copies all the stuff (directory-by-directory) from the old drive to the new drive... is that correct? I assume that sparrow and oriole (and others as necessary) are the directories on the original disk that I'd need to replicate on the new one. I got a little lost in the 'mount' commands....!

Is it possible to allow Suse to boot fully (on the old drive) and then drag and drop the appropriate folders across to the new drive? Perhaps then I could sort out the MBR as in your 2nd procedure?

It's just that being a newbie I'm less than confident with command line work....

Thanks.

Irf.
 
Old 05-20-2004, 11:33 AM   #4
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,589

Rep: Reputation: 187Reputation: 187
"Is it possible to allow Suse to boot fully (on the old drive) and then drag and drop the appropriate folders across to the new drive? Perhaps then I could sort out the MBR as in your 2nd procedure?"

Yes. I originally wrote the instructions that way. Then I realized that my instructions would get you into a recurtion copying /sparrow over and over. But you could do so by copying (or dragging) directories instead of copying /. If you are using your SuSE system instead of a rescue CD then you only need the mountpoint for the new disk partition. You only need to mount the new disk partition. You create the mount point (either from the command line or from konqueror) and mount the new partition from the command line. Then you can drag and drop the main directories, /boot, /etc, and so on. You have to create mount points and mount and copy every partition except swap. Do you have more partitions than just / and swap?

"It seems to me that your 1st procedure copies all the stuff (directory-by-directory) from the old drive to the new drive... is that correct?"

Yes.

"I assume that sparrow and oriole (and others as necessary) are the directories on the original disk that I'd need to replicate on the new one. I got a little lost in the 'mount' commands....!"

When you mount something you have to mount it on an empty directory. I just created the various bird directories as throw away mount points. Another thing you need to watch is that the mount file system type must be correct. I used ext3 in my examples but you may or may not be using ext3.

"It's just that being a newbie I'm less than confident with command line work...."

Probably the only things that you have to do from the command line are the mounts and the rescue procedure to fix the MBR.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Last edited by jailbait; 05-20-2004 at 11:35 AM.
 
Old 05-20-2004, 12:56 PM   #5
Irf
Member
 
Registered: May 2004
Posts: 30

Original Poster
Rep: Reputation: 15
Cheers mate,

I think I get it now.... does this sound OK?

- Disconnect old disk.

- Wipe my current (Ghost) copy effort, perhaps with a DOS FDISK. Use FDISK to set up the Windows partition on the new HD.

- Reconnect old disk.

- Use GHOST to copy the Windows partition from the old to the new disk.

- Disconnect old disk.

- Boot from the Suse DVD and proceed to install from new.

- Get as far as defining the partitions (after the FAT32 one), and create the root and swap partitions (all I have on the old Suse installation). By the way I think my file system is Reiser

- Allow the installer to format my new partitions (I know this happens with Mandrake at this stage, but not sure about Suse - we'll see).

- Quit the installation process after this point, before setting up apps.

- Connect my old disk as well and boot into Suse.

- Mount the new disk into a new folder as you suggest.

- Drag and drop everything from the old / into the new /.

- Disconnect old disk.

- Reboot from the Suse DVD and get into into repair mode.

- Install GRUB as you suggest.


WOW ! What a song and dance. Anyway, is my understanding correct, and would my process work? Have I got all the nuggets of knowledge I need, or are there more you need to throw my way?

Many, many thanks for you help so far mate!

Irf.
 
Old 05-20-2004, 04:35 PM   #6
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,589

Rep: Reputation: 187Reputation: 187
"is my understanding correct, and would my process work?"

Yes. The only step that you are missing is to physically move the new disk to its permanent location just before:

"Reboot from the Suse DVD and get into into repair mode."

The only unneccesary steps that I see is that you disconnect the old disk oftener than you need to. I guess that you are doing that to make sure that you don't accidently clobber it.

"Use GHOST to copy the Windows partition from the old to the new disk."

You introduced Windows into the discussion for the first time. I have no idea whether you can successfully copy a Windows partition this way or not. I don't know much about Windows.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 05-21-2004, 09:25 AM   #7
Irf
Member
 
Registered: May 2004
Posts: 30

Original Poster
Rep: Reputation: 15
Yes you're right - the reason I've got so many instances of removing and reconnecting the original drive is that I once had a very bad experience where all my data was lost!

Anyway I had to use the Suse setup program to delete the old partitions on the destination drive and create the new ones, because FDISK couldn't do it.. However Suse is different from Mandrake in that the partitions are NOT formatted immediately after creation. Instead it appears that this may occur when the installation of the files is carried out. So, I had to retry with Mandrake 9, which did the job fine including the formatting.

Sorry about not mentioning Windows earlier - I though I alluded to it when I mentioned a dual boot system, but I was not clear on that.

OK, I spent hours last night, and finally gave up 'my method' because it appeared to be impossible. At the drag and drop point I kept getting a message telling me that I could not copy the files onto themselves. Clearly I messed up with the mounting, although I honestly thought I understood and did it right!

So I turned to your (expert) instructions. It worked great, you'll be pleased to hear, until the last hurdle. When it came to booting in Rescue Mode and then trying to mount the drive in the new directory I got a message like this:

"Wrong fs type, bad option, bad super block on /dev/hdb2, or too many mounted file systems (aren't you trying to mount an extended partition, instead of some logical partition inside?).

The reason I'm using hdb2 is that the disk is configured as IDE slave, and also because the directories I copied with your instructions all went into this device..... hdb1 contains Windows.

Does this mean anything to you or anyone? Any ideas?

Thanks,

Irf.

Last edited by Irf; 05-21-2004 at 09:30 AM.
 
Old 05-21-2004, 10:52 AM   #8
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,589

Rep: Reputation: 187Reputation: 187
"The reason I'm using hdb2 is that the disk is configured as IDE slave, and also because the directories I copied with your instructions all went into this device..... hdb1 contains Windows."

On the new disk the /etc/fstab and /boot/grub/grub.conf files are set up for your disk being on /dev/hda. grub-install will try to install the boot loader to the MBR on /dev/hda. You should move the new disk to /dev/hda before you go into fixing the MBR.

"Wrong fs type, bad option, bad super block on /dev/hdb2, or too many mounted file systems (aren't you trying to mount an extended partition, instead of some logical partition inside?)."

The commands should look like this after you move the disk to /dev/hda:
mkdir /pigeon
mount -t reiserfs /dev/hda2 /pigeon
chroot /pigeon
grub-install
shutdown -r now

I am assuming that you formatted /dev/hdb2 as reiserfs:
mkreiserfs /dev/hdb2
If you formatted /dev/hdb2 without specifying a file system type then the default is ext2. In that case your mount command should be:
mount -t ext2 /dev/hda2 /pigeon

(Actually you formatted /dev/hdb2 with the Mandrake installer so if the file system type is wrong then that is where the error ocurred. I am not certain but I think that the Mandrake installer uses a default file system type of ext3 so try mounting /dev/hdb3 as ext3.)
___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Last edited by jailbait; 05-21-2004 at 11:02 AM.
 
Old 05-21-2004, 12:20 PM   #9
Irf
Member
 
Registered: May 2004
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
On the new disk the /etc/fstab and /boot/grub/grub.conf files are set up for your disk being on /dev/hda. grub-install will try to install the boot loader to the MBR on /dev/hda. You should move the new disk to /dev/hda before you go into fixing the MBR.
Ah, that makes sense then - I'll try that when I get home.

I did format to reiserfs, but not using the command line instructions you have listed. I used the Mandrake setup program to partition and format the disk. The default fs in Mandrake is ext3, but when creating the new partitions I made sure they were created and formatted to reiserfs.

Thanks for the pointers and I'll let you know how I got on....

Irf.
 
Old 05-21-2004, 03:01 PM   #10
PGDubbin
Member
 
Registered: May 2004
Location: NJ - USA
Distribution: Gentoo on 2.6.6
Posts: 39

Rep: Reputation: 15
Sorry but all these methods seem a bit redundant to me.

simply boot to a live CD (Morphix will suffice)

mount the disk you want to backup, and tar the entire disk with the -p flag (to preserve permissions)

When you are done, mount the other disk drive, and untar with the -p flag again (-zxvpf) update your root drive so it knows to look at the new disk, reboot and enjoy.

that method took me 30 minutes round trip on my PC (for specs see below) - about 9 gigs of data

Last edited by PGDubbin; 05-21-2004 at 03:02 PM.
 
Old 05-22-2004, 05:57 PM   #11
Irf
Member
 
Registered: May 2004
Posts: 30

Original Poster
Rep: Reputation: 15
Well this is still bubbling on..... I haven't managed to do the copy properly so that the system boots with GRUB. Trying to do the grub install is failing, and I'm getting desperate now!

However, the good thing is that I'm learning a lot about command line and how linux works...

PGDubbin: Would you mind explaining some of your suggestions?

I have a Knoppix CD - I guess that would be OK?

When you say mount the disk I want to backup, do you mean to a new directory like jailbait explained? So could I try this:

mount -t reiserfs /dev/hda /directory

Or should the device have a number after the hda? If that is the case, then doesn't that mean I've mounted that partition only?

But what does "tar the entire disk" mean? Could you supply instructions?

Then mount the other disk in the same way as above? Then how do I untar?

And what do you mean by "update the root drive"?

Sorry for all the questions, but I am a noob trying to find my way through a disk upgrade while retaining the ability to use both Windows and Linux.

Many thanks,

Irf.

Last edited by Irf; 05-22-2004 at 06:01 PM.
 
Old 05-22-2004, 06:52 PM   #12
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,589

Rep: Reputation: 187Reputation: 187
"When you say mount the disk I want to backup, do you mean to a new directory like jailbait explained? So could I try this:

mount -t reiserfs /dev/hda /directory

Or should the device have a number after the hda? If that is the case, then doesn't that mean I've mounted that partition only?"

You are actually mounting a file system. /dev/hda does not have a file system on it so /dev/hda is not mountable. The partition /dev/hda1 has a file system on it so it /dev/hda1 is mountable.

An example of a mountable device is /dev/fd0. A floppy is mountable because it has a file system on it. A tape is not mountable because it does not have a file system on it.

See:
man mount

"But what does "tar the entire disk" mean? Could you supply instructions?"

tar concatenates files into one large file called a tarball. Optionally you can compress the files when you create a tarball. Then later you can untar the tarball and restore the files. People usually use tar with compression for backup and recovery but you could use tar to create a tarball of your entire old / partition and then untar it onto the new / partition. See:
man tar.

One of the people I was helping copy partitions around was having trouble preserving permissions. Everything ended up belonging to root. He solved the problem by using tar instead of cp thus bypassing some permissions problem with cp that was peculiar to his system.

However tar will not do partitioning, file formatting, nor copy the MBR.

"Then mount the other disk in the same way as above?"

Yes. tar will only work on mounted file systems. It accesses tapes as a file within a mounted file system.

"Then how do I untar?"

The -x parameter tells tar to extract files from a tarball. The -c parameter tells tar to create a tarball.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Last edited by jailbait; 05-22-2004 at 06:56 PM.
 
Old 05-22-2004, 08:12 PM   #13
PGDubbin
Member
 
Registered: May 2004
Location: NJ - USA
Distribution: Gentoo on 2.6.6
Posts: 39

Rep: Reputation: 15
I used morphix and did the following

# sudo mount /dev/hda1 /directory

/dev/hda1 is the drive to backup
/directory is a random folder I created

# sudo tar -zcvpf

specifly the correct locations for the tar file to be created, and what is being tared (something like /directory/*)

mount the new harddrive where you want the stuff to go (assuming it's already partitioned and awaiting data)

# sudo tar -zxvpf (blah blah blah)

The next part of this envolves the following:

chroot, updating the environment and updating the source

I run gentoo for that I used the following, I'd imagine you'd need a different set of commands, I cannot help you here:

Reboot, switch from Morphix Live to Gentoo Live CD
# mount /dev/hda1 /directory
# chroot /directory /bin/bash
# env-update
# source /etc/profile
Reboot with no live CD's confirm master/slave settings, and you should be good to go.
 
Old 05-23-2004, 01:33 AM   #14
Irf
Member
 
Registered: May 2004
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks for your explanations guys, though I must say I'm still a little bit unclear on one or two things.

Overall though, it seems that using tar is a bit like creating a zip file in Windows.... would that be a reasonable analogy?

Tar allows me to take great chunks of files (and sub-directories?) and roll them into one super-file. I can then un-tar them wherever I want.

However tar cannot do the partitioning and MBR work I need. Jailbait: You mentioned this, but what did you mean by "file formatting"? Did you mean formatting the partition?

So considering all my previous attempts have failed, how does the following sound:

Remove the original disk and carry out a fresh and minimal install from scratch on the new disk. Reconnect the old disk and boot from it, but keeping the new one connected. Tar the old file systems - hda5 and hda6 only I think (one of those is the swap.... is this needed?). Mount the file systems on the new disk. Overwrite the existing file systems with the un-tars created from the old file systems.

Would this work?

I've tried all sorts of things so far without luck: Norton Ghost, Windows PartitionMagic, carrying out the copying within Linux. The last suggestion from jailbait got me the furthest, but I'm not sure the copying was complete. When checking some of the directory contents (/boot for example) on the destination disk there were less files. Perhaps that's why the grub-install failed?

Any observations on my suggestion or other ramblings?

Thanks,

Irf.

Last edited by Irf; 05-23-2004 at 01:38 AM.
 
Old 05-23-2004, 02:29 AM   #15
PGDubbin
Member
 
Registered: May 2004
Location: NJ - USA
Distribution: Gentoo on 2.6.6
Posts: 39

Rep: Reputation: 15
I'm a hair confused.

Situation: You have a (more or less) complete, working system installed on a single HDD. You want to take this entire system, and move it to a new HDD.

Is that correct?

I'm going to assume the following:

/dev/hda1 is the location of the data, the "system" if you will
/dev/hda5 is the swap location assuming you have swap

You will need to do the following:

First off, you have a new HDD I presume?

Lets say your old HDD looked like this (for giggles)

hda1 = 25gb
hda5 = 5gb

- Install your new HDD (I'm going to call it 30gb total in size), this new install we'll place on the slave of your IDE0 controller, so it is now /dev/hdb
- Boot your system using a live CD, do not try and tar the system while running it, everything should be done from a live CD.
- We need to make hdb "look like" hda so we'll do the following

# sudo fdisk /dev/hdb

you will now be in the fdisk program, enter m to get a view of the menu, we will only use a handful of these flags and what-not

First things first "p" - this will display what, if anything is on your new HDD (/dev/hdb). If anything is present - wipe it off this is envoked via "d" (easy huh?)

Okay, now that your new HDD is clean, we need to make 2 (maybe just 1?) partition, one for data, one for swap. This is your game now, figure out how much space you want for them and do the math.

n - will create the new partion, give it the number "1" and it will create /dev/hda1 partition.
n - create a 2nd partion with remaining space, or ignore this step if you have no need for swap and just expand the entire disk to hda1

If you created one as swap, enter m and change the type of the partition to a linux swap partition. Play around with this program, you wont officially "do" anything to the disk until you enter this next command

w - this will do everything you configured in fdisk (Ah crap, I screwed up!! - big whoop, hit "q" and start over.

Now you have hdb1 setup (yay!) Format time! (I'd like to just point out, that some of this stuff you'll need to make decisions on, so just use my description as a general setup guide unless of course it's the same - rock on then)

format time

# sudo mke2fs -j /dev/hda1
This will create an ext3 (-j flag makes ext3 if you exclude the -j it will be ext2) on your new partion
# sudo mkswap /dev/hda5
This will create the swap format on the other partion (again, ignore this if you dont plan on swap).

Assuming all this has worked thus far, you should now have this in your computer:

/dev/hda1 - All your data
/dev/hdb1 - Blank HDD awaiting data

...

Now lets tar...

# sudo mount /dev/hda1 /olddirectory
# sudo mount /dev/hdb1 /newdirectory
# cd /newdirectory
# sudo tar -zcvpf backup.tar.gz /olddirectory/*
That is the structure of the tar command - it will tar the entire hda1 system to whatever location you specify, here I used /newdirectory by cd'ing over to it and created a file called backup.tar.gz

(Long wait)

Assuming no errors, you now have a huge tarball sitting on /dev/hdb1, go to where it resides and now do the following:

# sudo tar -zxvpf
This will untar the file onto the new system, CD over to what root should look like I'd assume it'd just be /newdirectory if all goes well (meaning, inside that folder, should look exactly like your old PC - It does? great!)

# sudo chroot /newdirectory /bin/bash
# cd /
# ls
After running ls it should look the same as your PC has always looked, almost like you're not even running the live CD.

# exit
# reboot

remove the CD
power down
open the case, and switch master/slave on your disks (hda and hdb)
reboot

Enjoy life

Now, go into all those commands, and read the man and info pages - you'll learn quite a bit. I've just always hated when people told me years ago, "Read the man, read the info, rtfm, blah blah..." and never bothered to answer a question.

I hope this helps you.



Edit:

The reason I trust this method, I've done it about 3 times in a week on my system. To make a long story short, I had a 250watt power supply, 3HDD and a burner. When my updatedb cronjob kicked in - forget it, the powersupply couldn't keep up, I cooked all 3 drives one at a time, killed a 30 gig, 15, and 13 gig. Lucky for me, I had a backup of my home directories on another 15 gig drive, as well as pictures, and random stuff, notes, scripts, stuff like that. I moved all that data to two 5gb drives, upgraded to a 400 watt power supply, and rebuilt the system on the 15gb backup drive and now use the 5 gig ones as backup and file storage. Unfortunately for me (fortunately?) I know all about this failing HDD situation

Last edited by PGDubbin; 05-23-2004 at 02:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard disk partition copy elmu Linux - Hardware 1 11-10-2005 09:31 AM
make exact copy of a hard disk in fedora AQG Linux - Hardware 6 08-07-2005 05:11 PM
Make a copy of entire hard disk jeucken Linux - Software 1 03-22-2004 05:55 AM
LAN backup to a removable hard disk chakkerz Linux - Networking 3 12-16-2003 07:11 PM
How to make an exact copy of a Hard Disk danishmr Linux - General 15 11-10-2003 02:48 AM


All times are GMT -5. The time now is 02:32 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration