Linksys AC Series Router Configuration Tips for OpenWRT: Difference between revisions

Line 2,956: Line 2,956:


====DD====
====DD====
Another program that functions as an effective cloning utility is ''dd'' (noted in an earlier section).  Ideally an additional USB Flash drive should be used.  Note, to utilize the full dd program, instead of the one built into BusyBox: opkg install corutils
Another program that functions as an effective cloning utility is ''dd'' (noted in an earlier section).  If cloning an entire disk or drive or flash drive, the image should be cloned to a separate device (another flash drive, disk drive, or network storage location).


*dd if=/dev/sdXy of=/dev/sdXy bs=64K conv=noerror,sync status=progress (if = source, of = destination, bs=block size (IE amount to copy at a time), noerror=Don't stop on read errors, sync=If an error occurs use zeros or nuls to pad file, progress=show the progress)
Note, the DD command is built into BusyBox, but does not have all options available.  To utilize the full capability of DD, install the full package with this command: opkg install corutils


To copy to a compressed file;
Below is an example command to clone a partition;
 
*dd if=/dev/sdXy of=/dev/sdXy bs=64K conv=noerror,sync status=progress
**if = source
**of = destination
**bs=block size, amount of source data to be read and then written, IE read 64K at a time, then write that, and repeat.
**conv = noerror = Don't stop on read errors, sync = If an error occurs use zeros or nuls to pad file, progress=show the progress
 
Before cloning a partition, to save space, "zero out" all unallocated space.  IE, with every file system there are potentially sections of the drive that have had data written to them at some point in time that has since been erased.  And as we all know, when a file is "erased" from a drive, the actual file itself is left on the drive and the space it occupied is simply marked as available in a file system.  DD has no method of determining alocated or unallocated space.  It copies everything.  And in the below example where everything it copies is put into a compressed TAR file, compressing a bunch of zeros is very easy to make quite small.  IE, "zeroing out" unallocated space on a disk drive really reduces the size of an image file in a compressed file.
 
* dd if=/dev/zero bs=64K conv=noerror,sync status=progress of=/overlay/ZeroByteFile.zero (in this example the partition being copied is mounted as an /overlay (look it up), so adjust if you need to clone a different partition)
** if = Source
** bs =
** status = Essentially show a progress meter
** of = destination
* sync
** sync = write any unwritten files stored in RAM to physical media
* rm ZeroByte.File.zero
** rm = delete the Zero Byte File to free up space as it has filled the entire free space on the disk.
 
To copy a complete partition to a single compressed file;


*dd if=/dev/sdXy conv=sync,noerror bs=64K status=progress | gzip -c  > /WhatEverPath/WhatEverFile.img.gz (-c=Do not change files)
*dd if=/dev/sdXy conv=sync,noerror bs=64K status=progress | gzip -c  > /WhatEverPath/WhatEverFile.img.gz (-c=Do not change files)
Line 2,979: Line 2,999:
In the above examples X and y should be replaced with actual mount point references.  IE, sda1, sdb3, sde2, etc.
In the above examples X and y should be replaced with actual mount point references.  IE, sda1, sdb3, sde2, etc.


==== Good 'ole Fashion, just make a copy ====
To mount a partition (not a complete disk / drive);
 
* mkdir /tmp/MyMountPoint (this can be any name)
* mount -o loop -t ext4 /WhatEverPath/WhatEverImage.img /tmp/MyMountPoint
** -t = the type of file system (this could be -t vfat, -t ntfs, -t ext2, etc., but it should obviously match the type of the original file system)
** -o = Option (let the mount command know it is a "loop" device)
 
====Good 'ole Fashion, just make a copy====
Forget all the fancy backup stuff for this one.  Sometimes it's good just to make a manual copy of things.  Not so much in this example to avoid a failed drive, but more to preserve a working copy of stuff.  The idea is whenever one embarks on a journey or a major change (even a minor one too), sometimes it's good to make a copy of a working file.  For instance, using the /etc/config/network configuration file: cp /etc/config/network /etc/config/network-09.30.2020  There, a copy of the original file with a date on the end of it.  Simple and effective if one needs to take a "single step back", instead of walking through the complexity of restoring files from Restic or a DD Tar.GZ file.
Forget all the fancy backup stuff for this one.  Sometimes it's good just to make a manual copy of things.  Not so much in this example to avoid a failed drive, but more to preserve a working copy of stuff.  The idea is whenever one embarks on a journey or a major change (even a minor one too), sometimes it's good to make a copy of a working file.  For instance, using the /etc/config/network configuration file: cp /etc/config/network /etc/config/network-09.30.2020  There, a copy of the original file with a date on the end of it.  Simple and effective if one needs to take a "single step back", instead of walking through the complexity of restoring files from Restic or a DD Tar.GZ file.


Line 3,029: Line 3,056:


The installation script ./install.sh relies on the full BASH shell (OpenWRT includes the [[wikipedia:Almquist_shell|ASH]] shell by default): opkg install bash, then type the command ''bash ./install.sh'' (plain ASH won't work, they even explicitly state the [[wikipedia:Shebang_(Unix)|shebang]] of their file as ''#!/bin/bash'', not #!/bin/sh, and just for the fun of it attempted to run it with ASH, and it errors out) Read here for more information or to change it permanently: https://www.howtogeek.com/669835/how-to-change-your-default-shell-on-linux-with-chsh/
The installation script ./install.sh relies on the full BASH shell (OpenWRT includes the [[wikipedia:Almquist_shell|ASH]] shell by default): opkg install bash, then type the command ''bash ./install.sh'' (plain ASH won't work, they even explicitly state the [[wikipedia:Shebang_(Unix)|shebang]] of their file as ''#!/bin/bash'', not #!/bin/sh, and just for the fun of it attempted to run it with ASH, and it errors out) Read here for more information or to change it permanently: https://www.howtogeek.com/669835/how-to-change-your-default-shell-on-linux-with-chsh/
=== NTP (Network Time Protocol) ===
By default OpenWRT provides an NTP Client ''and Server'' (suprise, suprise, and a really good thing) within [[wikipedia:BusyBox|BusyBox]].  Since most routers (if any) do not provide a method (IE, battery) of maintaining an internal clock when the router is off a method must exist to set the proper time for the router when it starts up.  This client service is supplied within the BusyBox version of ntpclient.
It is also possible to install the full version of ntpclient (opkg install ntpclient) along with a LuCI GUI (opkg install luci-app-ntpc).  No research was done on the difference between the two versions of the ntp client as the BusyBox version of ntpclient satisfied all functional needs.
For and NTP Daemon / Server, the BusyBox also includes NTPD.  A full version of NTPD can be installed (opkg install ntpd), but there is no LuCI GUI inteface as there is with the client.  An alternative NTP client, CHRONYD can be installed (opkg install chonry) instead of NTPD.  But since the daemon / server version of NTPD in BusyBox will function for client NTP devices (including Windows) no further research was done on alternative NTP daemons / services like NTPD or CHRONYD.
One additional note worth mentioning relates to internet service providers.  Some providers, such as AT&T, block client devices attempting to using the NTP protocol to syncronize clocks.  Some websites indicate this is a "slow-down" or some other type of limit imposed on the NTP protocol, but the end result is the same.  And that end result is the NTP protocol does not work.  And that means devices, computers, etc. are not able to syncronize with a time server.  AT&T claims this is for security reasons.  HA!  See more information about it here: https://about.att.com/sites/broadband/network


==Webmin==
==Webmin==
Webmin can be successfully installed on OpenWRT, '''AND IT IS USEFUL'''.  The end of the previous sentence is in all CAPS and '''BOLD''' because of the large number websites and posts that do nothing more than question why anyone would want to install Webmin on OpenWRT instead of just answering the original question of how to install it.  Sometimes it is just nice to have a GUI.  The editor for config files alone is worth it.
Webmin can be successfully installed on OpenWRT, '''AND IT IS USEFUL''' (unlike so many other ignorant (notice the word 'stupid' wasn't used, but they are) web posters claim or question).  The end of the previous sentence is in all CAPS and '''BOLD''' because of the large number websites and posts that do nothing more than question why anyone would want to install Webmin on OpenWRT instead of just answering the original question of how to install it.  Sometimes it is just nice to have a GUI.  The editor for config files alone is worth it.


There is however a word of caution to address: Do NOT use Webmin for any OpenWRT services that have an associated LuCI GUI or /etc/config/WhatEverConfigurationFile because modifications made by Webmin will be wiped out by changes made via LuCI or the /etc/config/Files...  There are many, many services such as BIND / NAMED, Apache / HTTPD, ProFTPD, OpenSSL for OpenVPN Certificate generation that have no LuCI GUI, nor are they "controlled" or configured via the /etc/config/ Files.  That means these services are safe to configure via text or by GUI.
There is however a word of caution to address: Do NOT use Webmin for any OpenWRT services that have an associated LuCI GUI or /etc/config/WhatEverConfigurationFile because modifications made by Webmin will be wiped out by changes made via LuCI or the /etc/config/Files...  There are many, many services such as BIND / NAMED, Apache / HTTPD, ProFTPD, OpenSSL for OpenVPN Certificate generation that have no LuCI GUI, nor are they "controlled" or configured via the /etc/config/ Files.  That means these services are safe to configure via text or by GUI.