Page 1 of 1

resize partition manually?

Posted: Mon Oct 30, 2017 5:03 pm
by pajordan
Hi, I believe my RetroPie setup isn't utilizing the total available space on the SD card. If I run "lsblk" I get this output:

Code: Select all

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0   7.4G  0 disk
├─mmcblk0p1 179:1    0    56M  0 part /boot
└─mmcblk0p2 179:2    0   3.3G  0 part /
So, does this mean the disk size is 7.4G but the partition size with all my emulators and roms on it is only 3.3G? Can I manually increase the partition size without damaging/affecting any data? I found this article:
https://elinux.org/RPi_Resize_Flash_Partitions
But it looks like you can only do the resizing on an unmounted partition, which I'm guessing I can't do on my SD card from my Pi while it's running. Am I right or is there a way to resize the partition of the SD card without affecting data whilst over SSH?

Re: resize partition manually?

Posted: Fri Nov 03, 2017 2:32 am
by moooarcuuuus
Do you deleted the whole card before flashing? There can be an NTFS-partition or something other on the card.

"parted" is your friend.

0. Find the other partition
1. Delete the third partition
2. Expand with "raspi config"

Re: resize partition manually?

Posted: Fri Nov 03, 2017 5:41 am
by YaYa
Normally, flashing with win32disk deletes all partitions and occupy the whole space. I don’t know if other softwares keeps existing partition.

Re: resize partition manually?

Posted: Fri Nov 03, 2017 7:25 am
by wermy
Here's how you can make it resize the partition on the next reboot (before it's mounted):

Add this to the end of /boot/cmdline.txt (there should only be one line of text in that file - it's important you append it to the end of that so there is still only one line of text when you are done):

Code: Select all

quiet init=/usr/lib/raspi-config/init_resize.sh
Dump this into /etc/init.d/resize2fs_once and chmod +x it:

Code: Select all

#!/bin/sh
### BEGIN INIT INFO
# Provides:          resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 3
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
  start)
    log_daemon_msg "Starting resize2fs_once"
    ROOT_DEV=$(findmnt / -o source -n) &&
    resize2fs $ROOT_DEV &&
    update-rc.d resize2fs_once remove &&
    rm /etc/init.d/resize2fs_once &&
    log_end_msg $?
    ;;
  *)
    echo "Usage: $0 start" >&2
    exit 3
    ;;
esac
Run this:

Code: Select all

sudo systemctl enable resize2fs_once
Then on the next reboot it will resize the filesystem, disable that service and reboot again. This is the same method used to expand the filesystem on a fresh raspbian/retropie install.

Re: resize partition manually?

Posted: Sun Jan 07, 2018 11:04 pm
by pajordan
so, i finally got the time and nerve to try this and it appears my system predates the "systemctl" command; after the

Code: Select all

sudo systemctl enable resize2fs_once
i get: "sudo: systemctl: command not found"

i found this on stackexchange (https://raspberrypi.stackexchange.com/q ... -not-found):
On pre-systemd Debian/Raspian systems you should be able use these commands:

automatically start the service during boot:

update-rc.d resilio-sync defaults


i don't know what i'm doing here - will this work in place of the systemtcl command, or will other syntax in the resize2fs likely not work since i'm on such an older system?:

Code: Select all

update-rc.d resize2fs_once defaults

Re: resize partition manually?

Posted: Tue Jan 09, 2018 11:16 pm
by pajordan
D'oh - there's a very simple way to do what I was after: raspi-config, as described in the first section of this page: https://elinux.org/RPi_Resize_Flash_Partitions (which I originally linked to but also originally overlooked/didn't understand). I used this to expand the main partition to fill the SD card and it worked; to launch, just typed:

Code: Select all

sudo raspi-config
From there it's menu driven; I believe it was the first option.

Bear in mind, this post and this entire thread will likely not apply to anyone seeking help on this forum, since a fresh install of the latest Retropie does this resizing-to-fit-the-SD-card stuff automatically (as indicated by Wermy).