You are not logged in.

#1 2012-10-25 00:48:18

jeff story
Registered: 2009-05-31
Posts: 237

Need some help with script error please

I'm running a script from here: thats not working for me.

It's supposed to partition and format the SD card I'm using for my Arch ARM install.

I get the following output:

    # ./ /dev/sdb
    1024+0 records in
    1024+0 records out
    1048576 bytes (1.0 MB) copied, 0.222972 s, 4.7 MB/s
    DISK SIZE - 15931539456 bytes
    ./ line 24: bc: command not found

     sfdisk [options] <device> [...]

     -s, --show-size           list size of a partition
     -c, --id                  change or print partition Id
         --change-id           change Id
         --print-id            print Id
     -l, --list                list partitions of each device
     -d, --dump                idem, but in a format suitable for later input
     -i, --increment           number cylinders etc. from 1 instead of from 0
     -u, --unit <letter>       units to be used; <letter> can be one of
                                 S (sectors), C (cylinders), B (blocks), or M (MB)
     -1, --one-only            reserved option that does nothing currently
     -T, --list-types          list the known partition types
     -D, --DOS                 for DOS-compatibility: waste a little space
     -E, --DOS-extended        DOS extended partition compatibility
     -R, --re-read             make the kernel reread the partition table
     -N <number>               change only the partition with this <number>
     -n                        do not actually write to disk
     -O <file>                 save the sectors that will be overwritten to <file>
     -I <file>                 restore sectors from <file>
     -V, --verify              check that the listed partitions are reasonable
     -v, --version             display version information and exit
     -h, --help                display this help text and exit

    Dangerous options:
     -f, --force               disable all consistency checking
         --no-reread           do not check whether the partition is in use
     -q, --quiet               suppress warning messages
     -L, --Linux               do not complain about things irrelevant for Linux
     -g, --show-geometry       print the kernel's idea of the geometry
     -G, --show-pt-geometry    print geometry guessed from the partition table
     -A, --activate[=<device>] activate bootable flag
     -U, --unhide[=<dev>]      set partition unhidden
     -x, --show-extended       also list extended partitions in the output,
                                 or expect descriptors for them in the input
         --leave-last          do not allocate the last cylinder
         --IBM                 same as --leave-last
         --in-order            partitions are in order
         --not-in-order        partitions are not in order
         --inside-outer        all logicals inside outermost extended
         --not-inside-outer    not all logicals inside outermost extended
         --nested              every partition is disjoint from all others
         --chained             like nested, but extended partitions may lie outside
         --onesector           partitions are mutually disjoint

    Override the detected geometry using:
     -C, --cylinders <number>  set the number of cylinders to use
     -H, --heads <number>      set the number of heads to use
     -S, --sectors <number>    set the number of sectors to use

    umount: /dev/sdb1: not mounted
    mkfs.vfat 3.0.12 (29 Oct 2011)
    umount: /dev/sdb2: not mounted
    mke2fs 1.42.4 (12-June-2012)
    Filesystem label=ALARM
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    336672 inodes, 1345536 blocks
    67276 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=1379926016
    42 block groups
    32768 blocks per group, 32768 fragments per group
    8016 inodes per group
    Superblock backups stored on blocks:
       32768, 98304, 163840, 229376, 294912, 819200, 884736

    Allocating group tables: done                           
    Writing inode tables: done                           
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done 

The script:

#! /bin/sh
# v0.5
# (c) Copyright 2009 Graeme Gregory <>
# Licensed under terms of GPLv2
# Parts of the procudure base on the work of Denys Dmytriyenko

export LC_ALL=C

if [ $# -ne 1 ]; then
	echo "Usage: $0 <drive>"
	exit 1;


dd if=/dev/zero of=$DRIVE bs=1024 count=1024

SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`


echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE

sleep 1

if [ -b ${DRIVE}1 ]; then
	umount ${DRIVE}1
	mkfs.vfat -F 32 -n "boot" ${DRIVE}1
	if [ -b ${DRIVE}p1 ]; then
		umount ${DRIVE}p1
		mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
		echo "Cant find boot partition in /dev"

if [ -b ${DRIVE}2 ]; then
	umount ${DRIVE}2
	mke2fs -j -L "ALARM" ${DRIVE}2
	if [ -b ${DRIVE}p2 ]; then
		umount ${DRIVE}p2
		mke2fs -j -L "ALARM" ${DRIVE}p2
		echo "Cant find rootfs partition in /dev"

I posted this on their forums, but I don't think theres a whole lot going on there based on the amount of unanswered questions in my Pandaboard subforum. I hoping to be able to tap into the knowledge here to get some help.

Thanks in advance ......

Check out my website for info on the Arch Linux Installer


#2 2012-10-25 01:04:57

From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,316

Re: Need some help with script error please

The error message says you don't have bc installed


#3 2012-10-25 03:06:45

jeff story
Registered: 2009-05-31
Posts: 237

Re: Need some help with script error please

Thanks skunktrader,

Feeling kinda silly now looking at this. Would have known without thinking, this error was from a missing package using the terminal for most things.

Somehow, likely the excitement of my first Arch install on ARM based hardware, made me completely forget nearly everything I have learned as a Linux user to date.

Also, the  ./ line 24: bit may have distracted me from seeing the obvious.

Check out my website for info on the Arch Linux Installer


Board footer

Powered by FluxBB