在使用Win32DiskImager为一张空白的SD卡刷入新的Rasbian系统后,卡上的可用剩余空间并不大,

本人有一张8G的SD卡,但是刷入4.1的Rasbian后,用df -h查看,根目录下的空间使用率居然是99%,而且总空间也就3.5G左右。

原因是因为Rasbian的image是为2G SD卡(这应该指的是Wheezy版本,Jessie版本应该是3.5G或者更多)准备的,如果想用剩余空间,就得重新分配分区。

来自官方的解释如下:

The prepared images for the Raspberry Pi are created for SD cards of the size of 2GB. The SD card can be resized or restructured to use the full size of a SD card that is greater than 2GB.

OK,下面就是具体方法(来自 elinux.org):

Manually resizing the SD card on Raspberry Pi

You can also resize the partitions of the SD card that your Pi is running on.

First you need to change the partition table with fdisk. You need to remove the existing partition entries and then create a single new partition than takes the whole free space of the disk. This will only change the partition table, not the partitions data on disk. The start of the new partition needs to be aligned with the old partition!

Start fdisk:

sudo fdisk /dev/mmcblk0

Then delete partitions with d and create a new with n. You can view the existing table with p.

  • p to see the current start of the main partition
  • d3 to delete the swap partition
  • d2 to delete the main partition
  • n p 2 to create a new primary partition, next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on the Debian image from 2012-04-19 starts at 157696, but the start of your partition might be different. Check the p output!
  • w write the new partition table

Now you need to reboot:

 sudo shutdown -r now

After the reboot you need to resize the filesystem on the partition. The resize2fs command will resize your filesystem to the new size from the changed partition table.

sudo resize2fs /dev/mmcblk0p2

This will take a few minutes, depending on the size and speed of your SD card.

When it is done, you can check the new size with:

df -h

事实上老外也早早有遇到类似问题,在stackoverflow上问过:

How can I resize my / (root) partition?

可能有人不喜欢慢慢看英文,下面就来段中文的,摘录自网络

步骤1: 重新启动你的电脑,不要启动X windows

步骤2: $ sudo df -h
你应该会看到/ 挂载于rootfs(已使用97%左右)。 步骤3: $ sudo fdisk /dev/mmcblk0
命令:按P(印刷)
你应该会看到三个分区,现在把分区2的信息写下来(/dev/mmcblk0p2)。
命令:按d(删除分区2)
命令:按p(印刷)
现在应该会看到2个分区
命令:按n(加分区)
选择P (主要)
於分区2选择2
第一空格输入原来分区2的开始位置
最后的空格输入默认值
命令:按p(印刷)
你应该會看到分区2填满所有空间
命令:按w(保存) 步驟4: $sudo reboot
重新启动后,使用resize2fs来修复分区2 步驟5: $ sudo resize2fs /dev/mmcblk0p2
等待约2-3分钟 步驟6: $ sudo df -h
你应该會看到 / 挂载於rootfs(如果你使用8G SD卡,现在只会有22%的使用) 这样你便可以善用SD卡余下的空间了。

当然也有人根据elinux.org的建议,在ubuntu或者其它linux系统上使用gparted来对SD卡重新分配空间,可参考下面这篇博客,本文就不细述了。

树莓派Raspberry Pi 16G SD卡刷系统时默认空间扩容

最新文章

  1. 读书笔记--SQL必知必会--Tips
  2. PHP乱码问题,UTF-8(乱码) (share)
  3. c语言自定义BOOL函数
  4. 矩阵乘法快速幂 codevs 1250 Fibonacci数列
  5. geotools解析SLD中的elsefilter为什么里面的filter无效
  6. B. Quasi Binary
  7. bzoj4160: [Neerc2009]Exclusive Access 2
  8. Android手势识别(单击 双击 抬起 短按 长按 滚动 滑动)
  9. 小猪的Android入门之路 Day 4 - part 1
  10. centos 7.1搭建docker本地私有仓库返回500错误
  11. Java基础语法<七> 对象与类
  12. httpclient的主要业务代码逻辑(图解)
  13. Python系列之 - 反射
  14. ZZZPHP1.61 代码审计-从SQL注入到Getshell
  15. SuperMap iObject入门开发系列之二地下三维管线系统介绍
  16. MyBatis异常:元素内容必须由格式正确的字符数据或标记组成
  17. Python获取当前时间及时间转换(datetime)
  18. JSONObject的toBean 和 fromObject
  19. Oracle-归档日志详解(运行模式、分类)
  20. android alipay

热门文章

  1. Kettle的概念学习系列之Kettle是什么?(一)
  2. web监控脚本
  3. 优动漫PAINT-紫藤花画法
  4. H5页面在线制作工具搜集
  5. mysql日期加减运算
  6. vue源码之响应式数据
  7. 项目集成Hudson+SonarQube出现的一个问题
  8. nginx模块开发
  9. ZOJ2326Tangled in Cables(最小生成树)
  10. java中多线程知识