Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Page 2 of 2 < 1 2
Topic Options
#339188 - 07/11/2010 14:11 Re: Apple store is not listing any accessory SSD's for Macbook pros. [Re: drakino]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
You can usually use lsof to see what the current file offset is in order to estimate copy duration.
_________________________
Bitt Faulk

Top
#339209 - 07/11/2010 17:24 Re: Apple store is not listing any accessory SSD's for Macbook pros. [Re: wfaulk]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
Here is a script somebody wrote, and which I modified, to use cp and show a progress bar..
Code:
#!/bin/sh
#
# Simple file/device copy command with a progress bar.
# This is VERY handle for drive-to-drive copies and the like.
#
src="$1"
dst="$2"
if [ "$src" = "" -o "$dst" = "" ]; then
        echo "missing src/dst param(s)" >&2
        exit 1
fi
if [ ! -e "$src" -o ! -r "$src" -o ! -f "$src" ]; then
        if [ ! -b "$src" ]; then
                echo "$src: not a regular file" >&2
                exit 1
        fi
fi
[ -d "$dst" ] && dst="${dst%/*}/${src##*/}"

if [ -e "$dst" -a ! -b "$dst" ]; then
        echo "$dst: already exists, not overwriting it" >&2
        exit 1
fi

if [ -b "$src" ]; then
        total_size=$(grep "\<${src##*/}\$" /proc/partitions | awk '{print $(NF-1) * 1024}')
else
        total_size=$(stat -c '%s' "$src")
fi
if [ "$total_size" = "" ]; then
        echo "$src: unable to determine total size, aborting"
        exit 1
fi

echo "Copying \"$src\" to \"$dst\":"

strace -q -ewrite cp -- "$src" "$dst" 2>&1 |\
        awk '{
                count += $NF
                if (count % 10 == 0) {
                        percent = count / total_size * 100
                        printf "%3d%% [", percent
                        for (i = 0; i <= percent; i++)
                                printf "="
                        printf ">"
                        for (i = percent; i < 100; i++)
                                printf " "
                        printf "]\r"
                }
        }
END { print "" }' total_size=$total_size count=0

Top
#339211 - 07/11/2010 18:14 Re: Apple store is not listing any accessory SSD's for Macbook pros. [Re: mlord]
gbeer
carpal tunnel

Registered: 17/12/2000
Posts: 2665
Loc: Manteca, California
handle handy

Still cool.


Edited by gbeer (07/11/2010 18:14)
_________________________
Glenn

Top
#339212 - 07/11/2010 18:15 Re: Apple store is not listing any accessory SSD's for Macbook pros. [Re: mlord]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Yeah, that's clearly easier than using dd. confused
_________________________
Bitt Faulk

Top
#339216 - 07/11/2010 19:09 Re: Apple store is not listing any accessory SSD's for Macbook pros. [Re: wfaulk]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
Originally Posted By: wfaulk
You can usually use lsof to see what the current file offset is in order to estimate copy duration.

Bah, right, forgot about that.

As for Mark's script, wouldn't have worked for me, as I ran the clone while booted off an OS X DVD. So BSD instead of Linux, no strace on the DVD boot, and no /proc to poke.

I did like how simple cp was to use though for cloning. No worrying about block size tweaks for speed, it just worked. And from what I could tell from initially trying dd, cp ended up finishing a little sooner.

Top
Page 2 of 2 < 1 2