Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Adafruit Logo
0

Resizing the Raspberry Pi Boot Partition

Image for user pburgess
published May 30, 2016, last edited March 08, 2024
Save Link Note Download
31
Beginner
Skill guide

Edit Partitions

At this point, your “setup” system should be up and running the Raspbian graphical desktop, with networking, keyboard and mouse connected, with the “target” system's SD card in a USB reader connected to one of the setup system’s USB ports.

We’ll use thegparted utility to edit the partition table. This is not installed with Raspbian by default, hence the need for a network connection.

It’s usually fastest and easiest to open a Terminal window and type:

sudo apt-get install -y gpartedsudo gparted
sudo apt-get install -y gpartedsudo gparted
raspberry_pi_add-remove-1.png
raspberry_pi_add-remove-1.png
raspberry_pi_add-remove-2.png
raspberry_pi_gparted.png

If youinsist on using a GUI to install the software, click Pi Menu→Preferences→Add / Remove Software. You’ll find gparted in the “Gnome Desktop” section, or use the search field to locate it. Tick the check box and click “Apply” to install.

You can then run gparted via Pi Menu→Preferences→GParted. You’ll be asked for the root password, since this is a system-level operation.

But really, the Terminal way ismuch quicker.

Select Device

raspberry_pi_device-menu-1.png
raspberry_pi_device-menu-1.png
raspberry_pi_device-menu-2.png

When you first run gparted, it will select theinternal SD card by default.

We want to edit the card in theUSB reader. To do this, use the pop-up menu near the top-right of the window, or theGParted→Devices menu.

It should appear as/dev/sda or similar…the name’s not important, just make sure you’renot selecting /dev/mmcblk0, which is the internal card.

Save /boot Partition Contents

You’ll see a graph and list of at least two partions on the card — the tinyboot partition, and a much larger partition taking up the bulk of the card — and perhaps one or more small “unallocated” spaces.

The unallocated spaces are used to align partitions to specific start and end points on the card. You can ignore these.

The first “real” partition is a FAT16 filesystem…that’s the boot partition on the target system SD card. Note themount point of this partition…it’s probably/media/pi/boot or similar. We’ll need this exact path in a moment.

raspberry_pi_partitions-before-meddling.png

Open a Terminal window if you don’t already have one running, and type the following commands…

cdsudo cp -r /media/pi/boot .
cdsudo cp -r /media/pi/boot .

You may need to change “/media/pi/boot” if a different mount point was shown in gparted. Also, there should be a space between “boot” and the final period.

This copies the full contents of the /boot partition (from the card in the USB reader, not the setup system’s card) to a directory called “boot” in your home folder. This is a temporary measure…we’ll move these files back later.

Unmount Partitions Before Editing

You can not edit partitions while mounted (e.g. accessing files). If there’s akey icon next to one or both partitions, it’s necessary to unmount these filesystems first…

raspberry_pi_partitions-locked.png
raspberry_pi_unmount-1.png
raspberry_pi_unmount-1.png
raspberry_pi_unmount-2.png

Highlight the /boot partition, then selectPartition→Unmount.

As a shortcut, you can also right-click on a partition in the graph or list and select Unmount there.

Repeat for the second (root) partition. There should beno key icons in the list…everything’s editable now.

When everything’s ready, it should look something like this…

raspberry_pi_unmounted.png

Resize the Root Partition

To increase the /boot partition, we first need toshrink the root partition to make space.

Highlight theroot partition (/dev/sda2) and select Partition→Resize/Move(or use the right-click shortcut).

raspberry_pi_root-resize.png
raspberry_pi_root-resize-1.png
raspberry_pi_root-resize-1.png
raspberry_pi_root-resize-2.png
raspberry_pi_root-resize-3.png

The Resize/Move dialog visually shows the full partition size (white) and the amount of data actually present within (yellow).

Because this is a Linux system, there needs to besome space left for caches and log files…or for future updates and additions…we can’t shrink it down to anexact fit.

There’s no hard-and-fast rule for exactlyhow much should be kept free. One third to one half felt “safe”…with Raspbian Jessie Lite, I rounded to an even 2000 MB.

Any surplus should go to theFree space preceding field…Free space following should be 0.

You can do this either with the numeric fields or by dragging and moving the partition graph with the mouse. When it’s adjusted to your liking, click the “Resize/Move” button.

A pop-up dialog will warn about moving partitions. It’s all good, just click “OK.”

Afterward, it should look something like this (though your partition sizes may vary with card capacity and installed operating system version):

raspberry_pi_root-resized.png

The partition map isn’t actually changed on the card yet. Several operations can be queued up and applied all at once…

Create a Larger Boot Partition

This next sequence is thesecret sauce that makes this guide work…

Using gparted’s Resize/Move feature on the boot partition renders the card unreadable on Windows and Mac systems (though it still works with Linux). So the trick here is todelete the existing boot partition,create a new one with the desired size, thenrestore the files there that we backed up earlier.

raspberry_pi_boot-delete.png
raspberry_pi_boot-delete.png
raspberry_pi_boot-deleted.png
raspberry_pi_boot-new.png

Highlight the boot partition (/dev/sda1) and select Partition→Delete (or use the right-click shortcut).

You’ll then have the root partition on the right, and a lot of unallocated space on the left.

Then select Partition→New to begin creating a replacement…

TheCreate new Partition dialog is similar to the Resize/Move dialog, but with some additional options…

raspberry_pi_boot-new-dialog.png

Adjust the size (using the mouse or text fields) to fill the available space, but note that there is an upper limit to the /boot partition size…it cannot exceed 32GB, even on a very large SD card. If there’s room left over, you can edit the root partition again, enlarging it to claim this space, or create extra partition(s) there (these will appear as separate drives, not a contiguous space).

For the other options, select/enter the followingexactly:

  • Create as:Primary Partition
  • File system:fat32
  • Label:boot

Then click the “Add” button.

When you’re done, the partition map should look something like the following. Itmay or may not include small “unallocated” blocks — either way is completely normal, it varies with partition sizes and SD card capacity.

raspberry_pi_new-partition-map.png

Apply Changes

Nothing has actually changed yet; all operations are queued up. Clicking the “Apply” button (the green check mark) will commence reorganizing the data and partitions on the card…

raspberry_pi_apply.png

…but not without warning you first. Take heed, if something goes amiss you might end up with a scrambled card and have to start over from scratch. This is why it’s a good idea to make a backup before any serious disk editing.

raspberry_pi_confirm.png
raspberry_pi_applying-1.png
raspberry_pi_applying-1.png
raspberry_pi_applying-2.png

Once you click “Apply,” the system will be moving around a lot of data…these operations can take a long time, so this is a good opportunity to take a break or tidy up your desk or something.

raspberry_pi_insert.png

Once those operations are complete, you’ll see the same partition map again, but without the “pending” messages at the bottom…everything is now “real” on the card.

To mount the new partitions, it’s easiest just tounplug and re-plug the USB card adapter. You’ll get a “Removable medium” dialog box when you do this (two, actually…one for the boot partition, one for root). Just click “Cancel” for each. We want the partitions mounted but don’t need to browse the files.

Back in gparted now, selectGParted→Refresh Devices and then select/dev/sda from the device list.

It should resemble the following, with a key next to each partition (indicating that it’s mounted). This is with an 8 GB card, with Raspbian Jessie Lite in the root partition, the rest allocated to the /boot partition. There might be one or more small unallocated spaces depending on your card.

raspberry_pi_final-partitions.png

Restore /boot Data

Last step now is to restore the data we saved from the original /boot partition. In a Terminal window, type the following commands.

(If you encounter an error,do not continue with the next command, since the last step deletes all the saved data! Check your typing and that the named directories exist, etc.)

cdsudo cp -r boot /media/pisudo umount /media/pi/*sudo rm -r boot
cdsudo cp -r boot /media/pisudo umount /media/pi/*sudo rm -r boot

Done!

You can quit from gparted now and unplug the SD card reader.

Perform an orderly shutdown of your setup system (Pi Menu→Shutdown…), then swap the SD cards and confirm the system can still boot from the newly-reconfigured card.

Since mine was a Jessie Lite system, this boots to a command line. I can log in and type “df -k” to see the partition sizes and free space, in kilobytes (the mount points “/” and “/boot” are of interest — the root and boot partitions, respectively).

raspberry_pi_Screen_Shot_2016-05-25_at_10.35.46_PM.png

Page last edited May 21, 2016

Text editor powered bytinymce.

Related Guides
Search

Search

Categories

[8]ページ先頭

©2009-2025 Movatter.jp