resize partition manually?

Having trouble with your GBZ build? Ask your questions here!
Post Reply
pajordan
Posts: 33
Joined: Mon Jun 27, 2016 11:24 pm
Has thanked: 53 times
Been thanked: 1 time

resize partition manually?

Post by pajordan » Mon Oct 30, 2017 5:03 pm

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?

User avatar
moooarcuuuus
Posts: 232
Joined: Tue Jul 04, 2017 1:28 am
Has thanked: 2 times
Been thanked: 94 times

Re: resize partition manually?

Post by moooarcuuuus » Fri Nov 03, 2017 2:32 am

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"
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over

User avatar
YaYa
Posts: 1719
Joined: Mon Jun 26, 2017 12:42 pm
Location: brittany - France
Has thanked: 871 times
Been thanked: 689 times
Contact:

Re: resize partition manually?

Post by YaYa » Fri Nov 03, 2017 5:41 am

Normally, flashing with win32disk deletes all partitions and occupy the whole space. I don’t know if other softwares keeps existing partition.
Follow me on instagram Image

User avatar
wermy
Site Admin
Posts: 1346
Joined: Tue May 03, 2016 8:51 pm
Has thanked: 620 times
Been thanked: 1322 times
Contact:

Re: resize partition manually?

Post by wermy » Fri Nov 03, 2017 7:25 am

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.
ImageImageImageImage

pajordan
Posts: 33
Joined: Mon Jun 27, 2016 11:24 pm
Has thanked: 53 times
Been thanked: 1 time

Re: resize partition manually?

Post by pajordan » Sun Jan 07, 2018 11:04 pm

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

pajordan
Posts: 33
Joined: Mon Jun 27, 2016 11:24 pm
Has thanked: 53 times
Been thanked: 1 time

Re: resize partition manually?

Post by pajordan » Tue Jan 09, 2018 11:16 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest