tl-wr720n and OpenWrt (iii)

Source: Internet
Author: User
Tags dmesg

V. Mount USB storage devices

tl-wr720n USB Interface (formerly used for 3G network card) can provide us with access to USB storage devices, extended capacity is greatly facilitated.

1. Preparing the disk

You can choose a large USB flash drive or disk, and I choose a mechanical hard drive removed from the old computer (and, of course, the USB to SATA cable), and then format it, in the principle of waste utilization. It is important to note that the USB I am using is based on the original router 3G mode, so the gear must be set correctly.

2. Partitioning and formatting

View disk conditions

$ fdisk–l

< get disk/dev/sdg>

Complete the partition according to the instructions of the Fdisk command.

$ FDISK/DEV/SDG

Command (M for help): n Create a new partition

Partition Type:

P Primary (0 primary, 0extended, 4 free)

E Extended

Select (default P): P type Primary partition

Partition number (1-4, default 1): 1 set partition

First sector (2048-312581806, default2048): Set the partition start location

Using Default Value 2048

Last sector, +sectors or +size{k,m,g} (2048-312581806, default 312581806): +140g Set Partition size

The 1th partition created at this point is used as the EXT4 partition, and then the same can be done with partition 2nd as the swap partition.

Command (M for help): P View the partition information that has been set

disk/dev/sdg:160.0 GB, 160041885184 bytes

255 heads, Sectors/track, 19457cylinders, total 312581807 sectors

Units = sectors of 1 * MB = bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512bytes

Disk IDENTIFIER:0X3A023A01

Device Boot Start End Blocks Id System

/DEV/SDG1 2048 293603327 146800640-up Linux

/DEV/SDG2 293603328 312581806 9489239+, Linux Swap/solaris

Command (M for help): W Save partition information

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:re-reading the partition tablefailed with error 16:device or resource busy.

The kernel still uses the old table. Thenew table used at

The next reboot or after you Runpartprobe (8) or KPARTX (8)

Syncing disks.

You can update the kernel partition table directly without restarting.

$ sudo partprobe

The partitions are then formatted and activated using MKFS and Mkswap respectively.

$ mkfs.ext4-m 0.5/DEV/SDG1

$ mkswap/dev/sdg2

$ swapon/dev/sdg2

View Swap partition and Uninstall

$ swapon-s

Filename Type Size used priority

/DEV/SDG2 Partition 9489232 0-1

$ swapoff/dev/sdg2

Note: The M parameter in the MKFS command is used to set the percentage of reserved partitions, and the default of 5% is a waste of high-capacity disks. You can use the TUNE2FS tool to upgrade the file system directly to EXT4, while the partitioned disk does not want to erase the content.

3. Querying the USB interface type

After accessing the router USB interface, use DMESG query

$ DMESG | Gerp ' USB '

$ [4.740000] usbcore:registered new Interfacedriver USBFS

[4.740000] usbcore:registered new Interfacedriver Hub

[4.750000] usbcore:registered new Devicedriver USB

[5.140000] USB 1-1: New high-speed Usbdevice number 2 using Ehci-platform

You can see that for the USB2.0 interface, you need to install a module that supports USB2.0.

4. Install support modules for USB and mass storage devices

Because the USB support module is not selected by default at compile time for openwrt, it needs to be installed via the OPKG tool (to ensure that the router has normal Internet access).

$ opkg Update

$ opkg Install kmod-usb-storage BLOCK-MOUNTKMOD-FS-EXT4

$ reboot

Note: If collected errors appears:

* Satisfy_dependencies_for:cannot satisfythe following dependencies for Kmod-usb-storage:

* Kernel (= 3.18.11-1-317527fb328b694536ee00c07026c22c) * Kernel (= 3.18.11-1-317527fb328b694536ee00c07026c22c) *

*opkg_install_cmd:cannot Install package kmod-usb-storage.

Indicates that the kernel version does not match, typically due to the fact that the firmware update for the community version that you compiled is too fast.

5. Build a partition map and port the root partition to a USB storage device

Modify the partition mapping table and activate

$ vim/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 Target/

Option DEVICE/DEV/SDA1

Option Fstype EXT4

Option Options Rw,sync

Option enabled 1

Opntion enabled_fsck 0

Config ' swap '

Option Device/dev/sda2

Option enabled 1

$/etc/init.d/fstab Enable

Mount the disk and copy the files from the root partition in the router flash to the USB storage device.

$ mkdir/mnt/sda1

$ mount/dev/sda1/mnt/sda1

$ mkdir-p/tmp/cproot

$ mount--bind//tmp/cproot/

$ tar-c/tmp/cproot/-CVF-. | TAR-C/MNT/SDA1-XF-

$ umount/tmp/cproot/

6. Detect if the mount is successful

Restart check after modifying welcome interface

$ vim/mnt/sda1/etc/banner

CHAOS Calmer (bleeding Edge, r45573) boot from usb!

$ reboot

< can see boot from usb! on the Welcome screen Words >

$ df–h

< can check the status of mounted USB devices >

Resources:

"1" http://blog.chinaunix.net/uid-23354495-id-1740679.html

"2" Http://wiki.openwrt.org/doc/howto/usb.storage

"3" Http://wiki.openwrt.org/doc/howto/extroot

"4" http://tieba.baidu.com/p/2130462597

tl-wr720n and OpenWrt (iii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.