In the previous article, I used Netgear wndr3700 to explain how to configure openwrt. Next, we want to install necessary software on openwrt. But now the new problem arises: when some software is installed, the storage space is insufficient. What should I do at this time? Taking the 4 M Flash as an example, when you talk about the openwrt firmware flushing to your own vro, you will find that the remaining space is usually less than 2 m. When we need to install a lot of software that is not included in openwrt, we will find that such a small space is too shabby. So how can we solve this problem?
1. Add USB Extension(Note: by default, your router comes with a USB interface. If the motherboard does not have a USB interface, you can consider making changes to the hardware. I do not know much about the hardware, so I will not extend the explanation here. You can find a solution on the Internet)
1. Update the router software source (note: the router needs to be networked)
opkg update
2. Add USB support
Opkg install kmod-USB-core # optional opkg install kmod-USB-uhciopkg install kmod-USB-storageopkg install kmod-usb2opkg install kmod-USB-OHCI
3. Add USB mounting, hot swapping, and boot support
Opkg install block-mount # Mount opkg install block-hotplug # Hot swapping opkg install block-extroot # boot support
In this case, you can plug in a USB flash drive to test it.
ls -l /dev |grep sda
Display result
[email protected]:/#ls -l /dev |grep sdabrw-r--r-- 1 root root 8, 0 Jan 1 1970 sda
Check whether SDA sda1 sda2 sda3 is displayed. SDA indicates a device named SDA, sda1 indicates its first partition, and so on.
Ii. USB disk partitioning
Why partition the USB flash disk?
First, facilitate file management. We hope to start openwrt from the USB flash drive, so we can run the system image on the USB flash drive to get more space for storing various files. Necessary partitions are useful for enhanced management.
Second, create a swap partition. We need to open up some space on the USB flash drive for swap switching. Through swap, the RAM throughput is improved to prevent the system from being suspended when some software calls RAM in large quantities (for example, transmission offline download service ).
So, how to partition the USB flash disk? Perform the following operations:
1. Prepare and add necessary software
Opkg install kmod-fs-ext3 # Add ext3 File System Support opkg install fdisk # Add partition tool opkg install e2fsprogs # Add formatting and detection tools
2. partitioning the USB flash drive
(1) Use the following operations to view the USB flash disk.
Fdisk-L # list the current disks attached
Display result
Note: As My USB flash drive has been partitioned, the above results are displayed. (Note: sda1 is the system disk, which is equivalent to the C disk of the Windows system; sda2 is the swap partition for memory swap; sda3 is the storage area, mainly storing large files, FTP, transmission servers, and the IOT web server log files are stored in the change partition)
(2) Partition operations
fdisk /dev/sda
Select "N" and add each partition in sequence. After dividing the partition, select "W" to save and exit. After a partition is created, it is not formatted. Therefore, you need to format the partition.
(3) format each partition
Mkfs. ext3/dev/sda1 # format the first partition as the ext3 format mkswap/dev/sda2 # format the second partition as the swap partition mkfs. ext3/dev/sda3 # format the third partition to ext3
(4) display the partition result
3. Add a USB flash drive to start
1. Move the system image to the first partition of the USB flash drive:
Mkdir/tmp/root # create a temporary directory under the/tmp directory, used to place the system image Mount/dev/sda1/mnt # Mount/dev/sda1 to the/mnt directory Mount-O bind/tmp/root # create the root directory "/" image, mount it to CP/tmp/root/*/mnt-A # Under "/tmp/root" to copy all contents in the/tmp/root/directory to/MNT, it is equivalent to copying all content under/mnt/root to the umount/tmp/root under/dev/sda1 # unmount/tmp/root
2. modify a partition table
Go to the/etc/config/directory and modify the fstab file.
Config global automount
Option from_fstab 1
Option anon_mount 1
Config global autoswap
Option from_fstab 1
Option anon_swap 0
Config Mount # mount the sda1 partition to the system # option target/mnt # select the file directory in which the sda1 partition is mounted to the current system. The default directory can be used here.
Option device/dev/sda1 # device to be mounted,/dev/sda1 option fstype ext3 # File System Format ext3 option options RW, sync # read/write, and synchronization permission option enabled 1 # Whether to enable option enabled_fsck 0 # Whether to enable check
Option is_rootfs 1 # whether it is used as the root file system
Config swap # mount the sda2 partition to the switch partition option device/dev/sda2 option enabled 1 config mount option target/mnt # mount the sda3 partition to the MNT folder, as a place to store websites and files
Option device/dev/sda3 # device to be mounted,/dev/sda3
Option fstype ext3 # File System Format ext3
Option options RW, sync # read/write and synchronization Permissions
Option enabled 1 # Start the device
Save the preceding modification and execute the following command to make it take effect.
/etc/config/fstab enable/etc/config/fstab restart
Restart the device. Wait for the device to restart and enter shell to check whether the partition is successful.
DF-h # Check the system mounting status and disk space usage of the file system.
Free # view memory usage, which can be used to check whether swap is started normally
Normal partitioning and USB flash drive startup
OK, so far, we have successfully solved the storage problem. Then, when we install other software, we do not need to require kb for storage conditions.
Bytes ---------------------------------------------------------------------------------------------------------
In the next article, I will introduce how to install vsftp and Samba LAN file sharing.
Please indicate the source of reprint: http://www.cnblogs.com/Thank you!