原文地址:http://blog.pickbox.me/2013/08/28/tp-link-tl-wr703n%E8%B7%AF%E7%94%B1usb%E5%8F%A3%E7%94%A8%E9%80%942-%E6%8C%82%E8%BD%BDu%E7%9B%98%EF%BC%8C%E4%BB%8Eu%E7%9B%98%E5%90%AF%E5%8A%A8/
这里先在自己的主Linux系统中格式化好U盘,就不用在Openwrt中格式化U盘了
挂载U盘需要安装一些pkg模块,我的空间不够用了,于是先恢复到刷Openwrt固件的原始状态(出厂设置)
重启路由的时候按住reset,可以看到蓝色LED灯闪烁,接着很快的闪烁,说明进入了恢复模式
这时用telnet登陆到192.168.1.1(电脑用网线连接到wr703n的LAN口),运行
mount_root firstboot reboot -f
这样就恢复到了固件的初始状态
接下来安装pkg
root@OpenWrt:/etc/config# opkg update Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/Packages.gz. Updated list of available packages in /var/opkg-lists/attitude_adjustment. root@OpenWrt:/etc/config# df Filesystem 1K-blocks Used Available Use% Mounted on rootfs 1088 216 872 20% / /dev/root 2048 2048 0 100% /rom tmpfs 14608 672 13936 5% /tmp tmpfs 512 0 512 0% /dev /dev/mtdblock3 1088 216 872 20% /overlay overlayfs:/overlay 1088 216 872 20% / root@OpenWrt:/etc/config# opkg install kmod-usb-storage block-mount kmod-fs-ext4 Installing kmod-usb-storage (3.3.8-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/kmod-usb-storage_3.3.8-1_ar71xx.ipk. Installing kmod-scsi-core (3.3.8-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/kmod-scsi-core_3.3.8-1_ar71xx.ipk. Installing block-mount (0.2.0-9) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/block-mount_0.2.0-9_ar71xx.ipk. Installing blkid (2.21.2-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/blkid_2.21.2-1_ar71xx.ipk. Installing libblkid (2.21.2-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/libblkid_2.21.2-1_ar71xx.ipk. Installing libuuid (2.21.2-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/libuuid_2.21.2-1_ar71xx.ipk. Installing swap-utils (2.21.2-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/swap-utils_2.21.2-1_ar71xx.ipk. Installing kmod-fs-ext4 (3.3.8-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/kmod-fs-ext4_3.3.8-1_ar71xx.ipk. Installing kmod-lib-crc16 (3.3.8-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/kmod-lib-crc16_3.3.8-1_ar71xx.ipk. Configuring kmod-scsi-core. Configuring kmod-usb-storage. Configuring kmod-lib-crc16. Configuring libuuid. Configuring libblkid. Configuring blkid. Configuring swap-utils. Configuring block-mount. Configuring kmod-fs-ext4. root@OpenWrt:/etc/config# df -h Filesystem Size Used Available Use% Mounted on rootfs 1.1M 640.0K 448.0K 59% / /dev/root 2.0M 2.0M 0 100% /rom tmpfs 14.3M 680.0K 13.6M 5% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/mtdblock3 1.1M 640.0K 448.0K 59% /overlay overlayfs:/overlay 1.1M 640.0K 448.0K 59% /
这里可以看到安装pkg用了大概400多K的空间
root@OpenWrt:/etc/config# ls /dev/ bsg mtd0ro mtd4ro mtdblock5 sda1 ttyS12 ttyS6 bus mtd1 mtd5 null shm ttyS13 ttyS7 console mtd1ro mtd5ro port tty ttyS14 ttyS8 full mtd2 mtdblock0 ppp ttyATH0 ttyS15 ttyS9 kmsg mtd2ro mtdblock1 ptmx ttyS0 ttyS2 urandom log mtd3 mtdblock2 pts ttyS1 ttyS3 watchdog mem mtd3ro mtdblock3 random ttyS10 ttyS4 zero mtd0 mtd4 mtdblock4 sda ttyS11 ttyS5
可以看到在/dev目录下多了sda和sda1,说明U盘被识别出来了
修改/etc/config/fstab文件:
root@OpenWrt:/etc/config# vi fstab config global automount option from_fstab 1 option anon_mount 1 config global autoswap option from_fstab 1 option anon_swap 0 config mount option target /overlay option device /dev/sda1 option fstype ext4 option options rw,sync option enabled 1 option enabled_fsck 0 config swap option device /dev/sda2 option enabled 0
执行下面命令使其生效:
root@OpenWrt:~# /etc/init.d/fstab enable
接下来将系统root内容拷贝至U盘:
mount /dev/sda1 /mnt mkdir /tmp/root mount -o bind / /tmp/root cp -a /tmp/root/* /mnt/ umount /tmp/root
修改U盘上的/mnt/etc/banner,最末尾处加一行boot from usb,标识是从U盘启动的系统
root@OpenWrt:~# vi /mnt/etc/banner _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- ATTITUDE ADJUSTMENT (12.09, r36088) ----------------------------------------------------- * 1/4 oz Vodka Pour all ingredients into mixing * 1/4 oz Gin tin with ice, strain into glass. * 1/4 oz Amaretto * 1/4 oz Triple sec * 1/4 oz Peach schnapps * 1/4 oz Sour mix * 1 splash Cranberry juice ----------------------------------------------------- boot from usb -----------------------------------------------------
重启路由后就可以使用了
root@OpenWrt:~# reboot root@OpenWrt:~# df -h Filesystem Size Used Available Use% Mounted on rootfs 7.4G 248.7M 6.8G 3% / /dev/root 2.0M 2.0M 0 100% /rom tmpfs 14.3M 380.0K 13.9M 3% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/sda1 7.4G 248.7M 6.8G 3% /overlay overlayfs:/overlay 7.4G 248.7M 6.8G 3% /
可以看到,系统的存储空间变为7.4G了!
注:重刷openwrt固件后还想使用原来U盘,可能会碰到这样一个错误:/dev/sda1被挂载到了/tmp/overlay-disabled,解决办法是
cp /.extroot.md5sum /tmp/overlay-disabled/etc/extroot.md5sum