树莓派扩容,Kali系统,SD卡扩容,ext4
树莓派安装了Kali系统的SD卡扩容问题困扰我很长时间了,最初是安装gparted工具进行扩容树莓派的扩容,但是没弄成功。
最近又想起这个树莓派扩容的事儿来,心情甚是不爽。
在网上查到,有安装raspi-config的,但是我没有弄成功,因为我按方法操作后,在输入raspi-config后的界面中没有“1 Expand Filesystem”这个选项。
https://jingyan.baidu.com/article/d8072ac488553dec95cefdb5.html
https://www.cnblogs.com/small-gray/p/5392044.html
他们的方法大致如下:
apt-get install triggerhappy lua5.1 alsa-utils
dpkg -i raspi-config_20151019_all.deb
0
1
apt-getinstalltriggerhappylua5.1alsa-utils
dpkg-iraspi-config_20151019_all.deb
在终端输入raspi-config,连按两次确定键,重启即可。
—————————————-
树莓派SD卡扩容操作方法如下(有删减,分区、格式化、挂载等操作可参看这里):
# fdisk /dev/mmcblk0 #扩展分区**
...
Command (m for help): p #查看现有分区
...
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 137215 129024 63M c W95 FAT32 (LBA)
/dev/mmcblk0p2 137216 60062499 59925284 28.6G 83 Linux
Command (m for help): d #删除分区2
Partition number (1,2, default 2): 2 #选择要删除的分区号
Partition 2 has been deleted.
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 #选择p,即为主分区
Partition number (2-4, default 2): 2 #选择要新建的分区号
First sector (2048-60062499, default 2048): 137216 #输入删除分区前/dev/mmcblk0p2的起始磁盘柱
Last sector, +sectors or +size{K,M,G,T,P} (137216-60062499, default 60062499): #默认即可
Created a new partition 2 of type 'Linux' and of size 28.6 GiB.
Command (m for help): p #查看修改后的分区
Disk /dev/sda: 28.7 GiB, 30752000000 bytes, 60062500 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2d52e4bb
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 137215 129024 63M c W95 FAT32 (LBA)
/dev/mmcblk0p2 137216 60062499 59925284 28.6G 83 Linux
Command (m for help): wq #保存退出
...
0
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
# fdisk /dev/mmcblk0 #扩展分区**
...
Command(mforhelp):p#查看现有分区
...
DeviceBootStartEndSectorsSizeIdType
/dev/mmcblk0p1819213721512902463McW95FAT32(LBA)
/dev/mmcblk0p2137216600624995992528428.6G83Linux
Command(mforhelp):d#删除分区2
Partitionnumber(1,2,default2):2#选择要删除的分区号
Partition2hasbeendeleted.
Command(mforhelp):n#新建分区
Partitiontype
pprimary(1primary,0extended,3free)
eextended(containerforlogicalpartitions)
Select(defaultp):p#选择p,即为主分区
Partitionnumber(2-4,default2):2#选择要新建的分区号
Firstsector(2048-60062499,default2048):137216#输入删除分区前/dev/mmcblk0p2的起始磁盘柱
Lastsector,+sectorsor+size{K,M,G,T,P}(137216-60062499,default60062499):#默认即可
Createdanewpartition2oftype'Linux'andofsize28.6GiB.
Command(mforhelp):p#查看修改后的分区
Disk/dev/sda:28.7GiB,30752000000bytes,60062500sectors
Units:sectorsof1*512=512bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Disklabeltype:dos
Diskidentifier:0x2d52e4bb
DeviceBootStartEndSectorsSizeIdType
/dev/mmcblk0p1819213721512902463McW95FAT32(LBA)
/dev/mmcblk0p2137216600624995992528428.6G83Linux
Command(mforhelp):wq#保存退出
...
然后重启系统 sudo reboot。
重启完成后,使用 sudo resize2fs /dev/sda2 命令进行实际的空间拓展,等待命令执行完成,再次重启系统,即完成了U盘空间的拓展。
总结:之前我就是没有做resize2fs这步操作,只能说是不会啊。学习了。没有这步操作,分区扩容后不是ext4格式的,所以不能使用。现在好了,树莓派扩容的问题解决了,心情敞亮多了!!!