Repair hdd on linux

Guide to Repair Linux Disk Using FSCK and Recover Linux Files

Is your Linux system giving you hiccups? Do not fret! Whether it is Linux check disk, Linux repair disk or other functions that you need to run, we have all of it right here!

How to Repair Linux Disk Using FSCK and Recover Linux File?

Theo Lucia

Jun 28, 2023 • Filed to: Recover Files • Proven solutions

Last night, I ran into disk problems in my Linux system. I have tried my hand at repairing it using tutorials from the internet, but nothing seems to be working for me. Then I stumbled upon a resource, which introduced me to fsck command. Everything changed from there.

Part 1. Overview of Linux Check Disk

The Linux check disk option checks bad sectors and errors on the drive.

1. What Linux Check Disk Means?

In Linux, the check disk command is represented by fsck, which is an abbreviation for file system consistency check. Simply put, it is a utility that helps a user scan the file database for any existing errors and repairs them if need be. Using a set of built-in tools, it checks the disk and then auto-generates a report of its evaluation. In certain systems, fsck often runs by default, usually, after the system shuts down improperly or after a series of reboots.

The Linux check disk (fsck) is a standard operation in Unix-based operating systems, the likes of which includes Linux and Apple operating systems. For the most part, fsck is activated by the system administrator manually or is automatically used at boot time. It works on the data structures directly, which are stored on the disk. The particular behavior of fsck can differ, but it generally follows a specific protocol for internal operations and give the users a common command-line interface.

2. Causes of Linux Drive Corruption

The Linux drive often gets corrupted to these common causes:

1. Accidental data deletion or some human error: Due to accidental deletion of key data, the Linux drive is often corrupted. This is often due to a lack of understanding or toying with files that you may be unaware of in the system.

2. Infection due to viruses: Malicious software or virus infection could be another cause for the corruption of the drive. It is often due to accessing of compromised websites from where these elements enter the system. It could also be due to access to unknown internet connections.

3. Bad sectors present on the hard drive: Bad blocks on the hard drive could cause drive corruption. It often occurs when the situation has gone from bad to worse.

Читайте также:  Unzip linux все файлы

To your benefit, Live CD of any given Linux Distros can easily detect the drive corruption and allow the users to recover their much-needed data in its original form.

Part 2. How to Check Linux Disk?

Fsck function is not just used for checking the hard drive in Linux systems. It can also perform a range of functions that will be examined below. Follow these simple, quick commands and you can execute a range of functions with it.

Smartctl

The modern Linux hard drives come with the S.M.A.R.T function. It is a useful tool, which allows the OS (Linux and Windows) to check up on their health and overall functionality. A fast way to check if your hard drive is equipped with the SMART feature is to extract it from your personal computer and check the information given on the label. You may also check the box it came packaged in.

Install smartmontools

In the case of Linux, there are multiple ways to affirm the S.M.A.R.T status of your hard drive. But the quickest of the lot is probably smartctl. Before looking at how to use this tool, let us first examine how the health of the hard drive is checked with smartctl.

For installing the Smartmontools, you need to open the terminal and follow the given instructions that show on your particular Linux distribution (there are so many).

For Ubuntu:

»Sudo apt install smartmontools’’

For Debian

»Sudo apt-get install smartmontools’’

Источник

Repair and isolate bad sectors on your hard drive with these tools

Repair HDD in Ubuntu

I have recently given myself the task of maintaining my equipment, so, within the tasks, identify that my hard drive already has some bad sectors which has been the cause that has slowed down its operation a bit.

While in Linux we have some very effective tools and quite powerful for this type of task, this is excellent since we are not going to break our heads looking among the many that exist for Windows and most of them are based on the same method.

In Linux they do the same thing that is to encapsulate or isolate the sectors that are damaged, in this way the disk will avoid storing the information in these sectors that are no longer optimal for it.

I must mention that The following tools will only detect the damages in the sectors Therefore, if there is any physical damage to the disk or problems with the heads, this type of damage can no longer be easily repaired, so it is recommended that you change the hard disk.

Now inside dand the tools that we will use this badblocks, this powerful tool will help us locate those sectors with failures or that are no longer optimal for storing information and try to recover them.

Use of badblocks to repair hard drive.

For the use of this tool the first thing is to identify the disk that we are going to repair, for this we will open a terminal and execute:

Once this is done, we will see the mounting point that our disk has, now it is important that the disk that we are going to analyze and repair with badblocks is not in use, so it is the disk where you currently have your system, I recommend you use a Live CD / USB of your system.

Читайте также:  Linux find list all files

Mount point already identified we proceed to execute badblocks from the terminal, in my case the disk that I am going to repair has the mount in / dev / sdb

sudo badblocks -s -v -n -f /dev/sdb

Where we are indicating the following:

  • -s. It shows us the process of scanning the disk, showing us the sectors already checked.
  • -v. It indicates the writing mode used.
  • -n. It puts us in non-destructive mode, this means that the damaged sectors will be recovered and the information on the hard disk will not be damaged or deleted.
  • -f. It will repair bad sectors.

In my case it is a disk to which the information has already been backed up, so I have no problem with the data so all the data will be overwritten, block by block I execute the following:

sudo badblocks -wvs /dev/sdb
  • — in: Write mode (destructive).
  • -s. It shows us the process of scanning the disk, showing us the sectors already checked.
  • -v. It indicates the writing mode used.

We just have to have a lot of patience for this as depending on the damage and the size of the disc it can take from hours to days. So I recommend you leave the computer and prepare a good series marathon if your disk is badly damaged.

How to isolate bad sectors of the hard drive?

Now if what you are interested in is being able to isolate those sectors that are no longer optimal for storage of information, we can use the fsck tool.

This tool it is a good complement for badblocks and I also recommend its use for analysis and preventive maintenance, since using this tool periodically we will have a disc in good condition for a long time.

For your use, like badblocks, the disk that we are going to analyze and repair must be unmounted, now we must open a terminal and execute the following command:

Where we are indicating the following:

  • -c. Check blocks on disk.
  • -f. Force the check, even if everything seems ok.
  • -v. Display more information.
  • -r. Interactive mode. Wait for our reply.

In the same way we must wait and be patient.

If you know of any other tool that helps us with this work, do not hesitate to share it with us, also as a personal comment if the time it takes for these tools to complete their task is more than one day, you should start thinking about purchasing a new disc since in time to back up your information and avoid unnecessary losses.

The content of the article adheres to our principles of editorial ethics. To report an error click here.

Full path to article: ubunlog » Ubuntu » Tutorials » Repair and isolate bad sectors on your hard drive with these tools

13 comments, leave yours

Leave a Comment Cancel reply

Pedro Correa said

Hi, thanks for the help, I am trying to recover a backup disk that got damaged. The thing is slow but it works :), when I finish I will share the result.

Reinaldo Gonzalez said

Thanks for the information, I have a 500gb hard drive with two SOS, I looked to analyze slackware 14.2 but it gave me an error after a crash and under no circumstances will it let me enter now with this method I will try to make it work . eye if someone knows how to recover this error please let me know

Читайте также:  Linux physical memory info

Animal Businesses said

What a good tutorial, thank you very much. I have started to scan a 1Tb HDD and it took 16 hours, 2 patterns finished the other by 4%. It was the original disk that the HP 14-ac132la brings, I noticed a change in its performance spoiling the work a lot, I have changed it for a 240Gb Kingston SDD and it flows perfectly. The previous one I have put in the CD bay (this laptop does not come with that unit) with a caddy and it has fit perfectly. Now to wait for the badblocks work to finish, continue with the fsck and hopefully it will be optimized as additional storage. I have also changed the OS from Win10 to Ubuntu, it had me fed up with so much mediocre and slowing down update.
Thanks again for the tutorial.
One more follower.

CarlosD said

I had the same problem, the original 1 Tb disk of my HP laptop did not lift Win 10, I made the change with a 128 Gb solid disk and took advantage of installing Ubunto 19.10, now I am repairing the 1 Tb disk with badblocks and I’m on my way 53 hrs, let’s see when it ends.
40464163 done, 53:18:44 elapsed. (1772/0/0 errors)
40464164 done, 53:22:01 elapsed. (1773/0/0 errors)
40464165 done, 53:25:18 elapsed. (1774/0/0 errors)

Guille RS said

Eventually I had an error and the OS would freeze, it occurred to me to analyze the disk and I had errors in blocks and clusters. Just use fsck with the above parameters and Xubuntu stopped freezing. Thanks for the excellent tutorial help. Greetings from Argentina!

John Gesell Villanueva Portella said

Ok, thank you very much, for now the badblocks thing is going well for me, I already identified 4 damaged blocks. I am doing the operations from an ISO image on a pendrive; I hope everything is in order at the end, thanks for everything!

Martin said

Hello, the tutorial is very good! I ask you a question: on my pc the disk tool throws me the sig. message: «Disk correct, 32456 bad sectors», and with Smart I see several items such as «Pre-failure». That’s normal? And the weird thing is that when I run Badblocks or FSCK, I get that everything is ok and it doesn’t have any errors. That could be happening? Thanks a lot!

Achilles Baeza said

It is a real SHAME, that sites where the use of FREE software is encouraged, force visitors to accept the use of cookies, really, they are embarrassing to others.

Christian Cala said

And it is also a REAL SHAME the fact that you do not know what a cookie is, gafo! Shut up and focus on learning clown

Beloved said

Your comment reflects the little knowledge you have of Blog and the management of Web pages. Before criticizing, advise yourself so that you do not suffer pain.

free said

My son, you are mixing lashes with your ass. This is not a capitalist ruse, but a legal obligation for ALL internet pages, since ALL are hosted on a server that hosts cookies on your computer.

angel kirilov said

Hello,
1TB disk for 216 hours and the% is 106189%?!
Nowhere does it say how much is left, what should I do?

Akshay patil said

Can I install new OS after isolating bad sectors without any error? While installing new OS we have to format disk, which can remove isolation?

Источник

Оцените статью
Adblock
detector