如何测试二手计算机是否存在问题?

如何测试二手计算机是否存在问题?

我可以在运行 Linux 的二手笔记本电脑或 PC 上使用任何命令来告诉我系统是否存在任何问题?如果有,它们是什么?

例如,电池寿命/状况、硬盘空间、坏扇区、坏 RAM、总线速度、视频/音频硬件和驱动程序规格、LAN 卡规格等。

答案1

让我们从上到下,本指南不是特定于发行版的(这些命令中的大多数在大多数发行版上都可用,要么开箱即用,要么通过包存储库)首先您可能想要粗略地了解一下您的硬件规格。为此,您有几个选择:

多合一选项:

inxi --admin --verbosity=7 --filter --width #<- Lists your complete system specs
lshw #<- Lists your complete system specs, sudo recommended
hwinfo > hwinfo.txt #<-Writes your hardware info in extreme detail to hwinfo.txt

多合一 GUI 选项:

hardinfo #<- A pretty good GUI system information utility, also offers benchmarks.
i-nex #<- Similar to CPU-Z on windows
lshw-gtk <- GUI for lshw

有针对性的选项:

cat /sys/devices/virtual/dmi/id/board_{vendor,name,version} #<- Lists your motherboard details.
lspci -Q #<- Lists all your internal hardware and checks online for missing/updated names.
lspci -v | grep "VGA controller" #<- Displays your currently active graphics card. Very useful on laptops with hybrid/switchable graphics. (Typically this is the integrated card unless you have configured it otherwise)
lspci -v | grep "3D controller" #<- Displays your Nvidia Dedicated GPU. For laptops with hybrid/switchable graphics.
lspci -v | grep "Display controller" #<- Displays your ATI/AMD Dedicated GPU. For laptops with hybrid/switchable graphics.
lsusb #<- Lists all your USB hardware.
lscpu #<- Lists detailed processor info (alternative: cat /proc/cpuinfo )
fdisk -l #<- Lists your hard drives and partitions (may requires sudo access).
free -h --si #<- Lists your memory information, total is your total, available is your total free memory.
cat /proc/meminfo #<- Much more detailed info on your memory
ip link #<- lists your network devices and their status

我们还可以快速检查一下内核错误:

cat /proc/kmsg | grep -i Error #<-Lists errors detected by the kernel (often hardware related ones), probably requires sudo access.

现在我们知道我们正在处理什么,我们要检查一下热气流lm_sensors,大多数发行版默认没有安装,lm_sensors通常是包名,但有时也可以是sensors。

它的调用方式如下:

sensors-detect #<-Detect sensors on your pc; you only need to do this once. Requires sudo.
sensors #<-Display current values for known sensors on your pc

之后,如果您想要 GUI 实用程序来监视这些传感器,您可以使用psensor

如果您想查看 Nvidia GPU 的温度或其他信息并且您已安装了该 GPU 的专有驱动程序,请运行nvidia-smi

接下来,我们要去硬盘诊断对于大多数 Linux 发行版来说,fsck 在启动时运行(它几乎是标准的,它在 Linux mint 上运行)来检查和修复硬盘驱动器错误和坏扇区,因此您几乎不需要这样做。 fsck 无法在已安装的驱动器上运行,因此如果您想进一步诊断硬盘驱动器,则必须退出系统并使用第三方实用程序,例如系统救援光盘(或另一张 Live CD/USB)或终极启动光盘。此外智能监控工具的smartctl可用于运行SMART测试,与fsck类似,更深入的测试无法在当前安装的驱动器上运行(但许多驱动器确实支持在离线时自动运行这些测试)。不管怎样,你的运行系统还可以做更多的事情。高清参数可用于分析和调整硬盘。

dd if=/dev/zero of=$HOME/testfile bs=1G count=1 conv=fdatasync oflag=direct #<- Measures throughput of your hard drive (whichever one has your home folder on it).
hdparm -Tt /dev/sdx #<- Gives read speed information on hard drive sdx. I won't cover this in more detail, but you can look for guides on it.
smartctl -Hic /dev/sdx #<- Gives basic info of hard drive sdx and runs an overall health assesment. (If the assessment fails either the drive has failed or is in the process of failing) it then lists the drives SMART capabilities.
smartctl -t short /dev/sdx #<- Runs a short SMART test (cannot be run on a mounted drive (some drives support offline data collection and can automatically run the test on shutdown))

要进行更彻底的硬盘基准测试,请使用菲奥,使用与 windows 用户可能熟悉的 crystaldiskmark 类似的格式,看到这个答案或使用kdiskmark.

在内存测试中,对于完整的内存测试,您很可能需要启动内存测试实用程序(例如内存测试86+,通常嵌入到 livecds 中,您也可以安装它并更新 grub 来显示它),但是在运行的 Linux 环境中,您可以使用内存测试仪

memtester 1024 5 #<- Sets aside 1GB(1024MB) free memory, and runs tests on it 5 times, then displays results.

正确诊断 LAN 设备性能的最佳方法,而无需简单地测试它向/从另一个设备发送或接收数据的速度(和多少)。但要做到这一点,你可以使用iperf或网猫(数控) 和这个结合DD(我们之前用它来测试硬盘)。请注意,您实际上可以通过在您的计算机上托管服务器来测试您的网卡从自身到自身的吞吐量,然后使用该地址连接到您自己本地主机或者127.0.0.1

iperf -s #<- Starts iperf server (run this on the device you want to connect to, yes, as I said you need another computer for this)
iperf -c <address of server computer> #<- Connects and displays transfer rate information.
nc -vvlnp 12345 >/dev/null #<- Starts a netcat server (requires open firewall port for port 12345 if you have a strict firewall)
dd if=/dev/zero bs=1M count=1K | nc -vvn <server IP address> 12345

对于电池测试有两种选择。侏儒电池工作台(图形)或交流接口(终端)或优动力(终端)这些是示例命令:

acpi -ib #<- Lists battery status, basic specs and gives an idea of it's health (shows it's charge level last time it was "full")
upower -i /org/freedesktop/UPower/devices/battery_BAT0 #<- Should provide detailed battery information.

对于声音测试。我不知道你为什么要这么做,如果声音有效,那就有效,如果不有效,那就无效,但无论如何让我们用 ALSA 来做这件事(这样它就能在所有发行版上工作)。你需要alsa 实用程序为了这。

speaker-test -c 6 -t wav #<- Runs test sound on 6 speaker channels (for 5.1 speaker setup, you can use -c 2 for stereo speakers), just to see what happens.
speaker-test -r 96000 -f S32LE #<- Test stereo wav sound at 32-bit on 96khz frequencies. You can use this to test the maximum supported format and frequency (for example, while you sepcify 32-bit format, it may set to 16-bit format, if it does this then it will say so so read the output)
aplay -l #<- Lists sound output devices.
speaker-test -D hw:0,0 -c 4 -r 48000 -t wav #<- Test on specific hard ware device 0,0 at 4 channels with 48khz rate.
arecord -l #<- Lists recording devices.
arecord -f dat -d 20 -D hw:0,0 test.wav #<- Test specific recording device by outputting to a file in basic DAT quality
aplay -f dat test.wav #<- Play the recorded test file.

任何进一步的测试(CPU 和 GPU 性能)都需要专用的基准测试/压力测试程序,或者启动到专门的测试环境。除了已经提到的实用程序之外,这里还列出了我建议的基准测试实用程序。与图形基准测试一样,您需要确保禁用垂直同步。

  • GLX齿轮(mesa 的一部分;opengl 性能的非常基本的测试)
  • 维克立方体(vulkan-tools 的一部分;非常基本的 vulkan 性能测试)
  • 优尼吉天堂或者尤尼金谷(图形基准测试程序,用于测试重负载下的3D游戏性能)
  • 系统工作台(CPU、内存和硬盘等的命令行基准测试工具,指导
  • 压力(命令行 CPU 和 HDD 压力测试实用程序)

最后但并非最不重要的一点是,不要忘记为了在测试中完全彻底,您将需要启动硬件测试启动光盘,例如终极启动光盘因为有很多事情无法从正在运行的操作系统中完成(至少不能有效地完成)。

相关内容