LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-17-2014, 01:19 AM   #1
thirun
LQ Newbie
 
Registered: Oct 2013
Posts: 22

Rep: Reputation: Disabled
Write Script to partition and flash the compact flash using card reader in linux


Hi all,

I'm working with Ubuntu 10.0 distribution and i want to write a bash script to flash a Linux uImage and ramdisk image to compact flash using card reader by creating different partitions.

Any one already did this kind of activity, please share the instuctions to do.

Appreciate your help in advance

Regards
Thiru N
 
Old 01-17-2014, 02:59 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Besides 10.0 is quite outdated something like this should work

Quote:
#!/bin/bash
# The devices where the card to be flashed is
CARD=/dev/sdf
# The directory where the images lie
SRC=$(dirname $0/images)

read -p "All data on $CARD will be deleted! Continue? (y/n) line
if [ "$line" = "y"]; then
echo "Foramting disk"
# use fdisk to create on partition
# thats the part to fiddle about
# maybe use cdisk due too this having real script capabilities
(echo n; echo p; echo 1; echo; echo; echo w) | fdisk $LOOP0 >> /dev/null || true
fi
mkfs.ext4 ${CARD}1
mount ${CARD}1 /mnt
cp $SRC/* /mnt
umount /mnt
echo "done"
Something like this.
 
Old 01-17-2014, 03:14 AM   #3
thirun
LQ Newbie
 
Registered: Oct 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
hi Zhjim,

Thanks for your suggestion, but how to verify that its works fine without booting from CF disk?
is there any instructions to verify?


Regards,
Thiru N
 
Old 01-17-2014, 04:44 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Can't think of any easy method to test this. Besides that the partitions got created. Either by checking the return value of the fdisk call or after the script by parsing the output of fdisk.

One could use virtualisation to check that everything is in order. Also it might be easier to just boot from the CF disk.
 
Old 01-17-2014, 06:22 AM   #5
thirun
LQ Newbie
 
Registered: Oct 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB flashgate compact flash card reader htamayo Linux - Hardware 1 11-24-2006 02:22 PM
USB Compact flash card reader with XANDROS dkunjeer Linux - Distributions 2 08-08-2004 08:43 AM
USB Compact flash card reader with XANDROS dkunjeer Linux - Newbie 1 08-03-2004 04:07 PM
USB Compact flash card reader with XANDROS dkunjeer Linux - Hardware 1 08-03-2004 03:35 PM
compact flash card reader mindcry Linux - Hardware 45 02-03-2004 09:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration