-
Junior Member
registered user
A script to do this (tested by me but you must uncomment some lines at bottom!)
Code:
#!/bin/bash
#
# Description
# Add specified MBs to the size of your knoppix-data.img partition.
# Haven't tested the LIBEXT=aes version. You are liable if you uncomment
# the operational lines below. It worked for me.
# Usage
# sudo ./resizeImg # add default 100 MB to your current img
# sudo ./resizeImg 1000 # add 1000 MB (1GB) to your current img
# Author
# koolb@hotmail.com
#
MYDATA=/mnt/sda2 # make this an area on any HD
set -e # exit on any errors..and do some checking
[ $(id -u) -eq 0 ] || exec echo "You prolly need to be root. You are $(id -nu)"
du | fgrep $(basename $MYDATA) || exec echo "You need to have a $MYDATA mounted"
# review these to see if they need to change for your dist or prefs
ADDMB=${1:-100} # append specified/default 100 Megabytes...
PWD=aes-password # only set this if LIVEXT=aes
#This should be the same for recent knoppix releases
LIVEXT=img # img or aes # Active img extension
BUIMG=$MYDATA/knoppix-data.$LIVEXT # BackUp IMaGe
LIVEDIR=/mnt-system/KNOPPIX # Active img location
LIVEIMG=$LIVEDIR/knoppix-data.$LIVEXT
TMPIMG="$LIVEDIR/$(basename $LIVEIMG .$LIVEXT).bak"
LOOP=$(losetup -f) # get an available loop device
echo "Syncing buffers..."
time sync # optional flush all data/buffers to disk
echo "Copying live to backup..."
time cp -p $LIVEIMG $MYDATA # backup/copy
echo "Adding..."
time dd if=/dev/zero bs=1M count=$ADDMB >> $BUIMG
FS=$BUIMG
[ $LIVEXT = aes ] && echo $PWD | losetup -e $LIVEXT -p 0 -s $LOOP $FS && FS=$LOOP
set +e # bound to have some fixups from live
echo "Cleaning fs..."
time e2fsck -fy $FS # clean the backup
set -e # resize will force exit on error(s)
echo "Resizing..."
time resize2fs $FS
echo "Checking FS again..."
time e2fsck -y $FS # clean after resize
[ $LIVEXT = aes ] && losetup -d $LOOP
# ideally do this in a transaction with rollback upon error
echo "Moving into place..."
#mv $LIVEIMG $TMPIMG # I was able to do this on a live system
#time mv $BUIMG $LIVEIMG # which is one reason why i love Linux!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G
$13.99
Crucial DDR3L 16GB 1600 2x 8GB PC3-12800 Laptop SODIMM Memory RAM PC3 16G DDR3
$13.50
HyperX FURY DDR3 8GB 16GB 32GB 1600 MHz PC3-12800 Desktop RAM Memory DIMM 240pin
$16.50
Crucial DDR3L 16GB 1600 2x 8GB PC3-12800 Laptop SODIMM Memory RAM PC3 16G DDR3
$22.50
8gb DDR4 2400MHz Sodimms (kingston, SK Hynix, Samsung) Laptop/USFF Memory
$11.99
A-Tech 8GB PC3-12800 Desktop DDR3 1600 MHz Non ECC 240-Pin DIMM Memory RAM 1x 8G
$13.99
HyperX FURY RAM DDR4 16GB 8GB 32GB 4GB 3200 2666 2400 2133 Desktop Memory DIMM
$9.64
32GB ECC DDR3 RAM 2x16GB PC3L-12800R Desktop/Server Memory
$11.99
Lot of 20pcs Samsung,SKhynix,ADATA 8GB DDR4-2133P/2400T/2666V Desktop Memory
$166.78
Lot Of 10 Mixed Samsung 16GB 2Rx4 PC4-2133P RDIMM DDR4-17000 ECC Server Memory
$149.99