本教程適用于梅林浴捆、padavan龄寞、LEDE(openwrt)等固件
以下具體方法都基于 ext4,NTFS 相關錯誤不做回答
使用ssh連接路由器汤功,把U盤插到路由器上
我們需要在命令行進行以下4步操作:
安裝fdisk
一般梅林、Padavan 固件都會自帶的溜哮,不用安裝滔金,如果沒有則按照下面給出的命令
$ opkg update
$ opkg install fdisk
# 輸出Configuring fdisk. 并且沒有錯誤
# fdisk就安裝好了
查看你的設備
$ fdisk -l
# 這里先輸出系統分區(qū)之類的不用管,外置設備一般在最后
Disk /dev/sda: 30.7 GB, 30752000000 bytes
64 heads, 32 sectors/track, 29327 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sda1 2 29327 30029824 83 Linux
上面的信息注意看到和你的存儲大小一樣的設備茂嗓,我的是 /dev/sda
餐茵,在它里面有個 /dev/sda1
的分區(qū)
刪除分區(qū)、新建分區(qū)
$ fdisk /dev/sda # 這是你的設備別打成分區(qū)
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.
Command (m for help): d
# 輸入d回車述吸,我只有一個分區(qū)忿族,它自動選擇了,如果你有多個分區(qū)蝌矛,可以多次使用d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n # 輸入n會車道批,創(chuàng)建分區(qū)
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p # 選擇p
Partition number (1-4, default 1): # 回車
First sector (2048-2065023, default 2048): #回車
Last sector, +sectors or +size{K,M,G,T,P} (2048-2065023, default 2065023): # 回車
Created a new partition 1 of type 'Linux' and of size 1007.3 MiB.
Command (m for help): w # 輸入w回車,保存并退出
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
經過以上的操作入撒,你可以用 fdisk -l
命令查看U盤上是否只有一個 Linux 分區(qū)
$ fdisk -l
# 找到你的設備 可以看到ID為83就對了
Disk /dev/sda: 30.7 GB, 30752000000 bytes
64 heads, 32 sectors/track, 29327 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sda1 2 29327 30029824 83 Linux
格式化分區(qū)
分區(qū)已經有了隆豹,現在開始格式化,其實現在的分區(qū)已經是 ext4 格式的了茅逮,不過我們還是對它進行一下格式化璃赡,算是熟悉一下命令,以后直接這樣格式化吧
$ mkfs.ext4 /dev/sda1
# 如果你的硬盤比較大献雅,256G以上的話碉考,是這個命令:mkfs.ext4 -T largefile /dev/sda1
mke2fs 1.43.3 (04-Sep-2016)
/dev/sda1 contains a ext4 file system labelled 'ONMP'
last mounted on Sun Nov 12 09:21:22 2017
Proceed anyway? (y,n) y # 輸入y回車
$ umount /dev/sda1 # 如果出錯,可能是因為已經被掛載了挺身,先執(zhí)行這個卸載
這樣侯谁,U盤就被格式化完了
PS
ONMP 是一個 web 環(huán)境快速安裝腳本,適用于安裝了 Entware 的路由器章钾,目前已經在 Padavan良蒸、LEDE(openwrt)、梅林上測試成功伍玖。
我的文章首先會在 底噪 上發(fā)布