13 Replies Latest reply on May 24, 2020 8:31 AM by colporteur

    SD card imaging utility?

    ujjwalrathod00700

      Hi Friends,

       

      I have a lot of Sd card and usually nowadays find it difficult to either formate or manage SD cards to write a new image for RaspberryPi. Anyone else also struggle to do that? Do you have any recommendations for tools?

        • Re: SD card imaging utility?
          shabaz

          Hi Ujjval,

           

          Problems might be very possible with poor quality (or fake capacity) SD cards. I only purchase good brands from a reputable seller and have had 100% success forever. There's no detail so perhaps you're following incorrect instructions or maybe you have a faulty download, or downloading from a strange source.

          Beyond that, I don't think there is anything wrong with the instructions at https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/2

          Personally I still use an earlier piece of software called Win32DiskImager because it works fine for me. If you're struggling, it is best to stick to the official raspberrypi.org instructions to the letter, since tens of thousands of people will have followed those instructions, and if there was an issue with their instructions they ought to know about it very quickly.

          1 of 1 people found this helpful
            • Re: SD card imaging utility?
              ujjwalrathod00700

              I have 3 SD cards, two are from Samsung and one Sandisk. As I posted in one of my road test reviews about RPI last year I will again say it.

              I also have genuine downloads from the official website etc so that should not be a problem.

               

              In fact, the instructions at Raspberrypi's website are always good and easy to follow, As I am using Linux could be that I am facing hard times with sd cards. FYI, I have tried belenaetcher, RPI official imager, Diskparted, linux's inbuilt tools to formate the sd cards, but none of them worked properly, Yes Unfortunetely. I will give a try to dd tool now.

                • Re: SD card imaging utility?
                  shabaz

                  ujjwalrathod00700  wrote:

                   

                  ..As I am using Linux could be that I am facing hard times...

                  You left that piece of important information out of your question.

                   

                  Unfortunately, you're going to find it harder to get as much best practice information simply because you're using a very uncommon desktop OS. Most of the Pi setup related information out there will be assuming Windows or Mac.

                  The raspberrypi.org instructions are for children, and it is really unexpected for them to be running Linux on a PC, let alone most adults.

                   

                  I think if you're doing something advanced like running Linux on your desktop then you have to be prepared to dig deeper, and debug a little harder.

                  Your issue could be anything - could even be a driver issue.

                   

                  Raspberrypi.org actually do have information for Ubuntu - they picked one of the more popular Linux distributions for beginners.

                  I cannot help you much further because I don't have much experience with desktop related issues such as SD card imaging.

                  Once you have figured it out, please write it up in a blog post to help other Linux users.

                  More generally, if you're having Linux issues, you should also try to join a Linux user group.. people have plenty of advice to share, and there are sometimes Linux virtual classes.

                  1 of 1 people found this helpful
              • Re: SD card imaging utility?
                Christopher Stanton

                Linux:

                1. Grab an SDCard, ideally larger than 8gByte
                2. Download the Raspbian image from raspberrypi.org, you then have to extract the image from the archive because it is usually in a .zip file, this means you'll usually have to install 'unzip' using your package manager
                3. Insert your SDCard, find its mount point, typically dmesg will tell you (for example, /dev/sdb0)
                4. use dd to write the image to the SDCard

                 

                A couple of steps here that catch you out typically:

                • Your user may not have the correct privileges to do this, you may have to elevate your privileges via superuser (sudo)
                • The SDCard you're using might not have enough space, 8gByte SDCard and an 8gByte image may not match up properly
                • SDCard you're using might be damaged, usually the default failure mode is that they go into 'read only' mode
                • dd can be slow, there are ways to do this faster, stack overflow has good tips for this, as does searching on google.
                2 of 2 people found this helpful
                  • Re: SD card imaging utility?
                    lui_gough

                    Actually dd can be as fast as any other tool - the problem is by default, it copies using a block size that is much too small (probably just 512 bytes) adding a lot of CPU overhead. Adding a larger block size argument will make things faster, if not equally fast, as most other solutions - e.g. "bs=8M" for an 8MByte block size. So instead of using 'dd if=image.img of=/dev/sdx', you would use 'dd if=image.img of=/dev/sdx bs=8M'. Try it yourself and see the difference! It is by far the easiest way to do things on Linux, but be doubly sure you have the right devices or you could end up with data destroyer instead ... the other nickname for dd. Best to try fdisk -l to work out what's what.

                     

                    A big problem with image management is that almost every brand of SD card has a different number of blocks for a different capacity size. It is hence not easily possible to image a Sandisk 32GB card and write it to a Samsung 32GB card, at least without some intervention. If you check fdisk's output and the size of the destination device is equal to or larger than the image file, you don't need to do anything. But if it's the other way around, even by a few kB, you will need to take some action. The easiest way to deal with this issue is to edit the image file by mounting it as a loopback device, resizing the main partition smaller (ideally, as small as possible to give you the widest latitude to image to other cards, but with a margin to allow it to boot), truncating the image file, writing it to your SD card, booting up and resizing the partition to fill the card again (e.g. via sudo raspi-config).

                     

                    You will find that running Linux is actually quite advantageous in this regard, because these kinds of things can be more easily accomplished under Linux than Windows (for example).

                     

                    - Gough

                    2 of 2 people found this helpful
                    • Re: SD card imaging utility?
                      gdstew

                      To expand on some of these points:

                       

                       

                      Most desktop Linux distros will offer the option to extract a compressed file when you right click on it without needing to add any programs.

                      I know Debian, Devuan, Linux Mint, and I believe Raspbian will because I've used them all to do so (it's been a while with Raspbian).

                       

                      To find out which /dev the SD card is using you can also use (using sudo or as root:):

                       

                      fdisk -l

                       

                      Disk /dev/sda: 29.8 GiB, 32010928128 bytes, 62521344 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: 0xaeedd120

                       

                      Device     Boot Start      End  Sectors  Size Id Type

                      /dev/sda1        2048 62521343 62519296 29.8G 83 Linux

                       

                      As long as you know the size of the SD card, 29.8 GiB  for a 32 GB SD card on the first line in the response, then it is easy to know which

                      device (/dev/sda also on the first line) it is using. It would be a good idea to properly remove any other SD cards before doing this just to

                      be sure you find the right one.

                       

                      I always use dd bs=1M status=progress if=image file of=/dev/sdX (of=/dev/sda from the fdisk command above)

                       

                      I have probably written 30+ Raspbian image files using this without any problems since the first revision of the Pi was released. I have also

                      used it for several other SBC OS images with no problems. The --status=progress  will display a progress message while the image is being

                      written although I am still having trouble figuring out exactly what it is displaying.  The progress display message also stops well before the next

                      shell prompt is displayed while waiting for the (SLOW) write to the SD card to finish.

                       

                      I use a block size of 1M because you can't do much to speed it up other than use a SD card with a faster write data rate because that is what

                      slows it down the most by far.

                      2 of 2 people found this helpful
                    • Re: SD card imaging utility?
                      gdstew

                      I almost forgot. The Raspberry Pi Foundation recently released a new SD card image writing utility for Windows, macOS, and Ubuntu.

                      Since what I currently use works fine for me I haven't tried it so I don't know how good it is but here is a link for it:

                       

                      https://www.raspberrypi.org/blog/raspberry-pi-imager-imaging-utility/

                      2 of 2 people found this helpful
                      • Re: SD card imaging utility?
                        ujjwalrathod00700

                        Thank you people.

                        I will try dd first, also see what fdisk has to offer.

                        BTW, I am not doing my P.hD. on SD card images and utilities

                        1 of 1 people found this helpful
                        • Re: SD card imaging utility?
                          colporteur

                          Check out this posting Introducing Raspberry Pi new imaging utility I have used the tool recommended by clem57 it has worked consistently.

                          1 of 1 people found this helpful
                          • Re: SD card imaging utility?
                            ujjwalrathod00700

                            Hi people,

                             

                            Thank you for your wonderful feedbacks.

                             

                            I think there could be an issue with my SD card itself.

                             

                            I tried several things and followed some of the existing bug solutions.

                             

                            https://askubuntu.com/questions/377253/unable-to-format-usb-drive-with-disks-udisks-error-quark-0

                             

                            https://bugs.launchpad.net/debian/+source/util-linux/+bug/1059872

                             

                            https://askubuntu.com/questions/574328/unable-to-format-pen-drive

                             

                            One of the first was to try Gparted and unmount the partition and formate to specific type of partition. Which was success but soon after the last /boot and /sdcardcontent come back.

                            Then I tried Linux's inbuilt Disk tool to formate following one of the above recomendation where I deleted and created the new partions but ssoon again both of my existing partitions came back.

                             

                            Latter tried fdisk thing as lsst post mentions which also did not work.

                             

                            I had also tried DD utility to formate and burn the image to the SD card. Still I will try my best to repair the card, but it seems that there could be a damage in it. @sean conway FYI, I have tried that.

                             

                            Thank you all.

                            1 of 1 people found this helpful
                              • Re: SD card imaging utility?
                                lui_gough

                                Low-quality cards and those which have been used too much can sometimes go into a quasi "read-only" mode. Some will throw write errors while others will pretend to write, but the data and changes are lost. Some readers may even report the card as "write protected". I've encountered this quite frequently on even genuine Sandisk Ultra cards after a year of use - they just don't last. I've had better luck with most other brands. Try using a different / higher quality card.

                                 

                                - Gough

                                1 of 1 people found this helpful
                                • Re: SD card imaging utility?
                                  colporteur

                                  Unfortunate the MS Windows utility didn't resolve your issue.  I had two unservicable SD cards when BB pointed out the utility. One card worked and one card did not after using the utility.

                                   

                                  The utility holds some ability to resolve SD card problems what they are and how they are created is a mystery to me. The failed SD card sits on my computer desk, with the hope I one day find a routine to restore it. The chances are slim:( At some point I will finish my grieving and throw the card into the garbage.