Проверка карт памяти linux

Blog entries are licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Blog comments are copyright to their respective authors.

Top Posts

Recent Comments

Archives

Chris Collins

Coder – Maker – Educator – Leader

Testing SD Cards with Linux

While on holiday recently, my wife bought a 32GB micro-SD card, which she intended to use in her tablet. Since then, it has been giving various errors, so I thought I should take it and verify its quality.

In order to test the card, we’re going to run three tests:

  1. Access Speed, to assess the card Speed Class.
  2. Drive Size, to assess if the reported size matches the actual size.
  3. Data durability. to assess that data written can be read back reliably.

Before we start…

The tools and techniques we’re going to use will be destructive to any data that is on the SD card. If this is important to you, make a backup of your data to a safe location before starting.

Testing Access Speed

A relatively quick assessment of speed can be made using the ‘gnome-disks’ tool. This sometimes appears as ‘Disks’ under the start menu on most modern Linux distributions. Opening this, you can find the SD card in the drive list, and use the tools to run a benchmark test. We’re interested in the write speed, so ensure you select to do a write test. Once complete, the benchmark tool will show a graph of results similar to the following figure.

SD Card Benchmark Results

SD Card Benchmark Results

We can see that the write speed is averaging 5.8 MB/s. Comparing this to the SD Association Speed Class data, we can conclude that this is only sufficient to claim Speed Class 4. This is quite disappointing for a card that was sold as a Class 10 High Speed card.

We’re going to have to mark this test as a fail.

Testing Drive Size

Again, the gnome-disks tool shows the reported size of the SD card as 34 GB (33,554,432,000 bytes). There is some ambiguity in terms of how disk sizes are reported, given that there are two definitions of what a Gigabyte is. Some consider it as 10 9 bytes (a decimal gigabyte), while some consider it as 2 30 bytes (a binary gigabyte). That said, the card was sold as a 32GB card, so if it holds that much (or more), we’re happy.

Читайте также:  Open new terminal linux command

To test the drive size we’re going to create a 32GB file containing random data. Assuming you have a hard-disk location suitable for a file of this size, one can be created using the command:

dd if=/dev/urandom of=rnd_data bs=1024 count=32768000

‘dd‘ is the disk-duplicator, we’re using it to read from the input file (if) /dev/urandom. This is a pseudo-file to the kernel random number generator, and will return a random string of ones and zeros. We’re going to write this data to the output file (of) called rnd_data. We’re reading block size chunks (bs) of 1024 bytes (1 kilobyte). We’re also going to read ‘count’ blocks. Count was derived by dividing the reported disk size by the block size. As this is a large amount of random data to produce, it took several hours to produce this file, so be patient.

Once this file is created, we can copy it to the SD card to see if it fits. Again we can use the dd command for this, but this time we’ll need administrator rights.

sudo dd if=rnd_data of=/dev/sdc bs=1024 count=32768000

In my case the drive was listed as /dev/sdc, though this might differ in your case. Again the gnome-disks utility can help show where your device is listed. This command will overwrite the disk contents with the random data we previously produced. Back up any data on the card before running this command. Depending on the write speed of your card, this can also take several hours to complete.

In the end the results were a pass. All 32768000 blocks were written, so we can say the card had sufficient capacity to pass this test. Had the card been of a lower capacity, dd will show how many blocks were written. This will give an estimate of actual drive size in kilobytes. Dd also shows the average write speed as 3.8 MB/s, which is not enough to claim Class 4. Again, further proof that this is a mislabelled speed class.

Testing Data Durability

To ensure that the data we wrote can be correctly read back we can copy the SD card contents back to another file. Again we’ll use dd…

sudo dd if=/dev/sdc of=rnd_read bs=1024 count=32768000

Reading is typically quicker than writing, but as we’re moving a large data size it can also take some time to complete. Once the data has been read back, we can compare the data that was written (rnd_data), with the data that was read back (rnd_read) using a hashing algorithm:

md5sum rnd* 729d62450dbf55d0676ddff494a7597d rnd_data c628379249c448eba5502acb9de9d477 rnd_read

The test is a failure as the checksums don’t match. It’s clear that the data read back doesn’t match the data written. If data durability can’t be assured, the card is useless. It’s little wonder the tablet constantly complained that the card didn’t have a file system.

Читайте также:  Drweb linux серийный номер

Caveat Emptor (Buyer Beware)

To finish you can delete the rnd files and recover their disk space. Two of our three tests failed, so we can say that we bought a dud SD card.

So if I have any final advice it would be when buying SD Cards, or indeed any other electronics, is to buy reputable brands from reputable dealers. Alas, as we made the purchase abroad, a refund is not likely. Hopefully these instructions can help you avoid the duds, and get a refund if possible.

Источник

How can I test the full capacity of an SD card in Linux?

I purchased a 64 GB SD card from eBay. It works fine when I burn an Arch Linux ARM image to it and use it to boot up my Raspberry Pi. However, when I try to create a single ext4 partition on it to use all capacity of the card, errors occur. mkfs.ext4 always finishes happily; however, the partition cannot be mount ed, always throwing an error and dmesg shows kernel messages includes Cannot find journal . This has proved to be the case on at least two platforms: Arch Linux ARM and Ubuntu 13.04. On the other hand, I can create and mount a FAT32 partition without error (a full capacity check has not been done). I heard that some bad guys can change the SD card interface to report a wrong capacity to the OS (i.e. the card is really only 2 GB but it reports itself as a 64 GB) in order to sell the card at a better price. I know that tools like badblocks exist for me to check the SD card for bad blocks. Can badblocks detect problems like this? If not, what other solutions exist for me to test the card? I’d ideally like to know whether I was cheated or not; if the result shows I just received a bad item, I can return to the seller only, rather report to eBay that somebody tried to cheat me. UPDATE operations and messages:

~$ sudo mkfs.ext4 /dev/sde1 mke2fs 1.42.5 (29-Jul-2012) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 4096000 inodes, 16383996 blocks 819199 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 500 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done ~$ dmesg | tail . [4199.749118]. ~$ sudo mount /dev/sde1 /mnt mount: wrong fs type, bad option, bad superblock on /dev/sde1, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so ~$ dmesg | tail . [ 4199.749118]. [ 4460.857603] JBD2: no valid journal superblock found [ 4460.857618] EXT4-fs (sde1): error loading journal 
  • The SD car is good but for some reason mke2fs or mount or the kernel have a bug that causes the problem.
  • I was cheated in a way that badblocks that cannot detect the defeat. This is plausible because I think badblocks is just doing some in-place write-read test. However, the cheater can make the access to outbound areas link back to some inbound block. In this case a in-place write-read check is not able to detect the problem.
Читайте также:  Antix linux rus 32 bit

If there is no application can do the proper test, I think I can try to write a simple C program to test it.

Источник

Is there an SD Card diagnostic utility?

Are there any SD Card diagnostic utility programs out there for Ubuntu? I would like to run tests on my SD card to check capacity, write speed etc. I have one for windows but I am looking for a Linux flavor and hope to find some source code.

4 Answers 4

Look for Disk Utility on you dash (as an option press Alt+F2 and type palimpsest )

enter image description here

Click on the disk you want information from, to test it click on Benchmark

enter image description here

To start benchmark, select Read only or Read/Write benchmark

enter image description here

On 13.04 (raring) palimpsest was replaced with gnome-disks («Disks» when you access it from the menu). The instructions are the same as posted by Bruno Pereira.

For Ubuntu 13.04 and later.

From the dash

Find <code data-lazy-src=

enter image description here

A window will appear. Click Start Benchmark. to see:

enter image description here

I left the defaults and clicked Start Benchmarking. . It will run for a while, building the chart over time. You can see that my new SD card’s read rate is around 7 MB/s, while the write rate is only slightly over 2 MB/s.

The model shown here is a SanDisk Ultra SDXC with an advertised speed of up to 30 MB/s. As you can see, the transfer rate is not as advertised.

Источник

Оцените статью
Adblock
detector