温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

OpenWrt系统怎么搬到U盘中

发布时间:2021-08-20 09:10:59 来源:亿速云 阅读:336 作者:chen 栏目:互联网科技

这篇文章主要介绍“OpenWrt系统怎么搬到U盘中”,在日常操作中,相信很多人在OpenWrt系统怎么搬到U盘中问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”OpenWrt系统怎么搬到U盘中”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

首先ssh登录路由。

一、对u盘分区

root@OpenWrt :~# fdisk /dev/sda

Command (m for help): n #输入n新建一个分区,回车

Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): #默认主分区,直接回车

Using default response p.
Partition number (1-4, default 1): #分区编号,默认,直接回车
First sector (2048-8235007, default 2048): #起始扇区,默认,直接回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-8235007, default 8235007): +1G #输入+1G回车,分区大小设定为1GiB

Created a new partition 1 of type 'Linux' and of size 1 GiB.

#其他分区与上类似,省略。。。。。。

Command (m for help): w #按w回车保存退出
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
二、格式化分区
root @OpenWrt :~# mkfs.ext4 /dev/sda1 -O ^has_journal,extent -L hg255d
在EXT4文件系统下,使用"-O ^hasjournal,extent"参数格式化可以提高读取大文件的性能。
三、拷贝根目录“/”下的所有文件到U盘
root @OpenWrt :~# mount /dev/sda1 /mnt -t ext4 #挂载U盘第一个分区到/mnt
root @OpenWrt :~# mkdir /tmp/root #/tmp下创建root目录
root @OpenWrt :~# mount -o bind / /tmp/root #挂载并同步系统根目录“/”到/tmp/root
root @OpenWrt :~# cp -a /tmp/root/* /mnt/ #拷贝/tmp/root下所有文件到U盘
root @OpenWrt :~# umount /tmp/root #卸载/tmp/root
修改/mnt/etc/banner,如此便可知道是不是从U盘启动了。
root @OpenWrt :~# vi /mnt/etc/banner
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 BARRIER BREAKER (Bleeding Edge, r41302)
  From USB device...  #添加的标识                      
 -----------------------------------------------------
  * 1/2 oz Galliano         Pour all ingredients into 
  * 4 oz cold Coffee        an irish coffee mug filled
  * 1 1/2 oz Dark Rum       with crushed ice. Stir.
  * 2 tsp. Creme de Cacao                             
 -----------------------------------------------------
root @OpenWrt :~# umount /dev/sda1 #卸载/dev/sda1
四、修改/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 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/sda2'
	option fstype 'ext4'
	option enabled '1'
	option options 'rw,sync'
	option target '/'

五、重启路由

重启路由后,ssh登录路由。打印的banner信息中看到我们加的标识就代表已经把系统搬到U盘里了。

到此,关于“OpenWrt系统怎么搬到U盘中”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI