LinuxQuestions.org
Review your favorite Linux distribution.
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 05-22-2010, 02:33 AM   #1
stoke city
LQ Newbie
 
Registered: Oct 2009
Posts: 16

Rep: Reputation: 0
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
 
Old 05-22-2010, 03:31 AM   #2
zeno0771
Member
 
Registered: Jun 2006
Location: Northern IL
Distribution: Arch64
Posts: 106

Rep: Reputation: 19
PartImage or the dd command from a liveCD/liveUSB should do the trick.
 
1 members found this post helpful.
Old 05-22-2010, 04:13 AM   #3
stoke city
LQ Newbie
 
Registered: Oct 2009
Posts: 16

Original Poster
Rep: Reputation: 0
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
 
Old 05-22-2010, 05:21 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by stoke city View Post
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.
 
1 members found this post helpful.
Old 05-22-2010, 07:03 AM   #5
stoke city
LQ Newbie
 
Registered: Oct 2009
Posts: 16

Original Poster
Rep: Reputation: 0
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
 
Old 05-22-2010, 08:30 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by stoke city View Post
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 View Post
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 View Post
It is so important that i have the least amount of downtime possible.
Why? Details?


Quote:
Originally Posted by stoke city View Post
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.
 
1 members found this post helpful.
Old 05-22-2010, 09:28 AM   #7
stoke city
LQ Newbie
 
Registered: Oct 2009
Posts: 16

Original Poster
Rep: Reputation: 0
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
 
Old 05-22-2010, 10:28 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by stoke city View Post
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 View Post
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.
 
1 members found this post helpful.
Old 05-22-2010, 10:32 AM   #9
linuxunix
Member
 
Registered: Mar 2010
Location: California
Distribution: Slackware
Posts: 235

Rep: Reputation: 18
Use photorec
 
1 members found this post helpful.
Old 05-22-2010, 10:40 AM   #10
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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) ?
 
1 members found this post helpful.
Old 05-22-2010, 04:58 PM   #11
stoke city
LQ Newbie
 
Registered: Oct 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
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
 
Old 05-22-2010, 05:11 PM   #12
stoke city
LQ Newbie
 
Registered: Oct 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by tredegar View Post
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
 
Old 05-23-2010, 01:49 AM   #13
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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
 
1 members found this post helpful.
Old 05-23-2010, 04:24 AM   #14
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
See this post: http://www.linuxquestions.org/questi...ommand-362506/
 
1 members found this post helpful.
Old 05-23-2010, 07:49 AM   #15
pierre2
Member
 
Registered: May 2009
Location: Perth, AU
Distribution: LinuxMint
Posts: 388
Blog Entries: 9

Rep: Reputation: 88
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.
 
1 members found this post helpful.
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
if any utility available for copy one HDD to two more HDD simultaneously? mdfakkeer Linux - General 3 02-07-2010 06:07 AM
DD to backup failing HDD jmoschetti45 Linux - General 4 02-02-2010 10:30 PM
HDD Failing johnny121 Linux - Hardware 3 11-25-2009 08:20 PM
Anyone know of a readily available hdd to hdd copy utility? lumix Linux - Software 1 03-29-2007 11:57 AM
Failing hard drive--need to copy Phathead Linux - Hardware 2 03-10-2004 12:59 PM

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

All times are GMT -5. The time now is 04:15 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
Open Source Consulting | Domain Registration