ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: Script to "Grow" Fourth Partition of T.S. SD Cards

To:
Subject: Re: [ts-7000] Re: Script to "Grow" Fourth Partition of T.S. SD Cards
From: Russ Nelson <>
Date: Wed, 16 Jun 2010 13:50:00 -0400
Rule #1 for hacking on other people's code: don't make style changes.
If you can't respect their style, write your own code.  So, none of
these changes were style preferences.  All were made because the
original code didn't work on 2.6.29.  Well, you could argue about the
'df' param and the rmdir, and I wouldn't argue against you.

There's no $EUID environment variable, nor is there a [[ program.
There's no file named $NUMBER, ever.  The TS-wifibox disk has two
type-83 partitions.

By the way, I'm (right now) working on a script which sets up
connectivity on a TS-7400 (upgraded to Lenny running 2.6.29).  If it
finds a Verizon cell data modem, it uses that.  If it finds one of the
ASUS wifi sticks that you tell, it uses that.  Otherwise, it falls back
on the Ethernet.  Happy to share it with everyone once it's done.

On Wed, 2010-06-16 at 16:58 +0000, Derek wrote:
> 
> Russ,
> 
> Thanks for reviewing it.  I can see now that there were a few spots that I 
> may have rushed through without thinking of optimizations.  Some of the 
> changes you made were simply style preferences.  The overall script wasn't 
> changed.  For those of you interested, here are the differences:
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> --- grow_sd   2010-06-16 09:45:42.000000000 -0700
> +++ ../home/derek/public_html/Grow_SD_Card/grow_sd    2010-05-07 
> 17:07:52.367938274 -0700
> @@ -23,7 +23,7 @@
>  # a 2GB SD card in both JFS and EXT3 filesystem formats.
>  
>  # CHECK FOR ROOT ACCESS
> -if [ `id -u` -ne 0 ]; then
> +if [[ $EUID -ne 0 ]]; then
>     echo "This script must be run as root" 1>&2
>     exit 1
>  fi
> @@ -40,8 +40,8 @@
>  # CHECK DISK AND PARTITIONS
>  if [ -e $1 ]; then
>       DISK=$1
> -     NUMBER=`fdisk -l $DISK | grep 83 | tail -1 | awk '{print $1}' | sed 
> "s,$DISK,,g"`
> -     if [ ! -e ${DISK}$NUMBER ]; then
> +     NUMBER=`fdisk -l $DISK | grep 83 | awk '{print $1}' | sed "s,$DISK,,g"`
> +     if [ -e $NUMBER ]; then
>               echo "Valid TS partition not found!"
>               echo "Exiting"
>               exit 1
> @@ -55,9 +55,8 @@
>  expand_sd(){
>       mkdir /mnt/tmp 2> /dev/null
>       mount ${DISK}$NUMBER /mnt/tmp 2> /dev/null
> -     TYPE=`df -T /mnt/tmp | awk '{print $2}'`
> +     TYPE=`df -T | grep ${DISK}$NUMBER | awk '{print $2}'`
>       umount ${DISK}$NUMBER 2> /dev/null
> -     rmdir /mnt/tmp 2> /dev/null
>  
>       ORIG=`fdisk -l $DISK | grep ${DISK}$NUMBER | awk '{ print $3 }'`
>       SIZE=`fdisk -l $DISK | grep Disk | awk '{print $5}'`    
> @@ -84,7 +83,7 @@
>  echo "Systems customers.  There are no guarantees or warranties.  Please 
> backup"
>  echo "your data before running this. Also, keep in mind that the JFS 
> filesystem"
>  echo "can grow, but cannot shrink again." 
> -echo -n "Do you wish to proceed <y or n>? "
> +echo -e "Do you wish to proceed <y or n>? \c"
>  read WISH
>  
>  if [ $WISH = "n" ] ; then
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> 
> Thanks again, Russ.  Overall, have you (or anybody else reading this) found 
> this script to be useful?
> 
> Best Regards,
> Derek Hildreth
> Embedded Systems Engineer
> Technologic Systems
> 
> 
> --- In  Russ Nelson <> wrote:
> >
> > Hi, Derek.  I made a few changes to your script.  I hope you think
> > they're improvements.  Feel free to share them with the mailing list.
> > 
> > 
> > On Thu, 2010-05-27 at 00:52 +0000, Derek wrote:
> > > Hello,
> > > 
> > > Some of you might find this of use...
> > > 
> > > I have recently taken some time to create a script that will 
> > > automatically expand the fourth partition of a Technologic Systems SD 
> > > card to take up the full capacity of your SD card (works with JFS and 
> > > EXT3).  
> > > 
> > > For example, say you have the 512MB SD image for a TS-7350 or TS-7800 and 
> > > you have just imaged a 4GB SD card with it.  Now, you want to take 
> > > advantage of the additional 3.5GB for Debian.  Simply run this script 
> > > like "grow_sd /dev/sdb" (assuming /dev/sdb is the device node  where your 
> > > SD card was enumerated; use "fdisk -l" to find out) and the script will 
> > > do it for you.
> > > 
> > > You can download this script here (may need to "right-click -> save 
> > > target as..." to download):
> > > 
> > > http://oz.embeddedarm.com/~derek/Grow_SD_Card/grow_sd
> > > 
> > > I tested it out on a couple of different cards (both jfs and ext3) with 
> > > success.  Just remember to back up your data.  This script doesn't come 
> > > with any sort of warranty.  ;)
> > > 
> > > Be sure to check out the comments within the script for more information.
> > > 
> > > Best Regards,
> > > Derek Hildreth
> > > Embedded Systems Engineer
> > > Technologic Systems
> > > 
> > > 
> > > 
> > > 
> > > ------------------------------------
> > > 
> > > Yahoo! Groups Links
> > > 
> > > 
> > >
> >
> 
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
> 
> 
> 



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU