In my defense, I've been spoiled by the draktools disk manager. It presents a great graphic display of hard drives and USB storage for managing partitons, mount points and mount permissions. I even slap Mandriva Free in ahead of other OS installs so I can cancel out of the custom install right after the disk manager writes the partition table. GNU Parted is more the defacto GUI partition manager which can be had easily with the GParted liveCD or Parted Magic liveCD (meant as disk management liveboot rather than my Mandriva installer method). I noticed the sfdisk man page listed GNU Parted so that's my bit on that.
Using a full GUI desktop install as your initial development platform is a good plan. You can always do the customized production install once the process is confirmed and your more comfortable at the prompt.
For viewing mounted partitions, you can probably leave the "-l" off the mount command. Actualy, any of the following should give you information:
fs - list file system usage and mount points.
mount - by default, will list mounted media and mount permissions, I use it as a second look if the first doesn't answer my questions.
cat /etc/fstab
more /etc/fstab - some people like to stick with the old ways so one can simply "type" the fstab and see what the system has mounted.
That's also my order of preference for viewing mount points.
Q1, I'd say yes. play it safe and include the umount command where applicable. A script doesn't care about one more command in the sequence.
The way it works here is that a partition is mounted to a directory resulting in the tree of subdirectories and folders on that partition. As files are read and changed, they are kept in memory and periodically written back to the partition. This means less writes to eat the drive read/write limit and less fragmentation. Media needs to be unmounted giving the system the chance to sync up any outstanding changed data between memory and the media. It then lets go of the media uncoupling it from the mount point it apears as.
This same thing can be seen with Windows management of flashdrives. Removing a flashdrive without "safely remove .." from the taskbar icon can damage the data because outstanding changes may get left unwritten.
Both platforms can also be told to keep the mounted media in sync at all times too of course.
But.. the point is that umount is better to do and not need rather than not do.
I suspect HAL is mounting the partition after you create it. (not just a red dot and smooth voice). HAL is a program that watches for hardware changes and responds. I don't know it it only watches USB or only storage either way, it also watches USB and storage.
Based on the mount point, I'd say HAL is the ghost in your system. It is spotting the valid partition /dev/sda1 and mounting it to /media/usb0 as a default location. It will normally use the partition label if one is available (ex. /media/mydisk if your disk is labelled "mydisk").
If you are writing an image file with DD, you won't want the partition mounted. If you where copying the data as directories/files with cp or a similar command then you would want the partition mounted.
Not mounted:
dd if=data.img of=/dev/sda1
Mounted:
cp -r /archives/data/* /mnt/usb0
I'm new to using fsdisk (partitioning SD for my Maemo PDA; SD with three partitions blows my mind).
For DD, think of it like "rawwrite" if you've used the Windows program to write .bin or .img files to a diskette. Copy reads the directories and files you want to move and duplicates them in the new location. DD reads the 1s and 0s you want to copy and writes the same order of 1s and 0s to the destination.
In another case where I made things harder than they had to be out of Windows habit; I wanted to pull an ISO of a CD for a VM rather than mount the distro install disk through the physical disk reader. In windows, Nero, winISO and a list of other programs do this for the user so I went looking for some sort of LinISO type thing. And, what was the archaine series of hoops I had to jump through eventually to get my ISO?
dd if=/dev/cdrom of=/home/user/cdrom.iso
I kicked myself for a day over how easy that little thing was; especially after years of writing image files the other way for diskette driven network installs of Red Hat and Mandrake.
Q4. use /dev/disk/by* contained file entries the same way you use /dev/sda. If you go into your by-uuid directory and do a "ls -l" you should see what actual device the virtual device points back too. (I should have thought to mention that earlier.) In my own machine right now I have the following:
lrwxrwxrwx 1 root root abc123def456 -> ../../sda1
(modified to remove specifics)
So, uuid abc123def456 is a link (man ln) pointing to /dev/sda1 using a relative path.
If you are mounting /dev/sda1, you can also mount /dev/disk/by-uuid/abc123def456. dd or sfdisk should also work through the uuid provided your "ls -l" shows it pointing to the right device ahead of time.
I'm still understanding the sfdisk steps myself so I can't help much there yet but I'll step through your commands and hopefully be repeating what you already know:
# cd /home
Switch to the home directory, this should be modified to your user directory; cd /home/palmetto or cd ~/ (home directory for applicable uname)
# dd if=nia-720.img of=/dev/sda
raw copy the image contained in blah.img to media recognized as device /dev/sda. This is writing the disk image just like taking a .iso and writing the binary image to CD/DVD.
# cd niafs720
change to the niafs720 subdirectory. Based on your commands, that's /home/niafs720 though I would make it a subdirectory of the applicable user. In your case, /home/palmetto/niafs720. This is only to keep all your user activities within your own area (~/).
# sfdisk -f /dev/sda /dev/null
I've only used sfdisk interactively so I'm not sure what this longer command is doing other than forcing (-f) the command. /dev/null is, well, null so it looks to be writing blank to the device/partition (blank.part?).
# mount -l
You can use "mount" without the "-l" porbably. it should default to listing mounted partitions without any command switches.
# umount /media/usb0
unmounts the automounted partitoin sda1 by specifying the mount point /media/usb0 used to identify it.
# sfdisk -f /dev/sda /dev/null
# sfdisk -f /dev/sda <128mb1.part> /dev/null
My understanding is that DD could be used to create the partition and contained data all at once from the image file so the fsdisk is throwing me. It does seem like you create the disk and image then blow it away by mucking the partition tables. I have to read Seanferd's comment though as he may have answered it already.
What files do you have or what are the "supplies" and end result your after? Are there more files involved other than the one .img file written with DD?
nia-720.img <- a file you have
blank.part <- is this a file?
128mb1.part <- is this a file?
So, with that/those initial files, you need to take a blank SD (MMC or such) and write the nia-720.img too it? The result is the written data then placed into the hardwar product as the authentication or unit unique data with the unit's own OS code on a ROM chip? (or, is this the OS/control software on the SD or MMC?)
Sorry to go back to the beggining again. Reviewing the intended goal and materials (img files) without the specific steps may result in a cleaner process for you.