Make full use of the SD card space in Raspberry Pi

Source: Internet
Author: User

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 usefdiskExpand 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

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

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

PresspKey to list all partitions. Only the first partition is available.

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

PresspKey to list all partitions. There are two partitions. There are 2nd linux primary partitions and the starting position is the original position.

PresswKey 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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.