How To Upgrade Storage Capacity On A Raspberry Pi
- Adam Douglas
A Raspberry Pi system are a very useful low powered single-board computer (SBC) that can do just about anything. Presently I’m using a Raspberry Pi 2 Model B with Pi-Hole software as a network wide advertisement blocking service. Those interested in setting up your own may follow my knowledge base article, Arch Linux ARM Install Pi-Hole On A Raspberry Pi. Anyway I wanted to take my setup to next level by adding Unbound, a recursive DNS resolver. So I began the process but quickly noticed that I have almost no free storage space left on the system. After quite some time I was able to clear up some log files but nothing substantial enough. The system has a max storage capacity of 8 GB, and it seems this is not enough for my needs. I decided that I’ll replace the Kingston 8 GB microSDHC UHS-I card with a SanDisk 32 GB microSDHC UHS-I card. However, this leaves me with a dilemma, I didn’t want to have to reinstall and configure Arch Linux ARM and Pi-Hole all over again. So I thought why not just image the old microSD card and write it to the new one. After that I should just be able to resize the partition size to utilize the entirety of the 32 GB microSD card. This may seem like a lot of work, but it really isn’t.
Here are the steps I took to get the job done successfully.
The instructions outlined below are done at your own risk. Data loss may occur if not done carefully.
- Linux terminal
- Linux graphical desktop with GParted
- Steps prefixed with a “$” (dollar sign) represents the CLI (command-line interface) prompt
- The text after the “$” is to be entered at the CLI
- Steps prefixed with a “#” (dollar sign) represents the CLI (command-line interface) prompt
- The text after the “#” is to be entered at the CLI
- The partition that will be resized is the last partition on the microSD card
- Powered off the Raspberry Pi.
$ systemctl poweroff
- Removed the microSD card from the Raspberry Pi.
- Insert the microSD card from the Raspberry Pi into computer running Linux.
- Find microSD card device name.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdf 8:80 1 7.4G 0 disk ├─sdf1 8:81 1 100M 0 part /run/media/adam/0E9A-D8D0 └─sdf2 8:82 1 7.3G 0 part /run/media/adam/f2577c9a-c3da-4f5f-aa38-c6a5dbcfbae1
- Umount microSD card.
$ umount /run/media/adam/0E9A-D8D0 $ umount /run/media/adam/f2577c9a-c3da-4f5f-aa38-c6a5dbcfbae1
- Create image of microSD card.
# dd if=/dev/sdf of=pi-hole-alarm-8gb-sd.img
- Remove the microSD card from the computer and set aside for safe keeping.
- Insert the 32 GB SD card into computer.
- Find microSD card device name.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdf 8:80 1 29.7G 0 disk └─sdf1 8:81 1 29.7G 0 part /run/media/adam/3938-3834
- Umount the 32 GB microSD card.
$ umount /run/media/adam/3938-3834
- Write the 8 GB image to the 32 GB microSD card.
# sudo dd if=pi-hole-alarm-8gb-sd.img of=/dev/sdf bs=4MB
- Remove the microSD card from the computer and then insert it again.
Using GParted application, select device “/dev/sdf” in the top right.
Select the partition “/dev/sdf2”.
Click on “Resize/move the selected partition”.
Drag the right arrow all the way to the right and click on the “Resize/Move” button.
Apply changes by clicking on the green check mark icon.
You will receive a warning message similar to the effect of “Editing partitions has the potential to cause LOSS of DATA. You are advised to backup your data before proceeding”. Click on the “Apply” button.
- Close summary report.
- Remove microSD card and begin using on the Raspberry Pi.
I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting 100DaysToOffload.com.
- Arch Linux ARM Install Pi-Hole On A Raspberry Pi
- Arch Linux ARM Operating System Installation
- GParted, Wikipedia
- Micro SD card icon, illustration by Freepik - Flaticon
- Rasberry Pi logo
- Raspberry Pi 2 Model B
Changelog - modified
- correct grammar "for" to "with"
- correct title heading levels from 3 to 2