引言
本教程適用于梅林岖免、padavan、LEDE(openwrt)等固件
以下具體方法都基于 ext4照捡,NTFS 相關(guān)錯誤不做回答
使用ssh連接路由器颅湘,把U盤插到路由器上
我們需要在命令行進行以下4步操作:
安裝fdisk
一般梅林、Padavan 固件都會自帶的栗精,不用安裝闯参,如果沒有則按照下面給出的命令
opkg update
opkg install fdisk
# 輸出Configuring fdisk. 并且沒有錯誤
# fdisk就安裝好了
查看你的設(shè)備
fdisk -l
# 這里先輸出系統(tǒng)分區(qū)之類的不用管,外置設(shè)備一般在最后
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
上面的信息注意看到和你的存儲大小一樣的設(shè)備悲立,我的是 /dev/sda
鹿寨,在它里面有個 /dev/sda1
的分區(qū)
刪除分區(qū)、新建分區(qū)
先卸載 U 盤薪夕,如果提示 No such file or directory
沒關(guān)系脚草,說明本來就沒掛載上
# padavan、梅林可以執(zhí)行以下這個推出 usb
ejusb
# 其他固件原献,或者梅林使用以上命令無效玩讳,則可以使用這個命令卸載分區(qū)
umount /dev/sda1
然后分區(qū)
fdisk /dev/sda # 這是你的設(shè)備別打成分區(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): # 輸入 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.
經(jīng)過以上的操作误窖,你可以用 fdisk -l
命令查看U盤上是否只有一個 Linux 分區(qū)
fdisk -l
# 找到你的設(shè)備 可以看到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ū)已經(jīng)有了,現(xiàn)在開始格式化
用 mkfs.ext4
命令格式化秩贰,并且設(shè)置卷標為 onmp
注意: 如果下面的命令提示 /dev/sda1 is mounted
霹俺,則需要先卸載 U 盤,和分區(qū)前卸載的方法一樣
mkfs.ext4 -m 0 -L onmp /dev/sda1
# 如果你的硬盤比較大毒费,256G以上的話丙唧,是下面這個命令:
# mkfs.ext4 -m 0 -L ONMP -T largefile /dev/sda1
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=onmp
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1880480 inodes, 7507456 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
230 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
這樣,U盤就被格式化完了觅玻,拔插 U 盤可以重新掛載想际,或者你想用以下命令掛載也行
mkdir /mnt/onmp
mount -t ext4 /dev/sda1 /mnt/onmp
本文章發(fā)表于底噪博客 https://zhih.me , 轉(zhuǎn)載請注明