Script to increase the size of easy-*.img

Moderator: BarryK

Post Reply
Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Script to increase the size of easy-*.img

Post 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

Last edited by Caramel on Thu Jul 18, 2024 5:39 pm, edited 1 time in total.
User avatar
Flash
Moderator
Posts: 978
Joined: Tue Dec 03, 2019 3:13 pm
Location: Arizona, U.S.
Has thanked: 51 times
Been thanked: 127 times

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

Post by Flash »

3 Gb or GB?

Chaos coordinator :?
Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

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

Post 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)

Post Reply

Return to “EasyOS”