Well things are starting to come together, finally got my arse in gear and set up a virtual sd card image so I can start organizing the project files properly. It also makes backups simple as now I just copy and paste the image at the end of the day with a script.
For the curious if you are on arch linux... assuming you want to manually create the virtual card/image. And not depend on some cute gui/tool that you didn't write yourself..
Before you read on and get frustrated, and rage quit. If you are trying to create a bootable card, this is not the poorly written tutorial for you. Sadly this method can't generate bootable images (I know I cried myself to sleep over this feature fail myself the first time..) But for creating regular media images this method works just fine. ( hint your missing the bootloader padawan. )
The way you create a bootable image is a bit esoteric manually and would only confuse the potato's amongst us reading the tutorial who just want a regular card image.
First create the image file using dd, I decided to go for a 4 gig card, that is big enough not to worry about having to use multiple images to store asses and binary files but its also not too big (but in fairness if you wanted to target a 64gig + sd card you just have to bite the bullet and use exFAT.) A lot of this is going to depend on your target. You need to go check the technical documentation on what it can and can't handle, what file system it is expecting, what the maximum card size it can take is. Had I gone for 1gb card image then FAT16 would have made more sense. I guess 4gig is just on that threshold where FAT32 makes sense.
Still you might have a target with older firmware for the sd/micro-sd reader so I will include the options for different sizes. It's just a matter of changing the value used in the dd command but if you are as much as a potato as I was your need some guidance/hand holding. Plus dd is not the sort of command you want to just play around with (its not jokingly called 'Disk Destroyer' for nothing) In addition for very old device targets you might need to use FAT16.. (I don't know you might be targeting some old school hand held thing..
Yea you can have some pretty large FAT32 cards but past a certain point performance starts to suffer and you really should just go for exFAT (assuming your target can support that).
Going bellow 1 gig switch to FAT16..
Remember exFAT is going to need a slightly different command syntax (don't worry I'll add that as an example just in-case you are reading this from 10 years in the future with a 10tb sd card image..)
You might be really pushing the edge case of life and need to use FAT12 (welcome to 1977) Ok I won't judge you...
32gb card
Code: Select all
dd if=/dev/zero bs=1M count=32768 of=mysd32gb.raw
Code: Select all
dd if=/dev/zero bs=1M count=16384 of=mysd16gb.raw
Code: Select all
dd if=/dev/zero bs=1M count=8192 of=mysd8gb.raw
Code: Select all
dd if=/dev/zero bs=1M count=4096 of=mysd4gb.raw
Code: Select all
dd if=/dev/zero bs=1M count=2048 of=mysd2gb.raw
Code: Select all
dd if=/dev/zero bs=1M count=1024 of=mysd1gb.raw
Code: Select all
dd if=/dev/zero bs=1M count=512 of=mysd512mb.raw
Code: Select all
dd if=/dev/zero bs=1M count=256 of=mysd256mb.raw
Code: Select all
dd if=/dev/zero bs=1M count=128 of=mysd128mb.raw
Code: Select all
dd if=/dev/zero bs=1M count=64 of=mysd64mb.raw
Code: Select all
dd if=/dev/zero bs=1M count=32 of=mysd32mb.raw
Code: Select all
dd if=/dev/zero bs=1M count=16 of=mysd16mb.raw
Ok now you have a raw file, congratulations - you did it and your system is not borked. (well were assume things went ok because your able to read this..) If not, well you have brought shame to your ancestors - go sit in the corner as your system is restored and try again later. All jokes aside. We can't just run off mounting our new card image, because its not formatted yet. Hold ya horses... to format the card image do the following.
get on your big boy pants - were going in as root. If you don't have root access beg the person that does to complete the following steps...
Instead of mysd.raw use whatever name you used to create the card image.. if you are using a different file format (FAT12, FAT16, exFAT or the various other formats... if you are using them your know what they are..) use that instead of FAT32 obviously. But I am going to assume a simple potato like myself is going to stick to something middle of the road size wise ( >2gb <64gb ) and so FAT32 is going to be what ya need to succeed.
For FAT32 cards
Code: Select all
su
mkfs.fat -F 32 mysd.raw
exit
Code: Select all
su
mkfs.fat -F 16 mysd.raw
exit
Code: Select all
su
mkfs.fat -F 12 mysd.raw
exit
exFat cards
Code: Select all
su
mkfs.exfat -F mysd.raw
exit
In arch this is no longer the case fear not for I have shed the tears of frustration and rage so that you don't have too.. It's actually close by.
enter the following.. continue to wear your big boy pants in root. Like before if you don't have root access - beg the person that does to help you with the following step.
1 create a directory called sdcard in your media directory.. this is located in /run/media/<name>/ at the top of your file system. It doesn't have to be called sdcard but as I am the one writing this I got to make some choices right?
obviously when you see <name> look at what your actual account name is on the path.. don't know how to do that.. cut yourself just a little.. not too deep. the pain is the best way to learn. ok joke don't actually do that...
Code: Select all
pwd
next the finale! We mount the newly formatted card.
Code: Select all
su
mount -o defaults,umask=000 /home/<name>/<folder>/<file>.raw /run/media/<name>/sdcard/
exit
Assuming it all went ok.. savour the win, you now have the card mounted and ready for use. When you are done for the day, you can just unmount the image.
Code: Select all
unmount /run/media/<name>/sdcard
Having gone through this manually the next logical step is to create your own script to handle the process or if you are of the FORTH persuasion - a set of words to create a tool that will handle the process. (Come on you knew that was coming..) Because I don't know about you but I don't trust myself messing with dd manually at 3am in the morning..
Once we have the script set up or alternatively a shiny new set of FORTH words we are all set to create card images of any size and format we want till our hard drive space runs out.
One thing I should add is that there are some really obscure settings you can use when formatting the image - its best to check the documentation but if your platform is mentioned then use that switch.
Anyway we now have a reliable way to generate images for use in development projects. Someone wants to see what your up to you just upload the image (assuming its a reasonable size / depending on connection speed and storage space that is going vary from person to person but don't be that guy that uploads a 4gb image with only 200mb of data on it.. ) to the net or burn the image onto a real media for them and they can walk away. No annoying searching for files or wondering if paths will work. This saves so much time.
The use case is your friend walks in asks to take your project home to work on, you ask if you can email him the files he then complains about how long that will take, can't you make it easy? you then ask him for his sd card/usb stick. You then promise not to look at his porn stash as you copy your development card image to the drive/card and he walks away happy yet oddly ashamed. And you now spend the next week poking fun at his choice of fetish subtly in front of unsuspecting friends and family.