2

I have a Raspberry Pi running Openmediavault and I need to expand the main partition as I’m running out of space.

I’ve got a 2013 i7 (64bit) MacBook and I’ve been trying to boot GParted from a usb stick but it keeps crashing. The GParted iso that I used is the AMD64 version (as the Mac is 64bit) - I get through most of the menus but it doesn’t launch the program.

Has anyone got any advice for using GParted on a Mac?

Is there another way to change the partition on the RPi SD?...I have other RPi’s running but I haven’t got a usb card reader.

I do have the option of borrowing a PC laptop from work but I’m not sure if that has an SD reader.

4

You can do it all on the Pi if you have SSH or terminal access, below are some notes I made when I first did it, you shouldn't lose any data if you do it correctly but as always it pays to have a backup just in case :

At a terminal prompt (you may need to amend the partition names depending on your layout/requirements) N.B. the results in this example were based on resizing the partition on an attached 500Gb USB hard drive

Expand partition and filesystem

List existing devices and partitions with sudo fdisk -l

    $ sudo fdisk -l
    Disk /dev/mmcblk0: 7861 MB, 7861174272 bytes
    4 heads, 16 sectors/track, 239904 cylinders, total 15353856 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0002c262

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            8192      122879       57344    c  W95 FAT32 (LBA)
    /dev/sda2          122880     5785599     2831360   83  Linux

Partition to resize is /dev/sda2 make note of Start (122880)

Now run this command:
sudo fdisk /dev/sda

At the prompt (Command (m for help):) type the next letters and then press enter after each:
p

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0002c262

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            8192      122879       57344    c  W95 FAT32 (LBA)
    /dev/sda2          122880     5785599     2831360   83  Linux

d delete partition

2 partition to delete i.e /dev/sda2

p to confirm the deletion

n new partition (default)

p primary (default)

2 partition number (default)
122880 first sector as noted above (N.B. not default)
+50G last sector make size 50Gb (N.B. not default) or take default to use the remainder of the disk

p to confirm new partition is created

w writes the partition information, reboot required if the partition was already mounted (as it was in this instance)

After exit, run:

sudo resize2fs /dev/sda2 to expand the file system to fill the new partition

  • Note that the OP refers to the "main partition", which would be /dev/mmcblk0p1. Here you are working on some other partition, presumably on an attached harddrive, which can easily be unmounted and modified. It is possible to resize the primary partition with the system running, but if you screw it up you will have problems. – goldilocks Jan 27 '18 at 20:29
  • Brilliant, thanks! Just to clarify, I’ll be able to use this to expand an existing partition without destroying any data? – dazzathedrummer Jan 27 '18 at 20:39
  • Yex if you do it correctly but please backup 1st 'just in case' – Bra1n Jan 27 '18 at 22:41
0

You can NOT do this on a Mac, as there is no support for ext4.

While there are (paid) 3rd party programs, the easiest is a live Linux CD.

You CAN do it on the Pi itself. Most Pi OS have raspi-config which includes an option to resize the filesystem.

Failing this it can be done manually, assuming the distribution includes the necessary tools. See

https://ubuntu-mate.community/t/rasberry-pi2-file-system-resizing/2288/8

run sudo fdisk /dev/mmcblk0

Then press the keys in order: 
d 2 to delete,
n p 2 Enter Enter to re-create.

Verify the prompts to make sure what you are entering is sensible.

Reboot and enter:-

sudo resize2fs /dev/mmcblk0p2

This is similar to the other answer, but using Pi partition names.

There is one thing to be wary of. MAKE SURE the new partition STARTS on the same block! If it tries to create a new partition in the spare 3M you will need to manually enter start block. Running sudo fdisk -l /dev/mmcblk0 BEFORE will list existing partitions.

Disk /dev/mmcblk0: 14.5 GiB, 15523119104 bytes, 30318592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6d9a0006

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192    93814    85623 41.8M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      94208 30318591 30224384 14.4G 83 Linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.