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?
Be sure to click 'more' and select 'suggest as answer'!
If you're the thread creator, be sure to click 'more' then 'Verify as Answer'!
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?
Linux:
A couple of steps here that catch you out typically:
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
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