Results 1 to 10 of 19

Thread: resizing knoppix-data.img

Hybrid View

  1. #1
    Senior Member registered user
    Join Date
    Feb 2010
    Posts
    512

    RE: resizing knoppix-data.img

    I do not know that article and the forum's search functions does not seem to work.

    If the persistent image file is unencrypted then one can make use of the e2fs utilities. My method is to boot the live CD since a filesystem to be resized may not be mounted, to find the persistent image knoppix-data.img, to check the filesystem inside the container, to enlarge the container by adding some bytes to it and to resize the filesystem.

    1. Open a root terminal.

    2. Mount the drive with the persistent image

    3. Change to the directory with that persistent image

    4. Make a backup of the persistent image.

    5. Check the ext2 filesystem and allow corrections
    Code:
    e2fsck -fy knoppix-data.img
    6. Add 100 MB to the container
    Code:
    dd if=/dev/zero bs=1M count=100 >> knoppix-data.img
    Remember that the maximum filesize of the FAT32 filesystem is 4 GB. Therefore the filesize of the persistent image may not be made larger than the maximum filesize of the underlying filesystem. Be careful, use ">>" instead of ">"!

    7. Resize the filesystem.
    Code:
    resize2fs knoppix-data.img
    8. Shutdown the system and boot Knoppix the usual way.

    But if the persistent image is encrypted I think the only way to get a larger persistent image is to create a new persistent image and copy the data from the old filesystem to the new one.

  2. #2
    Moderator Moderator
    Join Date
    Jan 2010
    Location
    Asheville, NC, USA
    Posts
    528
    Quote Originally Posted by klaus2008 View Post
    I do not know that article and the forum's search functions does not seem to work.

    If the persistent image file is unencrypted then one can make use of the e2fs utilities. My method is to boot the live CD since a filesystem to be resized may not be mounted, to find the persistent image knoppix-data.img, to check the filesystem inside the container, to enlarge the container by adding some bytes to it and to resize the filesystem.

    1. Open a root terminal.

    2. Mount the drive with the persistent image

    3. Change to the directory with that persistent image

    4. Make a backup of the persistent image.

    5. Check the ext2 filesystem and allow corrections
    Code:
    e2fsck -fy knoppix-data.img
    6. Add 100 MB to the container
    Code:
    dd if=/dev/zero bs=1M count=100 >> knoppix-data.img
    Remember that the maximum filesize of the FAT32 filesystem is 4 GB. Therefore the filesize of the persistent image may not be made larger than the maximum filesize of the underlying filesystem. Be careful, use ">>" instead of ">"!

    7. Resize the filesystem.
    Code:
    resize2fs knoppix-data.img
    8. Shutdown the system and boot Knoppix the usual way.

    But if the persistent image is encrypted I think the only way to get a larger persistent image is to create a new persistent image and copy the data from the old filesystem to the new one.
    Yes, I think that's so. Unfortunately, that requires space for an extra copy of the data, in addition to what's being added - not such a big deal on a lot of hard drives, but if I want 3GB instead of 2GB for my knoppix-data.img file on a USB-flash that was 8GB to start with and got a 4GB KNOPPIX directory copied onto it when I ran the flash-install utility, I'd run out of room. Guess I'll be using a hard drive when I do it...

    Krishna

  3. #3
    Senior Member registered user
    Join Date
    Dec 2009
    Posts
    423
    Quote Originally Posted by klaus2008 View Post
    But if the persistent image is encrypted I think the only way to get a larger persistent image is to create a new persistent image and copy the data from the old filesystem to the new one.
    This is a very old thread, I thought I just want to post a follow up to this :-

    To increase the size of an encrypted image, the following can be done :-

    # dd if=/dev/zero bs=1M count=100 >> knoppix-data.aes
    ( same as the non-encrypted one )
    # echo 'password' | losetup -e aes -p 0 /dev/loop6 knoppix-data.aes
    ( Now you can use /dev/loop6 for your resizing purposes )
    # e2fsck -fy /dev/loop6
    # resize2fs /dev/loop6
    Once you are done, destroy the loop device association of knoppix-data.aes :-
    # losetup -d /dev/loop6

    Cheers
    Last edited by kl522; 05-24-2010 at 07:22 AM.

  4. #4
    Junior Member registered user
    Join Date
    Aug 2007
    Posts
    16

    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
  •  


Western Digital WD4000FYYZ RE 4TB 7200 RPM 64MB Cache SATA 6Gb/s 3.5

Western Digital WD4000FYYZ RE 4TB 7200 RPM 64MB Cache SATA 6Gb/s 3.5" Hard Drive

$28.60



Seagate ST8000NM0055 8TB 7200RPM 256MB SATA 6.0 Gb/s 3.5

Seagate ST8000NM0055 8TB 7200RPM 256MB SATA 6.0 Gb/s 3.5" Enterprise Hard Drive

$44.74



WD 16TB Elements Desktop, Certified Refurbished Hard Drive - RWDBWLG0160HBK-NESN picture

WD 16TB Elements Desktop, Certified Refurbished Hard Drive - RWDBWLG0160HBK-NESN

$209.99



Seagate Exos X14 12TB SATA6Gb/s 7200RPM 3.5

Seagate Exos X14 12TB SATA6Gb/s 7200RPM 3.5" Enterprise Hard Drive ST12000NM0558

$109.95



HGST Ultrastar DC HC520 12TB SATA 6Gb 256MB 3.5

HGST Ultrastar DC HC520 12TB SATA 6Gb 256MB 3.5" Enterprise HDD- HUH721212ALE601

$82.99



Seagate Exos X14 12TB SATA6Gb/s 7200RPM 3.5

Seagate Exos X14 12TB SATA6Gb/s 7200RPM 3.5" Enterprise Hard Drive ST12000NM0558

$104.95



HP 4TB 3.5

HP 4TB 3.5" 12Gb/s 7.2K SAS Hard Drive P/N: 793674-001 / 803634-001 / 695597-004

$13.99



1TB HDD/SSD 2.5

1TB HDD/SSD 2.5" SATA Hard Drive for Laptop with Win 10/Win 11 Pro Pre-installed

$18.99



Seagate Exos X22 ST22000NM001E 22TB 512E SATA 6Gb/s 3.5

Seagate Exos X22 ST22000NM001E 22TB 512E SATA 6Gb/s 3.5" Enterprise Hard Drive

$311.99



HDD 3.5

HDD 3.5" SATA Hard Drive with Windows 7/Win 10 Installed Legacy

$34.19