Page 1 of 1

Script to increase the size of easy-*.img

Posted: Thu Jul 18, 2024 5:01 am
by Caramel

First try :

Based on the method explained by @jamesbond (viewtopic.php?p=121957#p121957)

Code: Select all

#!/bin/sh

truncate -s $@

LOOPn="$(losetup -f)"
losetup -f -P $2

{
echo d
echo 2
echo n
echo p
echo 2
echo
echo
echo w
} | fdisk $LOOPn

resize2fs -f "$LOOPn"p2
losetup -d $LOOPn

Make sure the script is executable

Example of use :

If the script is named truncate-easy (EDIT : and in the same directory than the img file)

Code: Select all

./truncate-easy 3G easy-6.1.img

will increase the size of easy-6.1.img to 3G

The format of the size in the arguments is the same as the format for the truncate command.

There is no verification of the arguments, no test about the requested size (must be bigger than the initial size)

Remark: When used in the terminal fdisk ask wether to keep the ext2 signature of a recreated partition,but not when used in the script


Re: Script to increase the size of easy-*.img

Posted: Thu Jul 18, 2024 4:33 pm
by Flash

3 Gb or GB?


Re: Script to increase the size of easy-*.img

Posted: Thu Jul 18, 2024 5:35 pm
by Caramel
Flash wrote: Thu Jul 18, 2024 4:33 pm

3 Gb or GB?

According the man page of truncate G=GiB (gigibyte) (=GB in current language)