[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

auto partition script



A lot of hacks (particularly $END) but it works.
sync is needed to convince the Debian that /dev/sda2 exists.



CF_DEVICE=/dev/sda
CF_DEVICE_SIZE="4G"
END=":fat16"

CF_DEVICE_ID=${CF_DEVICE:(-3)} # just the last three characters eg; sda
from /dev/sda
PARTED=$(parted -lm) # hard disk (CF card) information

#extract prefixes and suffixes from variables
ppref=${PARTED%${CF_DEVICE_ID}*}
ssuff=${PARTED#*${END}}
nopref=${PARTED#${ppref}${CF_DEVICE_ID}} 

device=${nopref%${END}${ssuff}} # Get the relevant device information
FIRST_PART_SIZE=${device##*:} # Remove everything up to the colon to
leave us with eg: "310MB"

#echo ${dev_size}

# remaining disk space for writable section of OS.
parted ${CF_DEVICE} mkpartfs primary ext2 ${FIRST_PART_SIZE}
${CF_DEVICE_SIZE}
sync
e2label "${CF_DEVICE}2" live-rw


Reply to: