Test laptop hardware condition on linux

05
2014-04
  • khajvah

    I am going to buy a used laptop and I need to be sure if it has any issues. It will run windows. I am a linux user, so I want to run some tests with live cd. I can test in windows but Linux is preferable.

    Please, tell me some software/ways to test every possible piece of hardware.

  • Answers
  • Dylan

    It's not too hard to get diagnostic information on the hardware. I'm going to give you some command line instructions which should work on most any Linux distribution, however you might need to download some utilities (if you won't have internet access, consider storing some packages on a live flash drive you could use).

    First thing I'd check is that the hard drive isn't reporting any issues. Most hard drives support SMART to report issues, which you can check with the following:

    sudo smartctl -d ata -H /dev/sda
    

    This should give something like

    === START OF READ SMART DATA SECTION ===
    SMART overall-health self-assessment test result: PASSED
    

    if everything is okay. Smartctl is probably installed on your live distribution by default, but it wouldn't hurt to check. Quick explanation of the options: -d is the disk type, will probably be ata, and -H is the drive - it'll differ based on the type of drive and might also be /dev/hda. Note that smartctl is not a perfect measure of hard drive performance and you are likely at a higher risk of a failing hard drive if you purchase a used one.

    After that you can get some generic information about hardware. For this I'd recommend lshw - that probably won't be installed by default. Just execute the command without arguments like

    sudo lshw
    

    and you'll get detailed information about all the hardware on the machine. I recommend doing so in a full screen terminal. Pay special attention to the *-memory section to make sure it has as much as it says. You can also use

    lspci
    

    for a more compact list of internal hardware.

    You might also want to check how the battery is doing. This is simple enough with the acpi command, which some distributions include by default but is another thing you'll want to double check. To see the battery's design capacity and percentage of that type

    acpi -i
    

    You'll notice a percentage on the end of the second line, this is the current maximum capacity of the battery compared to the designed capacity (they degrade over time, you can usually expect 98-99% for a new one). If you've got low percentages there you can expect minimal battery life and will likely need to replace it if you mean to use it on battery.

    If something is going to be in immediate, obvious trouble it's probably the hard drive. RAM is something else to watch out for.

    That's all I can think of off the top of my head, might add more later.

  • Cristian Ciupitu

    You can use Memtest86+ to ensure the memory is working correctly. It is commonly found bundled with LiveCDs of most distributions, or LiveCDs built specifically for recovery tasks such as Knoppix or SystemRescueCD. You usually access it from the boot screen once the CD has loaded. For example, on an Ubuntu LiveCD, it is labeled as "Test memory".

    enter image description here

    There are similar utilities to stress test the CPU such as x86test and mprime.


  • Related Question

    Checking hardware status on Linux
  • Emiliano

    Is there a Linux tool to check hardware boards status?

    In Windows you have the hardware dialog which shows you lines like "your hardware is working properly" (I don't have the English version so the string may actually be different, but you got the idea).

    I'd like to check the same on Linux. Note that I know what hardware is installed but I need to know that the driver has been correctly loaded and that there are no errors. Since we are installing Linux on different PCs with the very same hardware we need a quick way to know that everything works after the installation. So if a board (say an ethernet card) isn't working for some reason I'd like to be notified about that.

    I know I could use lsmod and dmesg but that is not very "quick". Maybe there is some magic file in /proc that tells me (per board basis) that everything is working properly for a given board?

    Specifically I need to test the ethernet boards and the serial line status.

    (the serial line driver is compiled directly into the kernel so lsmod isn't very handy here)


  • Related Answers
  • Keith

    For ethernet interfaces you can use ethtool.

    # ethtool -t eth0 online
    The test result is PASS
    The test extra info:
    nvram test     (online)          0
    link test      (online)          0
    register test  (offline)         0
    memory test    (offline)         0
    loopback test  (offline)         0
    interrupt test (offline)         0
    

    This runs a self test, but depends on proper support in your hardware and driver. You can also just get its status.

    # ethtool  eth0 
    Settings for eth0:
            Supported ports: [ TP ]
            Supported link modes:   10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Half 1000baseT/Full 
            Supports auto-negotiation: Yes
            Advertised link modes:  10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Half 1000baseT/Full 
            Advertised pause frame use: No
            Advertised auto-negotiation: Yes
            Speed: 100Mb/s
            Duplex: Full
            Port: Twisted Pair
            PHYAD: 1
            Transceiver: internal
            Auto-negotiation: on
            MDI-X: Unknown
            Supports Wake-on: g
            Wake-on: g
            Current message level: 0x000000ff (255)
                                   drv probe link timer ifdown ifup rx_err tx_err
            Link detected: yes
    

    This tells you the connection parameters, and link status.

    For serial lines, the udev rules will load the driver and it will register device nodes if they exist. The mere presence of /dev/ttyS? tells you there is harware there, and that it passed a sanity test. The Linux driver does a test and the device won't be registered if it doesn't pass. But to really know if it works will require testing it with a loopback plug.

    Oh, and you can also use the ssetserial command to get information about the serial port.

    # setserial /dev/ttyS0
    /dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
    

    The presence of that information tells you you have that serial port hardware.

  • spectre256

    Testing is definitely the correct answer. Any piece of hardware can and will fail. Additionally, it will often fail in a way that still makes it LOOK like it is working, until you try to use it. It may work fine except in certain cases, such as high load. With this in mind it's clear Windows saying "this hardware is working properly" is not useful.

    If you are managing even a moderately large set of hardware, it is essential to do some sort of burn in. Run CPU intensive tasks for a few hours, write huge amounts of data to disk and read it back to ensure it is correct, saturate the network card with traffic and check for dropped packets. This is the only way to be sure.

    Also, be sure to run similar (but probably smaller) checks through the life of the machine. Use something like nagios so that you get an alert as soon as something is amiss. Hardware fails, and it fails frequently.