3

I have been trying to format an sd card with the lastest debian jessie-lite image for use with raspberry pi. When using the dd command, it states that there is no space left on device after copying 10 megs. I have searched SE and have tried to use various answers to questions but I always end up back at the same place. Below are the outputs of dd, fdisk, df and ls commands that may be of interest.

/dev/sdb is the sd card

dd bs=4M if=/home/user/Downloads/2017-02-16-raspbian-jessie-lite.img of=/dev/sdb

dd: error writing ‘/dev/sdb’: No space left on device
3+0 records in
2+0 records out
10485760 bytes (10 MB) copied, 0.0137885 s, 760 MB/s

fdisk -l /dev/sdb

Disk /dev/sdb: 10 MiB, 10485760 bytes, 20480 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: 0xdbcc7ab3

Device     Boot  Start     End Sectors  Size Id Type
/dev/sdb1         8192  137215  129024   63M  c W95 FAT32 (LBA)
/dev/sdb2       137216 2807807 2670592  1.3G 83 Linux

ls -al /dev/sdb*

-rw-r--r-- 1 root root 10485760 Mar  3 22:04 /dev/sdb
brw-rw---- 1 root disk    8, 17 Mar  3 22:05 /dev/sdb1
brw-rw---- 1 root disk    8, 18 Mar  3 22:05 /dev/sdb2
brw-rw---- 1 root disk    8, 19 Mar  3 22:05 /dev/sdb3

df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       226G  7.3G  207G   4% /
udev             10M   10M     0 100% /dev
tmpfs           1.6G  9.3M  1.6G   1% /run
tmpfs           3.9G  112K  3.9G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           792M  4.0K  792M   1% /run/user/119
tmpfs           792M  8.0K  792M   1% /run/user/1000
  • I notice that the fdisk output shows the card as 20480 sectors, then shows partitions ending at sector 2807807. I can't imagine why that shold be since the first time you used dd it should have blown out the partition table, and anything else in the first 10MB of the card. Is the card write-protected? How old is it? Could the card be bad now? Can you mount either partition r/w or does it only allow you to mount r/o? If you can mount at all, does it behave properly, as in allow file creation, and reading? – Gypsy Spellweaver Mar 4 '17 at 6:49
  • Is there a reason you've specified bs=4M? Have you tried writing without this option? The output shows 512 byte sectors. I'm not 100% certain, but perhaps try using bs=512 which should write one sector at a time. – Stephen C Mar 4 '17 at 7:22
  • @StephenC OP used bs=4M because that's what the Installation instructions said to use. That is common now when dding IMG and ISO files to cards and sticks. I believe it's because the cluster size on CD/DVD is 4096 bytes. Normally dd doesn't care which way you go, although the larger the block size the faster the process goes, up to reasonably limits based on the device and system memory. I've been known to use a cylinder at a time with bs=8225280 when imaging HDDs. – Gypsy Spellweaver Mar 4 '17 at 9:39
  • @GypsySpellweaver on modern disks the concept of C/H/S/ is largely irrelevant. On Linux-based systems (at least), using cat instead of dd is almost always faster, and never slower. – roaima Dec 5 '17 at 7:27
12
-rw-r--r-- 1 root root 10485760 Mar  3 22:04 /dev/sdb

/dev/sdb is a regular file, not a device. You must have run rm /dev/sdb at some point. It is created automatically when the device is inserted, but when you run commands as root, you can mess up with it. Now that /dev/sdb is a regular file, it's stored in memory, on a filesystem which has a low size limit because it's only meant to contain device files that have no content as such since they're just markers to say “call this device driver to store the contents”.

Remove the file (rm /dev/sdb as root). Then, to re-create the proper /dev/sdb, the easiest way is to eject the SD card and insert it back it. Once you've done that, you can copy the image with the command you were using, or simply

 </home/user/Downloads/2017-02-16-raspbian-jessie-lite.img sudo tee /dev/sdb >/dev/null
  • Going to guess that the .img file contains all sorts of normally non-printable characters, so the results of the given command could be very ugly on the screen. I think the OP is better off sticking with the dd command originally tried. +1 for a good eye, I totally missed the non-block device for /dev/sdb in the ls output. – Gypsy Spellweaver Mar 5 '17 at 2:33
-1

To write an image, you need a formatted partition. /dev/sdb is your device. You have two partitions, /dev/sdb1 and /dev/sdb2. So the command would be:

dd bs=4M if=/home/user/Downloads/2017-02-16-raspbian-jessie-lite.img of=/dev/sdb2
  • 2
    I don't think this answer is correct. dd writes raw data, and you shouldn't specify a partition if you want the SD card to be bootable – Stephen C Mar 4 '17 at 7:18
  • @Stephen C but he didnt mention about existing partitions deletion. – Israr Sayed Mar 4 '17 at 7:40
  • bootable Flag can be toggled. – Israr Sayed Mar 4 '17 at 8:03
  • @IsrarSayed When using dd on the device without partition number, as in /dev/sdx rather than /dev/sdx2 it starts at the beginning of the disk, where the partition table is in MSDOS disks, and wipes it out. If the written data includes a new table, that's what it will be, if it is a single filesystem, such as an ISO or UDF image, then the entire disk (card) will be the same, and any extra space will become inaccessible until the disk is repartitioned. – Gypsy Spellweaver Mar 4 '17 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.