|
|
本帖最后由 karl_marx_1818 于 2016-11-5 14:14 编辑
1、插入U盘,通过fdisk -l确定盘符
root@Shanty:~# fdisk -l
...
Device Boot Start End Blocks Id System
/dev/sda1 32 30375935 15187952 c W95 FAT32 (LBA)
2、通过fdisk命令删除原有分区,并创建一个主分区
root@Client:~# fdisk /dev/sda1
(1)按m键进入菜单
(2)按d键删除全部分区
(3)按n键  p键来创建一个主分组(所有参数提示直接回车,使用默认值)
(4)按w键保存退出
3、格式化U盘为ext-4
root@Shanty:~# mkfs.ext4 /dev/sda1
(所有参数提示直接回车,使用默认值)
4、挂载U盘到mnt目录下,拷贝当前 / 和 /overlay 目录下的文件到U盘
root@Shanty:~# mkdir /mnt/sda1
root@Shanty:~# mount /dev/sda1 /mnt/sda1
root@Shanty:~# tar -mC /overlay -cvf - . | tar -mC /mnt/sda1 -xf -
root@Shanty:~# mkdir -p /tmp/cproot
root@Shanty:~# mount --bind / /tmp/cproot
root@Shanty:~# tar -mC /tmp/cproot -cvf - . | tar -mC /mnt/sda1 -x
root@Shanty:~# umount /tmp/cproot
 
5、修改fstab文件
root@Shanty:~# vi /etc/config/fstab
config global
option anon_swap 0
option anon_mount 0
option auto_swap 1
option auto_mount 1
option delay_root 5
option check_fs 0
config mount
option device /dev/sda1
option target /
option fstype ext4
option options rw,sync
option enabled_fsck 0
option enabled 1
option is_rootfs 1
6、重启路由器,确认结果
root@Shanty:~# df -h
Filesystem Size Used Available Use% Mounted on
rootfs 7.0G 60.1M 6.6G 1% / # 已经使用U盘作为rootfs
/dev/root 11.5M 11.5M 0 100% /rom
tmpfs 61.9M 72.0K 61.8M 0% /tmp
/dev/sda4 7.0G 60.1M 6.6G 1% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mmcblk0p1 7.4G 87.3M 7.3G 1% /mnt # SD卡
 
|
|