zoukankan      html  css  js  c++  java
  • 树莓派扩展分区

    >> [目录] 数据远程采集 Step by Step


    现在来解决在安装树莓派系统时遇到的28GB空闲空间不能被系统使用的问题。image

    用PuTTY远程登录树莓派,查看磁盘状态:

    pi@raspberrypi:~ $ df -h

    image

    系统能识别到的磁盘空间总共只有1.7G,装完系统后已经用了1.1G,还剩470M。


    网络上可以找到两种常用的方法来扩展分区(推荐用第1种):

    方法1:使用raspi-config工具中的Expand Filesystem扩展


    pi@raspberrypi:~ $ sudo raspi-config

    选择 7 Advanced Options,回车

    image

    选择 A1 Expand Filesystem,

    image

    提示如下(下次重启后更新),回车确认:

    image

    退出时会提示是否重启,选择是:

    image


    方法2:使用fdisk、resize2fs命令扩展


    系统安装完成后,SD卡中一共有两个主分区

    /dev/mmcblk0p1:Boot分区,FAT32格式

    /dev/mmcblk0p2:Root分区,EXT4格式

    现在要做的是扩展第2分区(Root区),输入的命令如下:

    1586938602(1)

    1 查询空闲分区(第2分区)的起始地址:

    pi@raspberrypi:~ $ cat /sys/block/mmcblk0/mmcblk0p2/start

    显示的第二分区起始地址是98304,后面会用到。


    2 打开Linux分区表操作工具fdisk

    pi@raspberrypi:~ $ sudo fdisk /dev/mmcblk0

    pi@raspberrypi:~ $ sudo fdisk /dev/mmcblk0
    
    Welcome to fdisk (util-linux 2.29.2).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    

    fdisk 常用指令
    n: 添加新的分区
    p: 查看分区信息
    w: 保存退出
    q: 不保存退出
    d: 删除分区
    t: 改变分区类型


    3 删除原来的第2分区(要修改原来的分区结束地址)

    输入d表示删除分区,输入2表示要删除的分区是第2分区,提示第2分区已经被删除:

    Command (m for help): d
    Partition number (1,2, default 2): 2
    
    Partition 2 has been deleted.
    


    4 重新创建第2分区

    输入n表示添加新的分区,输入p表示要添加的是主分区,输入2表示要添加的分区是第2分区:

    Command (m for help): n
    Partition type
       p   primary (1 primary, 0 extended, 3 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (2-4, default 2): 2
    


    输入第1步得到的第2分区起始地址:XXXX,然后输入第2分区的结束地址,默认就是最大地址,直接回车就好了,提示已经创建了第2主分区,大小为29.7GB。提示分区2包含一个前面,是否要删除,这个一定要选择No,输入n。

    First sector (2048-62333951, default 2048): 98304
    Last sector, +sectors or +size{K,M,G,T,P} (98304-62333951, default 62333951):
    
    Created a new partition 2 of type 'Linux' and of size 29.7 GiB.
    Partition #2 contains a ext4 signature.
    
    Do you want to remove the signature? [Y]es/[N]o: n
    


    5 保存设置

    输入w,保存退出。提示要reboot以后生效。

    Command (m for help): w
    
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Re-reading the partition table failed.: Device or resource busy
    
    The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
    


    6 重启

    pi@raspberrypi:~ $ sudo reboot -h now


    7 调整文件系统大小

    重启后还需要用resize2fs命令来调整文件系统的大小:

    pi@raspberrypi:~ $ sudo resize2fs /dev/mmcblk0p2


    到这里就结束了,确认一下磁盘信息

    pi@raspberrypi:~ $ df –h

    image

    或者用fdisk工具+p命令看一下分区信息

    pi@raspberrypi:~ $ sudo fdisk /dev/mmcblk0

    image

  • 相关阅读:
    [网络流24题]飞行员配对方案问题
    学习笔记——线性基
    HDU 4507 吉哥系列故事——恨7不成妻(数位DP求平方和)
    bzoj1415&洛谷P4206 [NOI2005]聪聪与可可
    后缀自动机(模板+例题)
    最小表示法(模板)poj1059
    求次小生成树(洛谷P4180&bzoj1977)
    KMP poj3942
    最小表示法(模板) CH1807
    数位dp 求山峰数(hill)
  • 原文地址:https://www.cnblogs.com/hotwater99/p/12706713.html
Copyright © 2011-2022 走看看