linux 程序挂载磁盘_Linux磁盘实用程序初学者指南

linux 程序挂载磁盘

linux 程序挂载磁盘

Knowing how to check the condition of your hard disk is useful to determine when to replace your hard disk. In today’s article, we will show you some Linux disk utilities to diagnose the health of your hard disk.

知道如何检查硬盘的状况对于确定何时更换硬盘很有用。 在今天的文章中,我们将向您展示一些Linux磁盘实用程序,以诊断硬盘的运行状况。

Image by Scoobay

图片由Scoobay提供

SMART系统 (S.M.A.R.T System)

Most modern ATA and SCSI hard disks have a Self-Monitoring, Analysis, and Reporting Technology (SMART) system. SMART hard disks internally monitor their own health and performance.

大多数现代ATASCSI硬盘都具有自我监视,分析和报告技术(SMART)系统。 SMART硬盘在内部监视其自身的运行状况和性能。

The SMART tool assesses the condition of your hard disk based on: the throughput of the hard disk, the seek errors rate of the magnetic heads, and other attributes that your hard disk manufacturer built into their hard disk.

SMART工具根据以下各项评估硬盘的状况:硬盘的吞吐量,磁头的寻道错误率以及硬盘制造商在硬盘中内置的其他属性。

Most implementations of SMART systems allow users to perform self-tests to monitor the performance and reliability of their hard disks. The simplest way to perform a SMART system test with Ubuntu is using the ‘Disk Utility’ under the ‘System’ > ‘Administration’ menu.

SMART系统的大多数实现允许用户执行自检以监视硬盘的性能和可靠性。 在Ubuntu上执行SMART系统测试的最简单方法是使用“系统”>“管理”菜单下的“磁盘实用程序”。

The disk utility lets you see the model, serial number, firmware, and the overall health assessment of the hard disk, as well as whether a SMART system is enabled on the hard disk.

磁盘实用程序使您可以查看硬盘的型号,序列号,固件和总体运行状况评估,以及是否在硬盘上启用了SMART系统。

The ‘SMART data’ button lets you see the SMART features of your hard disk.

通过“ SMART数据”按钮,您可以查看硬盘的SMART功能。

The ‘Run Self-test’ button lets you initiate a short,extended, or a conveyance self-test on the hard disk.

“运行自检”按钮使您可以对硬盘进行简短,扩展或传输自检。

When you execute these tests, you’ll see a progress meter, letting you see how far through the test is and what the estimated time of completion is.

当您执行这些测试时,您会看到一个进度表,让您查看测试的进行时间以及预计的完成时间。

The ‘Attributed section’ lets you see the errors and self-test information.

“属性部分”可让您查看错误和自检信息。

文件系统检查 (File System Check)

There some other tools, beside the Disk Utility GUI, that we can use to diagnose the health of our hard disk. The File System Check (FSCK), that only comes as a command line tool, is one of the tools that we often use to check the condition of our hard disk.

除了“磁盘工具” GUI之外,还有一些其他工具可用于诊断硬盘的运行状况。 仅作为命令行工具提供的文件系统检查(FSCK)是我们经常用来检查硬盘状态的工具之一。

You can use the ‘Check Filesystem’ feature of the ‘Disk Utility’ to perform the same check,if you are not a command line geek like us.

如果您不是像我们这样的命令行怪胎,则可以使用“磁盘工具”的“检查文件系统”功能执行相同的检查。

Of course, there are some situations where we have to use the command line tool to check our file system. For example when we are using a headless system, when our Linux box fails to boot, or when we simply want to show off our command line Kungfu skills to our friends.

当然,在某些情况下,我们必须使用命令行工具来检查文件系统。 例如,当我们使用无头系统时 ,当Linux机器无法启动时,或者仅向朋友展示命令行功夫技能时。

At first, the FSCK command line tool looks like something that only a computer geek can handle; But you will find that FSCK is a very easy tool to use. There is one thing to note before you run FSCK; You need to unmount the file system using the ‘umount’ command. Fixing a mounted file system with FSCK could end up creating more damage than the original problem.

最初,FSCK命令行工具看起来只有计算机怪才可以处理; 但是您会发现FSCK是一个非常易于使用的工具。 在运行FSCK之前,需要注意一件事。 您需要使用“ umount”命令来卸载文件系统。 使用FSCK修复已安装的文件系统最终可能会造成比原始问题更大的损害。

sudo umount /dev/sdb

sudo umount /dev/sdb

The FSCK command is pretty straightforward:

FSCK命令非常简单:

sudo fsck -t ext4 /dev/sdb

sudo fsck -t ext4 /dev/sdb

This command checks an ext4 file system (/dev/sdb) for inconsistencies. You should replace /dev/sdb with your own partition. You can run the ‘fdisk’ command to find out your system partitions:

此命令检查ext4文件系统(/ dev / sdb)是否存在不一致。 您应该用自己的分区替换/ dev / sdb。 您可以运行“ fdisk”命令来查找系统分区:

sudo fdisk -l

sudo fdisk -l

计划文件系统检查 (Scheduled File System Checks)

If you’re using Ubuntu, you will notice that Ubuntu runs an FSCK session when you boot your system from time to time. If you find this scheduled check annoying, you can re-schedule the scan using the ‘tune2fs’ command. Here’s how it typically looks like:

如果您使用的是Ubuntu,则将在不时引导系统时注意到Ubuntu运行FSCK会话。 如果您发现此计划检查烦人,则可以使用“ tune2fs”命令重新计划扫描。 通常是这样的:

The mount count parameter tells us that Ubuntu scans our hard disk after 33 disk mounts.

mount count参数告诉我们,Ubuntu在安装33个磁盘后会扫描硬盘。

We can configure the mount count using the ‘-c’ option:

我们可以使用'-c'选项配置安装计数:

sudo tune2fs -c 35 /dev/sda1

sudo tune2fs -c 35 /dev/sda1

This command will re-configure Ubuntu to scan our hard disk after 35 hard disk mounts when the system boots.

系统启动时,安装35个硬盘后,此命令将重新配置Ubuntu以扫描我们的硬盘。

Note: change ‘/dev/sda1/’ with your own partition

注意:使用您自己的分区更改“ / dev / sda1 /”

坏块 (Bad Blocks)

A bad sector is a sector on a computer’s disk drive that cannot be used due to permanent damage (or an OS inability to successfully access it), such as physical damage to the disk surface.

坏扇区是计算机磁盘驱动器上的一个扇区 ,由于永久损坏(或操作系统无法成功访问它)(例如磁盘表面的物理损坏)而无法使用。

There are two ways to detect bad sectors in Linux: you can use the Disk Utility GUI, or if you are a command line geek like us, you can use the badblocks command to check your hard disk for bad sectors:

在Linux中有两种检测坏道的方法:您可以使用Disk Utility GUI,或者如果您是像我们这样的命令行爱好者,则可以使用badblocks命令检查硬盘中的坏道:

sudo badblocks -v /dev/sdb1

sudo badblocks -v /dev/sdb1

Badblock will give us the number of bad sectors in our hard disk.

Badblock将为我们提供硬盘中的坏扇区数。


zainul@zainul-laptop:~$ sudo badblocks -v /dev/sdb1
Checking blocks 0 to 97683200
Checking for bad blocks (read-only test): 3134528 done, 3:27 elapsed
3134560 done, 8:33 elapsed
3134561 done, 10:15 elapsed
3134562 done, 11:57 elapsed
3134563 done, 13:39 elapsed
done
Pass completed, 5 bad blocks found.


zainul@zainul-laptop:~$ sudo badblocks -v /dev/sdb1
Checking blocks 0 to 97683200
Checking for bad blocks (read-only test): 3134528 done, 3:27 elapsed
3134560 done, 8:33 elapsed
3134561 done, 10:15 elapsed
3134562 done, 11:57 elapsed
3134563 done, 13:39 elapsed
done
Pass completed, 5 bad blocks found.

You have two options when you see bad blocks. You can either look for a new hard disk, or mark these bad blocks as unusable hard disk sectors. This involves two steps:

看到坏块时,您有两个选择。 您可以寻找新的硬盘,也可以将这些坏块标记为不可用的硬盘扇区。 这涉及两个步骤:

First we have to write the location of the bad sectors into a flat file.

首先,我们必须将坏扇区的位置写入平面文件。

sudo badblocks /dev/sdb > /home/zainul/bad-blocks

sudo badblocks /dev/sdb > /home/zainul/bad-blocks

After that, we need to feed the flat file into the FSCK command to mark these bad sectors as ‘unusable’ sectors.

之后,我们需要将平面文件输入FSCK命令中,以将这些坏扇区标记为“不可用”的扇区。

sudo fsck -l bad-blocks /dev/sdb

须藤fsck -l坏块/ dev / sdb



FSCK, Badblocks, and Disk Utility are some of the disk utilities that we often use to scan our hard disks. Do share with the other fellow readers if you know other Linux disk utilities to scan hard disks.

FSCK,Badblock和磁盘实用程序是我们经常用来扫描硬盘的一些磁盘实用程序。 如果您知道其他Linux磁盘实用程序来扫描硬盘,请与其他读者共享。

翻译自: https://www.howtogeek.com/howto/37659/the-beginners-guide-to-linux-disk-utilities/

linux 程序挂载磁盘

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值