Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to resize partition #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vmayoral
Copy link
Contributor

@vmayoral vmayoral commented Dec 7, 2021

Signed-off-by: Víctor Mayoral Vilches [email protected]

Signed-off-by: Víctor Mayoral Vilches <[email protected]>
Copy link
Collaborator

@jasvinderkhurana jasvinderkhurana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vmayoral , I have a script which I use to increase the partition size, and it does not require any booting or manual inputs, can you pleas evaluate below script as well and let me know your opinion which one is more suitable

#!/usr/bin/env bash
# Short-Description: Resize the root filesystem to fill partition

ROOT_PART=$(mount | sed -n 's|^\(.*\) on / .*|\1|p')
ROOT_DEV=$(echo $ROOT_PART | cut -c 1-12)
PART_NUM=$(echo -n $ROOT_PART | tail -c 1)
MOUNTED=$(mount | sed -n '/^\(.*\)'$PART_NUM' on \/[a-zA-Z0-9].*ext/p')

do_expand_rootfs() 
{
	local target=$1
	local part_num=$2

	if [ -n "${MOUNTED}" ]; then
		echo -e "yes\n100%" | parted ${target} ---pretend-input-tty  resizepart ${part_num} > /dev/null 2>&1
	else
		parted ${target} resizepart ${part_num} 100% > /dev/null 2>&1
	fi
}

ext4_resize() 
{
	if [ "$ROOT_DEV" != "/dev/mmcblk1" -a "$ROOT_DEV" != "/dev/mmcblk0" ]; then
		echo "$ROOT_DEV is not an emmc or sd card. Don't know how to expand"
		exit
	fi

	do_expand_rootfs $ROOT_DEV $PART_NUM && resize2fs $ROOT_PART > /dev/null 2>&1
}

ext4_resize

@jasvinderkhurana
Copy link
Collaborator

@vmayoral ,

I got another simple way to resize the partition, please check if that is more useful and we can publish that in "How-to" section:

$ sudo parted /dev/mmcblk1 resizepart 2

Warning: Partition /dev/mmcblk1p2 is being used. Are you sure you want to continue? Yes/No? yes
End? [6442MB]? 100%
Information: You may need to update /etc/fstab.

$ sudo resize2fs /dev/mmcblk1p2

resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/mmcblk1p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 4
The filesystem on /dev/mmcblk1p2 is now 7267455 (4k) blocks long.

@vmayoral
Copy link
Contributor Author

vmayoral commented Jan 22, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants