How to know if your hard drive is about to “die” analyzing it with fsck and making backups with the tar command

Hard drives are components of our computers and that like everything in this world at some point will end their useful life, hence the importance of regularly making backup copies of our data and even more because we do not know when it will happen and we lose information; It is not easy to predict when our hard drive will fail either, but if we pay attention to certain symptoms we can take the necessary measures not to lose information.

free up hard disk space

Some of those symptoms that I comment on are the following:


Strange noises.

Our computers, no matter how quiet they are, will always make noise for everything that happens inside the case, but generally they are noises that we know and that we can identify as "normal".

So if we hear a noise that is not common we can begin to worry, since it is possible that some of hard drive headers have been damaged. Another possibility may be that the motor that spins the discs is not working as it should. So we must be careful if these noises are very frequent and occur at high speed, perhaps we have less time than we think.

Disappearance of Information.

One of the most significant symptoms and that gives us a clearer indication that something is not right, is when we have problems when it comes to save documents and open them. It is even possible that documents that we have saved in previous days we can no longer find them and it even seems that we have never saved them. The next thing we can find is that sometimes a program that has been working normally stops working overnight. Some viruses or bugs could be the cause, but not always; the best is make a backup of the data that we would like to keep and review exhaustively to rule out all possible causes.

pc-images-disk-dur

Our computer does not recognize a disk drive.

Sometimes our computer cannot find a disk drive installed in it, sometimes the main cause can be found in the same disk drive and not in another component, but it may not always be the case, the best we can do is install the disk drive on another computer and thus rule out that the problem is there or in another component.

Our computer crashes frequently.

If we have seen more often than normal how our computer crashes or if it restarts or if it shuts down while we are in the process, it is a sign that something is not right and that we must take action before it is too late. and most likely of all that is wasting time, is that the cause of everything is in our disk drive.

Very slow access times.

Another unequivocal indicator that our hard drive is failing is when we try to access our file explorer and the time it takes to access it is eternal or when we try to access our trash and it takes forever to empty it, the safest thing is that in a time of one or maybe two months we will have to replace our hard drive. And don't forget, it is best to always have a backup to avoid greater evils.

clip_image fsck

We can perform a hard drive status check using the command fsck but we must be careful since for security reasons of the data that are on the disk, it is not recommended to start fsck On a mounted partition, the best practice before using this command is to unmount the partition before running it.

To execute fsck in the next reboot we must execute the command shutdown and we add the parameter -f:

shutdown -r -F now

We can also create the file forcefsck directly in the root of the system:

Touch / forcefsck

When the system restarts the hard disk will be analyzed and the file / forcefsck will be deleted.

25014593936_fe73fb0b28_b

So if you need to make a backup of your information, an easy way to do it and manually is using the command tar with which a compressed file will be created and that is very easy to use.

This is the syntax with which we will use the tar command:

tar [parameters]

These are some of the most used operations with the tar command:

-z: to compress files using gzip

-c: to create the file

-v: Verbose mode. (It shows us the progress while the file is being created)

-f: To determine the file name

-p allows us to maintain file permissions

-x to extract the file

Now, let's go with an example using the tar command

If we want to compress a directory in its entirety we are going to use the following:

tar -zcvf backup-home.tar.gz / home / *  

Using this command makes a backup of all the files that are in the home directory.

But if what we need is to make a complete backup of the system, with which we can keep programs, data, settings, etc., so that we can recover everything we have on our computer in case of a total loss, we must execute the following:

tar cvpzf /backup-full.tar.gz –exclude = / proc –exclude = / lost + found –exclude = / backup-full.tar.gz –exclude = / mnt –exclude = / sys –exclude = dev / pts /

The "excludes" that are inside the command are to exclude directories that are not important and that the system occupies with dynamic files, which will cause problems and produce errors when we are doing the backup.

linux-disk-partitions

Restore backups:

When we are going to restore a backup, we will use the –x command

With this command the contents in the current directory are extracted, keeping the permissions (-p).

tar -zxvpf /fullbackup.tar.gz

If we do not want to keep the permissions but only extract the contents in the current directory we will use this command.

tar -zxvf backup-home.tar.gz

To extract the files contained in / home

tar -zxvf backup-home.tar.gz / home


3 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Llorenc Garcia said

    I find it weird to read about hard drive health without mentioning SMART. We can see problems before they affect the filesystem (fsck).

  2.   oscar said

    Good! Is there an application that allows these analyzes from a graphical interface?

    Thank you!

  3.   lalo45HD said

    There are guys, I think my disk will die soon, it says there is a problem with my disk and it says to create a backup or contact the pc assembler