LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 02-21-2021, 01:24 PM   #1
lvm_
Senior Member
 
Registered: Jul 2020
Posts: 1,523

Rep: Reputation: 521Reputation: 521Reputation: 521Reputation: 521Reputation: 521Reputation: 521
can SD card fail this way?


Bona fide "32G" SD card which did successfully hold 29G of data suddenly started accepting no more than 4G. It happened when I tried to write partition image to it:

Code:
# dd if=car.sd.sandisk.dd of=/dev/sdj1 bs=16384
dd: error writing '/dev/sdj1': No space left on device
248773+0 records in
248772+0 records out
4075892736 bytes (4.1 GB, 3.8 GiB) copied, 20.7289 s, 197 MB/s
Always fails at exactly the same place after 4075892736 bytes. When I tried to re-create filesystem it created a 4G one

Code:
# /sbin/mkfs.vfat -v /dev/sdj1
mkfs.fat 4.1 (2017-01-24)
Auto-selecting FAT32 for large filesystem
/dev/sdj1 has 255 heads and 63 sectors per track,
hidden sectors 0x0000;
logical sector size is 512,
using 0xf8 media descriptor, with 7960728 sectors;
drive number 0x80;
filesystem has 2 32-bit FATs and 8 sectors per cluster.
FAT size is 7760 sectors, and provides 993147 clusters.
There are 32 reserved sectors.
Volume ID is cb2429a9, no volume label.
even though partition is a 29G one

Code:
Command (m for help): p
Disk /dev/sdj: 29 GiB, 31104958464 bytes, 60751872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors Size Id Type
/dev/sdj1        8192 60751871 60743680  29G  c W95 FAT32 (LBA)

Ok, flash cards do fail - nothing unusual here, but two things make me suspicious: there are no messages in syslog about bad sectors and such - no errors at all, and the writing speed of the image is way too high - it is a Class 10 card good for 10 MB/sec, not 200. I am on ubuntu 18.04, and there is some background automount trickery goes on for usb devices. So... am I missing something?
 
Old 02-21-2021, 02:03 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,415
Blog Entries: 7

Rep: Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955
Quote:
dd if=car.sd.sandisk.dd of=/dev/sdj1 bs=16384
You wrote to a partition and not the device.

What is the output of, with the device plugged in.
Code:
fdisk -l
lsblk
parted -l
Quote:
/sbin/mkfs.vfat -v /dev/sdj1
That's a partition. How large is it? Is there free space on the device? Other partitions?

Edit:
Oh I see, didn't read good enough.

If you are sure that /dev/sdj is the usb device
Code:
dd if=/dev/zero of=/dev/sdj bs=1M count=10
Then start over. That will wipe the partition table.

Last edited by teckk; 02-21-2021 at 02:06 PM.
 
Old 02-21-2021, 05:29 PM   #3
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
If it has FAT32 file system, largest file size is 4GB. If you want to write larger files like a 16GB flash drive image perhaps, you need to use a different file system on the destination drive. Like extFAT, ext4, ntfs

Quote:
Device Boot Start End Sectors Size Id Type
/dev/sdj1 8192 60751871 60743680 29G c W95 FAT32 (LBA)
 
Old 02-22-2021, 03:23 AM   #4
lvm_
Senior Member
 
Registered: Jul 2020
Posts: 1,523

Original Poster
Rep: Reputation: 521Reputation: 521Reputation: 521Reputation: 521Reputation: 521Reputation: 521
Here is what lsblk and parted say about it - consistent with fdisk which was in my original message.

Code:
sdj       8:144  1   29G  0 disk  
└─sdj1    8:145  1   29G  0 part  


Model: Generic Ultra HS-SD/MMC (scsi)
Disk /dev/sdj: 31.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  31.1GB  31.1GB  primary  fat32        lba
And zeroing and re-creating partition table have no effect at all. The thing that baffles me most is the write speed - there is no way it can write to a fairly slow SD card that fast, and AFAIK there could be no write-back caching when writing directly to a device. Or could it? - another weird thing I noticed is that for some reason df refers to this card not as /dev/sdj1 but as /dev/loop0

Code:
/dev/loop0         3972588           4    3972584   1% /media/lvm/FE30-5469
although mount sees it as /dev/sdj1 and doesn't mention /dev/loop0 at all

Code:
/dev/sdj1 on /media/lvm/FE30-5469 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022
and udisksd doesn't mention loop0 either in syslog messages

Code:
udisksd[877]: Mounted /dev/sdj1 at /media/lvm/FE30-5469 on behalf of uid 1000
When, however, I write to /dev/sdj write speed is the expected ~10 MB/sec. So what's happening here?


Quote:
Originally Posted by Brains View Post
If it has FAT32 file system, largest file size is 4GB. If you want to write larger files like a 16GB flash drive image perhaps, you need to use a different file system on the destination drive. Like extFAT, ext4, ntfs
What filesystem limitations have to do with inability to write to a block device where it is stored? Nothing at all. I didn't even try to access the filesystem yet.
 
Old 02-22-2021, 08:35 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,815

Rep: Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238Reputation: 2238
Quote:
Originally Posted by lvm_ View Post
another weird thing I noticed is that for some reason df refers to this card not as /dev/sdj1 but as /dev/loop0

Code:
/dev/loop0         3972588           4    3972584   1% /media/lvm/FE30-5469
although mount sees it as /dev/sdj1 and doesn't mention /dev/loop0 at all
That looks like you might have accidentally created an ordinary file named "sdj1" in the /dev directory, and the 4GB size limit you are seeing is just the maximum size of the pseudo-filesystem mounted on /dev.
 
1 members found this post helpful.
Old 02-22-2021, 09:08 AM   #6
lvm_
Senior Member
 
Registered: Jul 2020
Posts: 1,523

Original Poster
Rep: Reputation: 521Reputation: 521Reputation: 521Reputation: 521Reputation: 521Reputation: 521
Quote:
Originally Posted by rknichols View Post
That looks like you might have accidentally created an ordinary file named "sdj1" in the /dev directory, and the 4GB size limit you are seeing is just the maximum size of the pseudo-filesystem mounted on /dev.
Indeed I am. You are a genius, sir.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The right way to fail LXer Syndicated Linux News 0 07-27-2015 12:53 PM
I can not find/use F spot in any way. Nor can I find a way to upload pictures from m old biker Linux - Newbie 1 07-12-2015 08:36 PM
[SOLVED] if [[ -n "$1" ]]; then FAIL FAIL FAIL rbees Programming 7 03-25-2015 02:39 PM
[SOLVED] Full disk makes xinit fail in unexpected way Weapon S Linux - Desktop 5 02-16-2013 02:03 AM
How can I type ASCII codes in a similar way like the old ALT+<code> way? pujolasdf Linux - Software 0 07-17-2005 03:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 02:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration