-
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
HP ProLiant DL380 Gen9 8SFF Server - E5-2698 v3 - 32Cores - 128GB Ram - 1TB HDD
$299.00
DELL PowerEdge R730 Server 2x E5-2690v3 2.6GHz =24 Cores 32GB H730 4xRJ45
$272.00
Promote Server 2U 24 Bay 4 Node Each: 2x Xeon 18 Cores 64GB RAM X710-DA4 4x 10GB
$999.00
DELL PowerEdge R630 8SFF Server 2x E5-2680v4 2.4GHz =28 Cores 128GB H730 4xRJ45
$379.00
Dell R630 Server 2x E5-2620 V4 2.1GHz =16 Cores 128GB DDR4 1x 960GB 2x 1G 2x 10G
$240.00
HP ProLiant DL360 G9 Server 2x Xeon E5-2690 V3 24 Cores P440ar 128GB DDR4 1x SSD
$279.99
SuperMicro Server 505-2 Intel Atom 2.4GHz 8GB RAM SYS-5018A-FTN4 1U Rackmount
$202.49
Dell PowerEdge R620 Server - 128GB RAM, 2x8c CPU, 128Gb SSD/3x900Gb SAS, Proxmox
$260.00
HP ProLiant DL360 Gen9 Server 2x E5-2620v4 2.1GHz =16 Cores 32GB P440AR 4xRJ45
$220.00
Dell R730xd 26 Port SFF 2x E5-2697v4 36-Cores H730 128GB Server 2x SFP 10G ENT
$490.00