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?
    – Chindraba
    Mar 4, 2017 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, 2017 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.
    – Chindraba
    Mar 4, 2017 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, 2017 at 7:27

3 Answers 3

-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.
    – Chindraba
    Mar 5, 2017 at 2:33
  • You saved my day. I forgot to run sudo partprobe /dev/sdX after creating a new partition, hence dd created a regular file on my /dev partition.
    – Arnie97
    Mar 22, 2020 at 7:34
  • 1
    thank you very much, I had the same problem, most probably because i have run dd with a destination that didn't exist at that moment (/dev/mmcblk1), seem like this was then created
    – flood
    Oct 18, 2020 at 12:40
  • 1
    This happened to me also, so I added conv=nocreat to the dd command, and now it won't create new files.
    – Jeremy
    Oct 20, 2021 at 21:01

I also got the "not enough space" but that was because I device-dumped (dd) from the iso image to a partition /dev/sdb1 which was too small! and it would never be bootable! I added this comment 4 years later because one answer got it wrong what to do if you want a bootable USB stick, therefore I elaborated this a bit:

If you have a USB memory stick as /dev/sdb (or sdc, sdf, whatever) you can make a bootable disk from an iso-boot-image with typically an iso9660 partition by using the dd command (or cat)

dd if=/distfiles/debian-11.1.0-amd64.iso of=/dev/sdb bs=4M

the last parameter, bs=4M, is not needed, it's just for speed. note that there was creation of partitions sdb1 maybe also sdb2 abd (maybe even more partitions).

check that it exists:

ls -l /dev/sdb*

brw-rw---- 1 root disk 8, 32 Oct 22 20:59 /dev/sdb
brw-rw---- 1 root disk 8, 33 Oct 22 20:40 /dev/sdb1
brw-rw---- 1 root disk 8, 34 Oct 22 20:33 /dev/sdb2`

b in the first column shows they are block-devices ("disks"). in this case there were 2 partitions on the iso-image! then you can mount it:

mount /dev/sdb1 /nod1

df -mT /nod1

/dev/sdb1      iso9660        378    378         0 100% /nod1

If you want to store the iso-image on a disk or USB stick but not as a boot-usb-memory stick, then use the existing filesystem (partition) on the usb stick (perhaps format it using mkfs or easist, use partition editor) and then mount that partition

mount /dev/sdb1 /nod1

df -mT /nod1

Filesystem     Type 1M-blocks  Used Available Use% Mounted on
/dev/sdc1      vfat     14844  6935      7910  47% /nod1

then you could do, if you want to store the iso img for later:

dd if=/distfiles/debian-11.1.0-amd64.iso of=/nod1

(but note that you can not boot it from the USB stick)

(as far as I know. Maybe possible in the future?!:)

Now if you list the device's partitions they will still be fx.ext2 or vfat partitions, not iso9660, and there will be a file called debian-11.1.0-amd64.iso


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, 2017 at 7:18
  • @Stephen C but he didnt mention about existing partitions deletion.
    – Israr
    Mar 4, 2017 at 7:40
  • bootable Flag can be toggled.
    – Israr
    Mar 4, 2017 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.
    – Chindraba
    Mar 4, 2017 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.