前言:在安裝好Go環(huán)境之后萬事俱備只欠東風(fēng)的情況下,我充滿了喜悅众弓,正準(zhǔn)備go get -u github.com/gogits/gogs芋齿,然而fatal: write error: No space left on device說我的磁盤不足了哇,說多了都是淚碗啄,想了想會不會是SD卡還有一部分剩余的容量沒有使用呢,果然不出我所料犬缨。
首先來查看一下系統(tǒng)的磁盤情況
df -h
Paste_Image.png
你會發(fā)現(xiàn):樹莓派只識別出2.9G的容量,雖然如此遇骑,但是還是由辦法解決的。
解決辦法:
pi@raspberrypi ~ $ df -h #查看當(dāng)前磁盤大小羡藐,總大小只有2.9GB
Filesystem Size Used Avail Use% Mounted on
rootfs 2.9G 2.8G 15M 100% /
/dev/root 2.9G 2.8G 15M 100% /
devtmpfs 214M 0 214M 0% /dev
tmpfs 44M 244K 44M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 88M 0 88M 0% /run/shm
/dev/mmcblk0p1 56M 19M 37M 34% /boot
tmpfs 88M 0 88M 0% /tmp
pi@raspberrypi ~ $ cat /sys/block/mmcblk0/mmcblk0p2/start # 查看第二分區(qū)的起始地址贩毕,后面會用到
122880
pi@raspberrypi ~ $ sudo fdisk /dev/mmcblk0 #使用fdisk操作磁盤
Command (m for help): d #d,刪除分區(qū)
Partition number (1-4): 2 # 2仆嗦,刪除第二分區(qū)
Command (m for help): n #創(chuàng)建一個新分區(qū)
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p #創(chuàng)建主分區(qū)
Partition number (1-4, default 2): 2 #分區(qū)2
First sector (2048-7744511, default 2048): 122880 #輸入第一次得到的第二分區(qū)起始扇區(qū)
Last sector, +sectors or +size{K,M,G} (122880-7744511, default 7744511): #最后一個sector辉阶,默認即可Enter
Using default value 7744511
Command (m for help): w #將上面的操作寫入分區(qū)表
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 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)
Syncing disks.
pi@raspberrypi ~ $ sudo reboot #設(shè)置完成需要重啟,sudo reboot
Paste_Image.png
重啟完成之后瘩扼,此時查詢也還是沒有變化的谆甜,還需要如下命令
sudo resize2fs /dev/mmcblk0p2
這時你再來查詢樹莓派的系統(tǒng)磁盤的容量就擴展啦,看圖集绰!
Paste_Image.png
這樣就可以解決樹莓派只識別出SD卡2.9G的容量的問題规辱!
關(guān)于樹莓派文章
樹莓派OS裝機初始化
玩玩樹莓派之自動連接無線路由器
玩玩樹莓派之?dāng)U展SD卡剩余空間
玩玩樹莓派之配置Go環(huán)境