2

One of the HDs in our Linux Mint computer has been behaving strangely (see at the end of the post, but it's not relevant) so we have decided to replace it. I would appreciate some advice on how to do it. The disk (1TB) has two partitions, a small one for /var and another one for /home that takes up most of the disk (both are ext4, only the second one had errors). We have another disk with /boot, /, and swap that would stay in place.

So the question is: what steps are needed to replace the disk with another one (possible larger), with minimal software reinstall/configuration? Starting with the backups... does it suffice to log into Mint and copy from there, or is it advisable to do it from GParted Live, for example? I guess that most software files and config is in the partitions we are leaving in place, so we don't have to worry about that, but if you think this may be an issue please comment on it... some of the software was a pain to install (not just getting things from repos) and we strongly want to avoid repeating that.

The strange behaviour of the disk (maybe not so strange after all) comes down, in the end, to using several times the following command from a GParted Live USB:

e2fsck -f -c -c -k -C 0 /dev/sdb5

and finding more badblock errors each time; the last one we got 244/0/0 and several files with multiply-claimed blocks, that gave further reading errors when answered "yes" to the question of cloning the blocks. Maybe the HD can still be usable, but we'd rather not risk losing data.

Thanks a lot

0

You can clone your old HD by using another machine. Remove the old HD from the original computer, and connect both new and old HDs to another Linux machine via SATA cable. Then boot this machine and ensure it recognizes both drives. Copy the content of the old HD (let's assume is /dev/sdb) over the new HD (/dev/sdc):

cat /dev/sdb > /dev/sdc  

Note the use of cat instead of the canonical dd. Not only cat is perfectly able to handle binary streams (at least in all modern Linux distros), but it'll also choose the optimized blocksize for the copy, so the copy will be faster. In terms of reliability, it's as reliable as dd.

Once the copy is finished, you can install the new HD on the original machine and it'll work immediately; all your software and data will be there. There will be a blank space at the end of the disk since the new HD is bigger, so you should use a partitioning tool (e.g. Gparted) to create a partition in it and then format it.

(Note: text taken from my answer from How to move OS image on a device to another device? . The present question can't be marked as a duplicate of the linked question because the latter has no upvoted or accepted answer.)

  • Would cat give problems with those files that contain bad blocks that I couldn't fix? – David Sevilla Apr 24 '17 at 14:03
0

Well, in the end instead of dd as suggested in another answer I found out about ddrescue and so...

  1. Installed http://www.system-rescue-cd.org on a USB stick
  2. Bought another 1 TB hard disk and installed it
  3. Booted from the stick and ran ddrescue (for this https://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html was very enlightening)
  4. Will try to fix the resulting errors due to missing blocks with GParted/e2fsck but I don't know how it will go or what to do from there; the new disk should substitute the old one transparently if all goes well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.