如何测试二手电脑是否有问题?

Fuz*_*sis 1 hardware system-information

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

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

Ces*_*ian 11

让我们从上到下,本指南不是特定于发行版的(这些命令中的大多数都可以在大多数发行版上使用,无论是开箱即用,还是通过软件包存储库)首先您可能想要了解硬件规格的大致情况。为此,您应该运行:

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 )
lshw #<- A combination of lspci and lscpu, also displays total RAM.
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 hardware info on your memory
ip link #<- lists your network devices and their status
cat /proc/kmsg | grep Error #<-Lists errors detected by the kernel (often hardware related ones), probably requires sudo access.
Run Code Online (Sandbox Code Playgroud)

接下来,我们将进行硬盘诊断,fsck 在大多数 linux 发行版的启动时运行(它几乎是标准的,它在 Linux mint 上运行)来检查和修复硬盘错误和坏扇区,所以你很漂亮很多不需要这样做。fsck 无法在已挂载的驱动器上运行,因此如果您想进一步诊断您的硬盘驱动器,您将不得不从系统启动并使用 3rd 方实用程序,例如系统救援 cd(或其他 live cd/usb)或终极引导光盘。另外smartmontools的 smartctl 可用于运行 SMART 测试,如 fsck,更深入的测试无法在当前安装的驱动器上运行(但许多驱动器确实支持离线时自动运行这些测试)。无论如何,还有一些事情可以从您正在运行的系统中完成。hdparm可用于分析和调整硬盘驱动器。

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))
Run Code Online (Sandbox Code Playgroud)

要使用fio进行更彻底的 hdd 基准测试,请使用与 windows 用户可能熟悉的 Crystaldiskmark 类似的格式,请参阅此答案

在内存测试中,对于完整的内存测试,您很可能需要启动内存测试实用程序(如memtest86+,通常嵌入到 livecds 中,您也可以安装它并更新 grub 以显示它),但从内部一个运行的linux环境,可以使用memtester

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

正确诊断 LAN 设备性能的最佳方法,而无需简单测试它可以向/从另一个设备发送或接收数据的速度(和速度)。但是要做到这一点,您可以将iperf或 netcat ( nc ) 与dd(我们之前用于测试硬盘驱动器)结合使用。请注意,您实际上可以通过将服务器托管在您的计算机上,然后使用地址localhost127.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
Run Code Online (Sandbox Code Playgroud)

对于电池测试,有两种选择。gnome-battery-bench(图形)或acpi(终端)或upower(终端)这些是示例命令:

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.
Run Code Online (Sandbox Code Playgroud)

用于声音测试。好吧,我不知道你为什么要这样做,如果声音有效,它就有效,如果它无效,它就不起作用,但无论如何让我们用 ALSA 来做这件事(这样它就可以在所有发行版上运行)。为此,您需要alsa-utils

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.
Run Code Online (Sandbox Code Playgroud)

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

  • glxgears(台面的一部分;opengl 性能的非常基本的测试)
  • Unigine HeavenUnigine Valley(图形基准测试程序,用于测试重载下的 3D 游戏性能)
  • hardinfo(一个 GUI 实用程序,列出有关所有系统规格的详细信息并具有基准测试功能,非常方便!)
  • sysbench(用于 CPU、内存和硬盘等的命令行基准测试工具,指南
  • 压力(命令行 CPU 和硬盘压力测试实用程序)

最后但并非最不重要的一点是,不要忘记要在您的测试中完全彻底,您将需要启动像Ultimate Boot CD这样的硬件测试引导CD,因为有很多事情无法完成(至少不是有效的)来自正在运行的操作系统。