Copy files to USB media reader.
One of our locations performs the following process to program flash memory cards. They boot a laptop from a Knoppix CD and type the commands in one at at time. I'm trying to build a desktop to accomplish the same task, but I want to boot from the hard drive and put all the commands in one file. I'm using Debian 2.6.18-6-686 and a Kingston FRC-HS219 6-in-1 media reader. This is my first attempt to build a production Linux system; my only previous experience is installing Fedora a couple of times for a few weeks. While I've looked at the man pages, I only about half understand what this does.
The original procedure is below, as copied from a Word file. I'm not sure why they documented each command with 'echo' lines; maybe the contents of the Word file were copied from a now-lost command file. I've numbered each line here to make it easier to reference them; the numbers are not part of the actual commands I'm entering. echo “Mount the Linux hard drive to the Knoppix” 1. mount /dev/hda3 /media/hda3 echo “Move to the Linux Root folder containing the image file” 2. cd /media/hda3/root echo “Burn the image file to the Compact Flash Card” 3. dd if=nia-720.img of=/dev/hde echo “Move to the folder containing the installation file” 4. cd niafs720 echo “Format the Compact Flash Card” 5. sfdisk -f /dev/hde <blank.part> /dev/null 6. sfdisk -f /dev/hde <128mb1.part> /dev/null echo “Make file system” 7. mkfs.ext3 /dev/hde1 echo “Mount the device, IMPORTANT: must specify file system type be ext3” 8. mount –t ext3 /dev/hde1 /mnt/hde1 echo “Install NIA software” 9. tar –zxf instimage.tgz –C /mnt/hde1 10. rm –rf /mnt/hde1/var 11. tar –zxf uss.tgz –C /mnt/hde1 echo “Change the root folder to the Compact Flash Card and run the lilo configuration” 12. chroot /mnt/hde1 13. lilo –v 3 –C etc/lilo.config echo “Exit and umount the Compact Flash Card” 14. exit 15. umount /dev/hde1 Here's what I've got so far. I've determined the appropriate slot in the media reader is /dev/sdb. I created a /mnt/sdb1 directory. I copied nia-720.imp and the niafs720 directory from the original machine into /home. I deleted the first line entirely since it shouldn't be necessary to mount the HD when I'm booting from it. 2. cd /home 3. dd if=nia-720.img of=/dev/sdb 4. cd niafs720 5. sfdisk -f /dev/sdb <blank.part> /dev/null 6. sfdisk -f /dev/sdb <128mb1.part> /dev/null 7. mkfs.ext3 /dev/sdb1 8. mount -t ext3 /dev/sdb1 /mnt/sdb1 9. tar –zxf instimage.tgz –C /mnt/sdb1 10. rm –rf /mnt/sdb1/var 11. tar –zxf uss.tgz –C /mnt/sdb1 12. chroot /mnt/sdb1 13. lilo –v 3 –C etc/lilo.config 14. exit 15. umount /dev/sdb1 Problem - I have been able to execute line 3 only one time. After testing the rest of the procedure, line 3 now returns: dd: opening '/dev/sdb': No medium found. How do I reset this card so I can refer to it as /dev/sdb again? There's plenty more to come if I can get past this issue! |
The first text file indicates to me that it was designed to be a bash script, not instructions for sequentially running commands by hand. The echo lines would print out as the script executes the sequence of commands to give feedback on what the script is doing. This is very typical for bash scripts and the echo syntax is exactly what you see in bash scripts.
In general, the procedure in the first text file appears designed to install a linux system of some sort onto a removable storage device and have it be bootable. From your post, you apparently want to run the same procedure from a script from within a running debian system installed on your hard drive. You have somehow determined that the flash card was given the device file /dev/sdb. From here, it's just not clear to me what is going on. Did you successfully run through the sequence of commands with the second text file and afterwards are unable to rerun them on the same flash card or are you unable to run the same commands on a second flash card? At any rate, with the problem flash card installed in the card reader, post the output of the following command run as root: # fdisk -l That will print out every partition recognized by your system. |
kilgoretrout, here's what I get for 'fdisk -l' after a reboot. Please excuse any typographical errors. I've omitted the results about /dev/hda and included only the /dev/sda results:
Disk /dev/sda: 129 MB, 129024000 bytes 3 heads, 28 sectors/track, 3000 cylinders Units = cylinders of 84 * 512 - 43008 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 2987 125424 83 Linux I also have something new to add. Originally this flash card showed up as /dev/sdb. Now it appears to be referred to as /dev/sda. Is this assigned at random or is there a way to predict how I should refer to this device? I have not attempted to run any of this as a script yet. I'm still entering lines manually at the CLI until I'm comfortable with what each one does and that the procedure as a whole is working. Right now it appears it ain't. Thanks! |
Things that get plugged into USB sockets used to be assigned (pretty much "at random") to the next spare /dev/something. This is still the default behaviour, until you change it to suit your needs.
This led to all sorts of problems like the ones you are experiencing: "I plugged it in, it was mounted at /dev/sda, I unplugged it and plugged it in again, it is not at /dev/sda so where is it mounted now??" udev (kernel 2.6 and above) was designed to solve this problem. It does a very good job at recognising what has been plugged in and then what should be done with it. Things get plugged in. udev starts up. It follows a set of "rules" to decide: - What the device is identifying itself as - Where to mount the device - If any symlinks need to be created eg /dev/production_FlashCard - What to call it - What permissions should be granted to it - Any scripts that should be called automatically once it has been recognised and mounted. Eg when I plug in my camera, a window pops up "Just open in a new window" and "I detected your camera. Import all these photos to /home/me/Photos?" or "Do Nothing". You can write a udev rule that, when you plug in a blank flash card pops up a window to ask "Do this, that, the other or nothing" Debian 2.6.18 should cope with all of this. Here's a good introduction to udev rules: http://www.reactivated.net/writing_udev_rules.html udev rules combined with kdialog are brilliant. Here is an introduction to kdialog: http://www.linuxtopia.org/online_boo...y.html#kdialog The above links should give you an idea of what is possible (it is an awesome concept, and is working). HTH |
You probably will want to monitor /var/log/messages by running "tail -f /var/log/messages" as root and then inserting the card. It looks like the kernel may not be noticing it. /dev/sda is probably your systems hard drive and not the card. If your computer has a built in card reader, a flash card may use something like /dev/mmc_blk0 instead. It depends on the hardware in your computer, the type of the card and the kernel version you are using.
Make sure you didn't boot up with the "noacpi" kernel boot option. This will interfere with the hal and dbus daemons. |
Quote:
On a 2.6 kernel, these things are easier. Also I think Charlie Spencer is running in a business environment (did you just edit that bit of your post out Charlie? It (your IT business address) was there before. That's OK though, I understand, my lips are sealed.) He doesn't want his users to be reading /var/log/messages all the time and issuing cryptic commands depending on what they have read there. He is looking for a simple "Plug the flash card in, click "Install the usual to the flash card", then unplug it". I think. Maybe I am wrong. |
Uh, yeah. What you guys said.
tredegar, it's going to take some serious reading before I'll be able to attempt anything with udev. I'm not using the KDE desktop (or any other; right now this is a CLI-only installation) so I don't know if kdialog will benefit me. jschiwal, when I enter 'tail -f /var/log/messages', what am I looking for? When I first typed it I got several about a dozen lines, all identical except for the time: Aug 12 09:38;19 DT9053 -- MARK -- Now the cursor is sitting after the last line, not at any apparent prompt. When I insert the card, nothing appeared to happen. I'll Google the 'tail' command tomorrow. EDITED: tredegar, apparently we have overlapping posts. Yes, this is a business environment. I don't recall removing my business address; heck, I don't even remember including it. All the editing I've done so far is to add additional details; I don't think I've removed anything. Your description of my end goal is pretty close. Since there's no GUI, replace clicking an icon with entering 'nia'. |
OK
One thing at a time. Quote:
Quote:
Quote:
Quote:
You don't need a GUI for udev to work. But it does make editing files easier. I can use vi but prefer not to. The command line is fine though. You want to write a script called nia ? OK, weird choice of acronym, but we can do it (fingers crossed). Please read up on the writing udev rules link I gave you. Don't bother with kdialog as you are not using a GUI. You should be reading that, thinking "How can I write a rule that identifies what I have plugged in is blank flash-card, and once I have done that, how do I ask udev to run my nia script that does whatever is needed to be done to the flash card". Then try writing a udev rule. Leave the complexities of the nia script for later: just make the script say Code:
#!/bin/bash Test it out. Let us know how you get on. |
I mentioned the "serious reading" only to alert you and jschiwal that it may be a while before I post anything else.
Is it necessary for udev to call the script? Can't the users just type the name in manually and have it run? 'nia' is the first of two scripts, 'fiu' being the other (not my choices). If udev runs nia whenever it detects flash media, how do I tell it which script to run? The media is identical. It strikes me as easier if the user enters which one to run. At this point I'm about ready to tell them to key every line in manually and let them deal with the typing errors. You can make a script executable? I'm carrying a lot of DOS and Windows baggage. I expected the users to be able to run the script similar to the way I'd run a DOS batch file: stick the commands in a file, give it an appropriate name, type the name, press Enter, sit back and watch. Please tell me you're going to get great satisfaction from destroying that ignorant notion. |
It is late here, but here goes, before I sleep:
Quote:
Quote:
Quote:
Linux doesn't care about .exe or .bat extensions. Try renaming a .jpg as a .foo Click on it (but you don't have a GUI) It opens as a .jpg file in your picture viewer. This is neat because linux knows what files are without them having to be labelled with extensions. [Search Engine: Linux magic numbers for more information, but I doubt you need this right now] Any file can be executed if it has the "execute permission bit set". It doesn't matter what it is called. You can set this permission with chmod +x filename Then it is executable, otherwise, it is not. Quote:
I get satisfaction from "Thanks, that worked, and I have learnt something". You need to read up on a lot of stuff, it's educational, and fun when you can make linux work for you: "I made it work" you'll be rightly pleased. Come back when you have further Q's. |
When monitoring /var/log/messages, look at whether there are messages including the disk node and the partition node.
For example, here I am pluggin in a 2gb usb pen drive: Code:
Aug 13 07:00:34 qosmio kernel: usb 8-1.4: new high speed USB device using ehci_hcd and address 24 The rule will look somewhat like this: 60-persistent-storage.rules:KERNEL=="sd*[0-9]|cciss*p[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n" A pattern sd*[0-9] from the kernel will trigger this rule, but it there is no such pattern, then the rule won't get triggered. Better not change a udev rule when it may not be the problem. An external drive may very will have a different device node the next time you plug it in. That is why it is better to use the UUID number or LABEL if you create an fstab entry. However, you said that you saw /dev/sda. If you are using a recent kernel, ide and scsi drives both have /dev/sd# designations, so the /dev/sda drive is probably your boot drive, and the pen drive isn't showing up at all. |
howto card reader -- SD and other media
There are many different media slot in a card reader. For SD card, I can read data by
Code:
mount /dev/sda1 /mnt/<directory> What about other card sony MS and XD? Who ever sucessfully mount these cards? |
Who able to use Sony MS, XD or compact flash media in Linux?
I can do mount for SD but not other cards (having kernel version 2.4) Quote:
|
mine come up as
/dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 Each slot on the card reader is a different drive. Issue the following command before you plug in your card reader and you should be able to see the assignments given to the card reader. tail -f /var/log/messages Code:
it-etch:~# tail -f /var/log/messages |
USB card reader modules in linux 2.4.xx
The reason I can not mount card reader drives is:
I having kernel version 2.4.xx with NO usb_storage, scsi_mod, sd_mod etc I'd like to keep the older version I having. Can I just insert the module files .ko for card reader (usb_storage,scsi_mod,sd_mod) copy from version 2.6 to 2.4 ? Do I need a newer kernell version then customerise/re-compile the things inside? |
Who able to use Sony MS, XD or compact flash media in Linux 2.4.xx?
This thread topic is about copy read files to USB media reader. Wellcome human to post reply to this topic. I think using card reader in Linux deian belong to this topic. |
You have several problems:
1] You have hi-jacked this thread. 2] You are talking to yourself (see [1], and previous posts, by yourself) 3] You are running an "old" kernel, which very few people have any interest in: things move on, and improve, and generally "get better" with newer kernels, Eg kernel 2.6.xx Quote:
If you choose to install the latest stable kernel you will find many improvements. Please try to keep up to date: You are the equivalent of someone saying "I am running MS-DOS 3.0 and I cannot use the internet. I want to keep MS-DOS 3.0, but still want firefox." Please wake up! Quote:
Please just deal with it, and stop complaining at us for help in solving your problems. Instead you should direct your complaints directly to sony. It is their fault that this doesn't work with linux. |
All times are GMT -5. The time now is 04:26 AM. |