OpenWRT and Backing Up: Difference between revisions
mNo edit summary |
|||
Line 60: | Line 60: | ||
Bad news. The delete command doesn't always work. After issuing the command on a legitimate Loop Device, and with no errors, the Loop Device will persist. Checking it with LOSETUP -a shows it is still there. Accessing it with CFDISK or MOUNT still works. Oh, well. Windows solution time. Reboot. | Bad news. The delete command doesn't always work. After issuing the command on a legitimate Loop Device, and with no errors, the Loop Device will persist. Checking it with LOSETUP -a shows it is still there. Accessing it with CFDISK or MOUNT still works. Oh, well. Windows solution time. Reboot. | ||
=== Overlay, OverlayFS, Union Mount, SquashFS, F2FS, and more. === | ===Overlay, OverlayFS, Union Mount, SquashFS, F2FS, and more.=== | ||
==== "QuickD" ==== | ===="QuickD"==== | ||
Real quick, here's what's going on with a typical Router based installation of OpenWRT that is stored on Flash Memory Storage. | Real quick, here's what's going on with a typical Router based installation of OpenWRT that is stored on Flash Memory Storage. | ||
Line 69: | Line 69: | ||
How is it done? Using the [[wikipedia:OverlayFS|Overlay]] / [[wikipedia:Union_mount|Union Mount]] capabilities of Linux. Sorry, not here to explain that fully, hence the above links. | How is it done? Using the [[wikipedia:OverlayFS|Overlay]] / [[wikipedia:Union_mount|Union Mount]] capabilities of Linux. Sorry, not here to explain that fully, hence the above links. | ||
==== Backing up the /overlay Directory ==== | ====Backing up the /overlay Directory==== | ||
Ideally (since LVM isn't typically available to do "Volume Shadow Copies"), one would boot to an alternative OS, use DD to clone the /overlay "Partition" / "Device". Easy with an x86_64 based install of OpenWRT, but also very possible with a Router based on Flash Memory Storage too. For the Router scenario, again ideally, if the /overlay "Partition" / "Device" is on an external USB Flash Drive (as it should be if a router has a USB 3.0 port), just pop it into a "Linux Box" (virtual or otherwise) for backing up. It can also be done "live" without much chance of something being modified during the cloning process. | Ideally (since LVM isn't typically available to do "Volume Shadow Copies"), one would boot to an alternative OS, use DD to clone the /overlay "Partition" / "Device". Easy with an x86_64 based install of OpenWRT, but also very possible with a Router based on Flash Memory Storage too. For the Router scenario, again ideally, if the /overlay "Partition" / "Device" is on an external USB Flash Drive (as it should be if a router has a USB 3.0 port), just pop it into a "Linux Box" (virtual or otherwise) for backing up. It can also be done "live" without much chance of something being modified during the cloning process. | ||
* While booted to an alternate OS (Rocky Linux, another OpenWRT install on a USB Flash Drive, etc.), in this example, booted to another OS, but first; | *Make a BackUp: While booted to an alternate OS (Rocky Linux, another OpenWRT install on a USB Flash Drive, etc.), in this example, booted to another OS, do... Wait, but first; | ||
** Locate where the /overlay Partition is; | **Locate where the /overlay Partition is; | ||
*** LSBLK will show | ***LSBLK will show the connection between the /overlay Directory and what it is "connected to" (hint for x86 systems, look in the /boot/grub/grub.cfg file) | ||
**** For an OpenWRT install with /overlay on a USB Flash Drive: /overlay will be on /dev/sdXy (where X is a letter and y is a number, example: sda1) | ****For an OpenWRT install with /overlay on a USB Flash Drive: /overlay will be on /dev/sdXy (where X is a letter and y is a number, example: sda1) | ||
**** For an OpenWRT install with /overlay on a SATA Disk Drive / SSD: /overlay will be on a [[wikipedia:Loop_device|Loop Device]], roughly equivalent to a VHD or VHDX File where a file represents a storage device | ****For an OpenWRT install with /overlay on a SATA Disk Drive / SSD: /overlay will be on a [[wikipedia:Loop_device|Loop Device]], roughly equivalent to a VHD or VHDX File where a file represents a storage device | ||
***** Use this command: losetup -a (it will display something like this: /dev/loop0: (Some Numbers) (/sda2), offset 3014656 (/dev/loop0 is the device and /sda2 is the "file", actually a real drive)) | *****Use this command: losetup -a (it will display something like this: /dev/loop0: (Some Numbers) (/sda2), offset 3014656 (/dev/loop0 is the device and /sda2 is the "file", actually a real drive)) | ||
**** | **"Create" a LOOP Device (For an x86 (used interchangeably with x86_64, yes, yes, don't say it)); | ||
***Generic Syntax: losetup -o OffsetInBytes /dev/loopX /WhatEverPath/WhatEverFileName | |||
***OpenWRT specific Syntax: losetup -o 3014656 -fP /WhatEverPath/WhatEverFileName (3014656* is the offset picked by the OpenWRT developers, losetup will pick the next available LOOP#) | |||
***OpenWRT Syntax Example: losetup -o 3014656 -fP /mnt/sda1/OpenWRT_BackUp.img | |||
**Mount the LOOP Device (again for an x86 system) | |||
***Example: mount -t f2fs /dev/loop1 /mnt/loop1 (mkdir /mnt/loop1 before this command of course) | |||
**...and that's it for x86 devices. From there, just cp | |||
<nowiki>*</nowiki>If you haven't spotted it yet, but you've been asking, "Where is that file that OpenWRT mounts a Directory named /overlay as a LOOP Device?" Answer: There is no file. It is simply a sector on the Disk / SSD Drive to the end of it. And you might ask, "But won't it be overwritten?" Answer: Nope, because everything before it is considered ROM (as in no write), so it won't expand. And yes that means the entire disk drive (well, at least the OpenWRT partitions) is considered a File that breaks down into a ROM Section and an /overlay Section. | |||
3014656 | 3014656 | ||
mount -t f2fs /dev/loop1 /mnt/loop1 | mount -t f2fs /dev/loop1 /mnt/loop1 |