LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 12-16-2016, 02:00 AM   #1
bobsie
Member
 
Registered: Apr 2013
Posts: 52

Rep: Reputation: Disabled
HDD problems; how to "clone" it for replacement


I have an Acer laptop with a 1TB Toshiba HDD, 2.5" 5400 rpm.
I am now running Xubuntu 16.10

For months I have experienced problems with the hard drive. I have run the SMART tests and they do not reveal any defects. At random times, a few days to a few weeks apart, I suddenly find that I have a "read-only file system", and therefore everything stops working. I cannot do a normal shut down because of the unwritable disk, so I kill it and of course it will not boot. In the past I had to boot from a CD, but now it starts a Busybox shell when it finds it can't read the disk, and so I can do fsck and watch it find hundreds of orphaned nodes and lots of other problems, all of which it eventually manages to fix. After that I can just boot the thing normally and all is well - until next time.

question 1: what could possible be causing this? can it be fixed? is my data at risk (I assume yes)

question 2: assuming it is not fixable, I need to replace it. I plan to buy a new hdd of equal capacity and an external USB drive caddy in order to copy every byte of the internal drive to the new one - that is to "clone" it. In the past I think dd has been recommended for this. I know that I have done it before using cp, but had a lot of problems because it did not copy the hidden files. Do I have to partition the new drive and then copy each partition individually? Is there a way to clone the whole drive with a single command (and then go to sleep while it does it). Can someone please advise the best way to do this?
Thanks!
 
Old 12-16-2016, 02:27 AM   #2
TheEzekielProject
Member
 
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
First, a note: Don't use dd to copy a mounted system, boot from a live distro on a usb stick

Assuming /dev/sda is your source and /dev/sdb is your destination

Code:
dd if=/dev/sda of=/dev/sdb bs=4M status=progress conv=noerror,sync
This will make a bit by bit copy.

Things to note: Those issues sound indicative of "ungraceful" shutdowns e.g. unexpected power loss. A new disk will do exactly the same thing if it faces the same conditions.

If SMART doesn't find anything wrong with it, and you have the same problems with a new disk, I'd check your power source.

Also you can always try to
Code:
mount -o remount,rw /device
 
Old 12-16-2016, 03:34 AM   #3
bobsie
Member
 
Registered: Apr 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
Unexpected power loss? It's a laptop. It has a battery so it doesn't lose power. But I have many times had to just force a shutdown because the system will not let me log out without writing to disk. Usually I don't shut it down because it takes a very long time to boot; I just suspend it.

I think there is something wrong with the disk because it is also extremely slow to read files. 3-5 times slower than it used to be when it was new, and the slowdown was abrupt, not gradual.

Yes I have tried a remount, but since the disk is full of errors it just goes back to read-only again as soon as it tries to write anything.

Thanks for the dd command. I will be using it when I get the new disk.
 
Old 12-16-2016, 02:50 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Tests.
Run the OEM hard drive diags.
Run Memtest for a few days.

Cloning is a tricky issue. We don't know the state of your hard drive anymore. It may be worth it to use a backup for data. Maybe for tips on what was installed. I tend to just reload. Makes it more likely in my opinion that all is correct.

A number of ways to clone also. Many people use clonezilla, redobackup, (programs in your repos), gparted, partimage, g4u, rsync, cpio, tar and others along with dd command. Each has good and bad to them.
 
Old 12-17-2016, 04:23 PM   #5
WFV
Member
 
Registered: Apr 2012
Location: somehow, somewhere
Distribution: Arch
Posts: 197

Rep: Reputation: Disabled
Quote:
Originally Posted by The EzekielProject View Post
First, a note: Don't use dd to copy a mounted system, boot from a live distro on a usb stick

Assuming /dev/sda is your source and /dev/sdb is your destination

Code:
dd if=/dev/sdX of=/dev/sdY bs=4M status=progress conv=noerror,sync
This will make a bit by bit copy.
whereas X is the original disk, and Y is the disk being copied to, use lsblk to get the correct /dev/sd? information.
I've heard that dd'ing a bad drive makes an exact copy including the errors even though the new drive isn't "bad" but don't know if that is true and anyway, the type of errors mentioned here should be fine with a dd copy. Be prepared for it to take a few hours, be patient, the
Code:
status=progress
is your friend
I always use dd for a new drive and rsync for backups
 
Old 12-18-2016, 01:42 PM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
source -> destination, everything is source -> destination. good rule of thumb to remember.
 
Old 12-18-2016, 07:11 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
dd is the absolute worst option. Maybe ddrescue in really dire circumstances, but I would never use dd.

I would use a filesystem-aware tool - any of the above mentioned would suffice. That way you get to know about which file(s) may be suspect.
Much better option would be to simply restore your latest (known good ?) backup. I guessing that is a forlorn hope.
 
Old 12-18-2016, 09:05 PM   #8
bobsie
Member
 
Registered: Apr 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
I think I have not been clear enough about this problem. Right now there is nothing whatever wrong with my file system - everything is normal. But sometime soon, in a few days or weeks, seemingly quite at random, I will suddenly find again that I have a read-only file system. The only thing I can do then is shut down, and then boot up without mounting any partitions. Then I run can fsck and tell it to fix every error automatically, and after a few minutes it completes and tells me that all partitions are clean. At that stage I can boot the system normally and all is well - until next time, whenever that will be.

I don't know if there is anything physically wrong with the disk. Testing has not revealed anything, and it works normally until the the next event. But what can be the cause, other than the disk itself? I must find the problem and fix it, or replace the computer - an expensive one. My plan is to replace the drive with a new one. That is the sole purpose of cloning it. I want to replace the disk with minimal disruption, and if I can clone the disk so that byte-for-byte identical with the old one that should achieve my objective.
 
Old 12-19-2016, 05:32 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
so if your disk is really ok, you can try to dd (see post #2) the content from this one onto another (bigger?) one and try to boot from the new disk. Probably it will work, and if not you can still use your old disk. Later you can resize the partitions to use the full disk.
 
Old 12-19-2016, 05:34 AM   #10
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Wouldn't rsync also work? It is used for back ups
Because it basically just makes a copy of whatever it is working on.

Last edited by BW-userx; 12-19-2016 at 05:37 AM.
 
Old 12-19-2016, 05:38 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
rsync is unable to copy data outside of a filesystem, like partition table, MBR and similar.
 
Old 12-19-2016, 06:07 AM   #12
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
I question this.

If OP is going to clone his system. Then Why? The most important items that will need to be taken off the hdd that is failing is his data. The OS itself is not all that important. A simple installing of the same OS onto a different HDD would be the simplest and probably the fastest method to use. He'd only have to ensure that he gets all of his modified conf files out of the system side so he can avoid having to modify them again.
 
Old 12-19-2016, 05:18 PM   #13
WFV
Member
 
Registered: Apr 2012
Location: somehow, somewhere
Distribution: Arch
Posts: 197

Rep: Reputation: Disabled
Not sure why dd is worst option, I've been using it without issues for the past 6 yrs - seems to work very well, but takes patience to let it do what it does and it is byte for byte, its actually bit for bit.
Installing a new OS can take as long or longer than DD considering adding all the extra applications and peripherals back in. DD gives you everything. It even copies the disk UUID, keep that in mind if you want to use the new disk UUID as two of the same may have problem being connected to same computer when finished. You can always change the UUID, but get it before you DD the new disk. DD before going to bed, have an OS in the morning without having to do anything else aside from removing old drive - just pray the power doesn't cycle during the process
I've dd'd Windows XP disk and booted new disk without issue - W7 different story, it worked but had to do a lot of system tweaking...

Last edited by WFV; 12-19-2016 at 05:22 PM.
 
  


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
[SOLVED] Using Clonezilla to clone HDD that has an "EISA Configuration" Partition austinium Linux - Newbie 19 03-01-2011 03:28 PM
Does mounting HDD with "flush" & "sync" have any real use? Mr. Alex Linux - Hardware 1 02-03-2011 03:46 AM
Need solution to "failed to fork PTY" and "error creating the child process" problems Gnusboy Linux - Newbie 4 01-02-2010 07:54 AM
k3b: To choose "normal" or "clone" copying grautu Linux - Software 1 01-09-2006 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 12:58 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