LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to make working copy of failing HDD (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-make-working-copy-of-failing-hdd-809427/)

stoke city 05-22-2010 02:33 AM

Need to make working copy of failing HDD
 
I run a sever 24/7/365 with Debian 5.0.4 (lenny) GNOME 2.22.3. It seems that the HDD is beginning to fail as it starting to clunk & you can hear it spinning up & down.
I had lots of help in setting up the server, and i am not that good with linux...but i am learning all the time ;)
I have a spare HDD lying around, and i am wondering if its possible to use it to make a "exact working copy" of the HDD whats failing ? The spare HDD actually has XP on it, but i cannot see this preventing it from being used ??
As my knowledge is still very little with Linux, and its important for me to replace the HDD, can anyone point me in the right direction to copying failing HDD ?? Also is it possible to then fit the new HDD into my server and it will work straight away ? This is to prevent any added downtime on my 24/7/365 server.. Kindest regards

zeno0771 05-22-2010 03:31 AM

PartImage or the dd command from a liveCD/liveUSB should do the trick.

stoke city 05-22-2010 04:13 AM

Hi mate....many thanks for taking time out to advise me...is there a tutorial anywhere for doing any of these ?? Like i said i am very new to linux ( very slowly migrating from xp ) and it is a bit overwhelming....I am frightened that i screw things up completely and lose all my data on the server..Kindest regards

unSpawn 05-22-2010 05:21 AM

Quote:

Originally Posted by stoke city (Post 3977331)
the HDD is beginning to fail (..) I have a spare HDD lying around, and i am wondering if its possible to use it to make a "exact working copy" of the HDD whats failing ? The spare HDD actually has XP on it, but i cannot see this preventing it from being used? (..) point me in the right direction to copying failing HDD? Also is it possible to then fit the new HDD into my server and it will work straight away?

I. Before you start, as root, run 'fdisk -l'. Save the information elsewhere as it will show you the disk device name in use. How you start off depends on the state of the current disk (called the "victim" drive here), how you attach your new disk (let's call it "target") and what size the target is.
- If the contents of the target don't matter and you can attach it directly using (E)IDE, SATA, USB, Firewire then you can make a direct copy: if the victim resides at /dev/hda and the target is attached at /dev/sda then a direct copy between disks that are equal in size can be done with (as root) with 'dd if=/dev/hda of=/dev/sda'.

II. If the victim is still good (or deteriorating very fast) and you would have no problem spending time replicating the setup then you could save time and only save the important parts while they're mounted. For this scenario you'll need another disk for rebuilding the server though. Again with the victim residing at /dev/hda and the target attached at /dev/sda:
- delete the partiton table on /dev/sda: 'dd if=/dev/zero of=/dev/sda count=1 bs=1M', then
- create a new partition table and one ext2 partition spanning the whole disk: 'fdisk /dev/sda' and press "o", press "n" choose primary, number 1, type "t", change type to "83" (Linux), press "w" then press "q". Now create the filesystem on the disk:
- 'mkfs.ext2 /dev/sda1' and mount it:
- 'mkdir /RESCUE; mount /dev/sda1 /RESCUE' after which you can list the partitions contents with 'ls -al' to verify there's only one directory named "lost+found" and 'df -mh' to check the size matches. Now run
- 'fdisk -l > /RESCUE/fdisk.log' output for recreating the partition table later on, backup directories /etc, /var, /home, /root, /boot (if separate), any data that needs saving while still accessible like mounted, encrypted filesystems, the /var/lib/dpkg package management information and stored information the machine serves up for others (webserver docroot, databases) with
- 'tar -cf /RESCUE/data.tar /etc /var /home /root /boot /var/lib/dpkg' (add any directoies you need).

III. If the victim is deteriorating faster and corruption should be anticipated then you should not waste time and use ddrescue or dd_recue instead (provided the target disk is similar or greater than the victim drive) and it would be best not to power down the server to attach the target but use an external encasing, mount via USB then run 'fdisk -l' again to see where the target is attached (probably /dev/sda unless device name was taken). Wrt dd_rescue create a single partition on the target as outlined under II then see post #16 and post #30 for a commandline example (substitute device names and mount points). The whole thread may actually be interesting to read as PTrenholme and I offer information about ddrescue vs dd_rescue.


* If unsure ask questions before you do anything but only after you've ensured the state of the victim drive still allows you time.

stoke city 05-22-2010 07:03 AM

Hello there.....A lot of that info you provided me has actually gone straight over my head..lol.....However i do have a external USB attached HDD i can use to "copy" the internal HDD drive over to, can i then copy from the external HDD to a replacement internal HDD....It is so important that i have the least amount of downtime possible...would this way be ok ? Also do i need to do this with a monitor and keyboard etc attached to the server, or can i do all this with VNC viewer through my XP based desktop PC ?? Kindest regards to you all

unSpawn 05-22-2010 08:30 AM

Quote:

Originally Posted by stoke city (Post 3977478)
A lot of that info you provided me has actually gone straight over my head

Each command has a manual. Say the command is 'fsck' then you can read the manual with 'man fsck' before you do something to verify things work for you.


Quote:

Originally Posted by stoke city (Post 3977478)
i do have a external USB attached HDD i can use to "copy" the internal HDD drive over to, can i then copy from the external HDD to a replacement internal HDD....

Sure. Note that command as listed in II won't get you a bootable OS but may work faster for you if you can prep a new install in another machine (swap disks or machines). Commands listed in I and III might but that depends on the state of the victim disk. If it's half gone already you should lower your expectations accordingly. If you need to minimize downtime (for whatever undisclosed reasons) then I'd suggest the external USB drive to be as large as the victim drive and use 'dd', 'ddrescue' or 'dd_rescue'.


Quote:

Originally Posted by stoke city (Post 3977478)
It is so important that i have the least amount of downtime possible.

Why? Details?


Quote:

Originally Posted by stoke city (Post 3977478)
Also do i need to do this with a monitor and keyboard etc attached to the server, or can i do all this with VNC viewer through my XP based desktop PC?

You can do this any way you want: at the keyboard, logging in over SSH (use PuTTY in mcrsft), via VNC on about any OS but I'd go for commandline-only: more efficient.


* BTW: posting the 'fdisk' output and commands (in full!) you think you should run allows us to see if it's going to work.

stoke city 05-22-2010 09:28 AM

Hello again everyone.....I can answer your questions......I use my server to run CCcam, this shares my Sky viewing with several satellite receivers ( this eliminates having to get sky multiroom etc ) I also share my card with other satellite enthusiasts across Europe, and they share their card with me...So as you can imagine, as soon as the server stops...The picture also stops !! lol.
My server is running at the moment, but i am playing it safe and making sure that i can copy the failing HDD before it does fail completely...so i am not in any rush to make a copy..
I have just managed to reformat my USB external HDD to type "83" with using putty, and the drive is being shown as /dev/sda

Kindest regards

unSpawn 05-22-2010 10:28 AM

Quote:

Originally Posted by stoke city (Post 3977596)
My server is running at the moment, but i am playing it safe and making sure that i can copy the failing HDD before it does fail completely...so i am not in any rush to make a copy..

Ensuring you can make a copy is meaningless. And are you really sure you're not in a hurry? After all you wrote in your OP:
Quote:

Originally Posted by stoke city (Post 3977596)
It seems that the HDD is beginning to fail as it starting to clunk & you can hear it spinning up & down.

I'd say get it over with before it is game over.

linuxunix 05-22-2010 10:32 AM

Use photorec

tredegar 05-22-2010 10:40 AM

My 2cents:

If it was my server, I'd want to back it up whilst it was not running. Otherwise you might end up with some "file inconsistencies". Eg a file is modified by the OS or a running application after it has been copied, and this might matter when it is restored.

So I'd boot from a live CD, and make the copy from there, being very very careful about which disks I was copying from and to, especially if using the dd ( "doubly dangerous" ?) command.

You will not be able to do this if your server doesn't have a keyboard & monitor.

Another approach might be to remove your server's HDD and put it in a USB-connected enclosure.
Then you will be able to copy it by plugging it (and the disk that is to replace it) into a linux PC with a working screen and keyboard.

Quote:

I have just managed to reformat my USB external HDD to type "83" with using putty, and the drive is being shown as /dev/sda]
It would be unusual for an external HDD to show up as /dev/sda, so please double-check this.

Do you have a local Linux Users Group? This is the sort of thing they are very good at helping with. Are you in the UK (Stoke) ?

stoke city 05-22-2010 04:58 PM

Quote:

Originally Posted by unSpawn (Post 3977653)
Ensuring you can make a copy is meaningless. And are you really sure you're not in a hurry? After all you wrote in your OP:

I'd say get it over with before it is game over.

Yes, i agree....the reason why i say its not that important is because my working cfg file is saved on a USB pen drive, so actually losing all vital data is not going to happen at all....I would like to fix it now as i can see the HDD is going to fail sooner rather than later, and i do not want to feel pressured into fixing it when it fails..This will mean the server will probabaly be offline all day, and this will probably happen when the wife want to watch something really good on sky one ! This will only lead me into a ear bashing from her ! lol So its a case of prevention is better than cure, and doing it now will say when I want to fix it..not when the server demands it...Kindest regards

stoke city 05-22-2010 05:11 PM

Quote:

Originally Posted by tredegar (Post 3977667)
My 2cents:

If it was my server, I'd want to back it up whilst it was not running. Otherwise you might end up with some "file inconsistencies". Eg a file is modified by the OS or a running application after it has been copied, and this might matter when it is restored.

So I'd boot from a live CD, and make the copy from there, being very very careful about which disks I was copying from and to, especially if using the dd ( "doubly dangerous" ?) command.

You will not be able to do this if your server doesn't have a keyboard & monitor.

Another approach might be to remove your server's HDD and put it in a USB-connected enclosure.
Then you will be able to copy it by plugging it (and the disk that is to replace it) into a linux PC with a working screen and keyboard.



It would be unusual for an external HDD to show up as /dev/sda, so please double-check this.

Do you have a local Linux Users Group? This is the sort of thing they are very good at helping with. Are you in the UK (Stoke) ?

Hello there....i am beginning to think that backing up the server is the better option with it not running...good idea
I also have got a spare keyboard and monitor available too do such a job.
With reference to fitting the servers HDD into an enclosure, thats not possible as all my external HDD's are using SATA within them, and my servers HDD is IDE...but its a good idea, and if i could do so i would use it.
If i managed to format the external HDD via putty, and the OSD showed i was doing it ok by entering /sda for the locaton of the external HDD, surely it must be ok ??
Also i am not aware of any local linux groups at all....And i do live in Stoke.......can anyone possibly help me complete my task ??? Kindest regards

tredegar 05-23-2010 01:49 AM

Quote:

With reference to fitting the servers HDD into an enclosure
Maplin have adapters for £20, but I have seen them for £13 or so.
A competent person will not need a USB enclosure, just a live CD, KBD, monitor and new HDD
Quote:

And i do live in Stoke
Then maybe try: http://www.staffslug.org.uk/

Offer beer ;)

AwesomeMachine 05-23-2010 04:24 AM

See this post: http://www.linuxquestions.org/questi...ommand-362506/

pierre2 05-23-2010 07:49 AM

Depending on the actual size of the server's hdd,
which would indicate just how long the cipy process would actually take,

what I would do is shut down the sever & boot the PC from a rescue-linux cd,
& run Gparted. Using that to perform a image copy disk - disk,
from the old/failing hdd to the new hdd, erasing anything on the new disk, in the process.

This would give a exact copy of the old disk & would also be bootable in the same way.

as the op is not linux literate, this way is a GUI & more achievable.


All times are GMT -5. The time now is 02:56 PM.