有些坑爹发行版比如 Kali Linux 没有附带 raspi-config 这个工具,于是默认状态下用不满 SD 卡。经过查找我找到了提取出来的脚本,以备日后使用。
直接安装方法:
| 1 2 3 4 | sudo wget -O /boot/raspi-expand-rootfs.sh http://dl.linhost.info/file1/raspi-expand-rootfs.sh sudo chmod +x /boot/raspi-expand-rootfs.sh sudo sh /boot/raspi-expand-rootfs.sh sudo reboot | 
原始脚本如下:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/bin/sh # # Resize the root filesystem of a newly flashed Raspbian image. # Directly equivalent to the expand_rootfs section of raspi-config. # No claims of originality are made. # Mike Ray.  Feb 2013.  No warranty is implied.  Use at your own risk. # # Run as root.  Expands the root file system.  After running this, # reboot and give the resizefs-once script a few minutes to finish expanding the file system. # Check the file system with 'df -h' once it has run and you should see a size # close to the known size of your card. #   # Get the starting offset of the root partition PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^2" | cut -f 2 -d:) [ "$PART_START" ] || return 1 # Return value will likely be error for fdisk as it fails to reload the  # partition table because the root fs is mounted fdisk /dev/mmcblk0 <<EOF p d 2 n p 2 $PART_START p w EOF # now set up an init.d script cat <<EOF > /etc/init.d/resize2fs_once && #!/bin/sh ### BEGIN INIT INFO # Provides:          resize2fs_once # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 S # Default-Stop: # Short-Description: Resize the root filesystem to fill partition # Description: ### END INIT INFO . /lib/lsb/init-functions case "$1" in   start)     log_daemon_msg "Starting resize2fs_once" &&     resize2fs /dev/mmcblk0p2 &&     rm /etc/init.d/resize2fs_once &&     update-rc.d resize2fs_once remove &&     log_end_msg $?     ;;   *)     echo "Usage: $0 start" >&2     exit 3     ;; esac EOF chmod +x /etc/init.d/resize2fs_once && update-rc.d resize2fs_once defaults &&   echo "Root partition has been resized. The filesystem will be enlarged upon the next reboot" | 
来源:Expand the Root Partition in Kali Linux for the Raspberry Pi