Make full use of the SD card space in Raspberry Pi
Generally, a 4g sd or TF card is required to create a system image for Raspberry Pi, but do you know if your SD card is 8g or 16g or larger, after various types of Linux are created and started to enter the system, only SD cards within 4 GB can be used, while the other extra parts are blank and no partition space. This is a big waste. If you want to replace the space of the entire SD card, we can usefdisk
Expand the Partition Table of the SD card.
Procedure
Use the fdisk command to perform partition operations (it is best to familiarize yourself with the usage of fdisk before actual operations)
Command Format:
Fdisk <Storage Device Name> // For example: fdisk/dev/sda
After entering fdisk, use the single-key command
M display Help
P list all partitions
D. delete a partition.
N create a partition
W disk to exit
Q: Do not save the disk and exit
Pressp
Key to list all partitions. Two or three partitions are displayed.
- The first partition is FAT32, which is used for guidance.
- The second partition is the Linux primary partition.
- The third partition is the Linux Swap file partition (which may not exist in the virtual machine)
Take note of the Start Sector number of the Linux primary partition (122880 in my imgfile)
Pressd
Select 2 for the key Partition Number (Partition Number) and delete the linux primary Partition (2nd partitions). If there is a linuxSwap Partition, press d to select 3 for the key Partition Number (Partition Number, delete the swap partition (3rd zones)
Pressp
Key to list all partitions. Only the first partition is available.
Pressn
Key to recreate the linux primary Partition
Partition Type (category Type) select P (Primary)
Select 2 for Partition Number (Partition Number)
First Sector (Start Sector) must enter the Start Sector number (my number is 122880)
Use the default value for Last Sector (terminate Sector) and press Enter.
Pressp
Key to list all partitions. There are two partitions. There are 2nd linux primary partitions and the starting position is the original position.
Pressw
Key to save disk to exit fdisk
Next, restart immediately and do not do anything else.
sudo reboot
After restarting and logging on, run the following command:
sudo resize2fs /dev/mmcblk0p2
This command expands the second partition to the new space.
Check hard disk usage. OK
df -h
Operating principle
First, the Linux primary partition and the Swap partition are deleted. The starting position of the re-built primary partition is the same as that of the original primary partition, and then the data of the original primary partition is not changed, but the size of the primary partition is changed.
How to run Ubuntu Snappy Core in Raspberry Pi 2
Install NodeJS on the (Raspberry Pi) Raspberry Pi
Install Weston on Raspberry Pi
Linux OS for Raspberry Pi is available
Raspberry Pi (Raspberry Pi) trial note
Introduction to Raspberry Pi (Raspberry Pi) installation, IP configuration, and software source
This article permanently updates the link address: