What's new

USB swap for M.2 SSD with "soft" option?

xmanyes

Occasional Visitor
Hi,

I see my USB is probably failing with some files locked and no way to make updates for a few addons in amtm... So I saw several posts with the same problem and all suggest either replacing USB or, better version, SSD (M.2) 256Gb. As I have 4 routers (main AX58 + 3 older in AI mesh) and 38 devices, parental supervision, setting up everything from scratch would be a major PITA... MAJOR! Probably a day or two with gradually workable solution for 2 families, which means I will be eaten alive in the process by each and everyone...

So I am asking, if there is any "soft" solution to just swap the USB for 256 Gb M.2 SSD and somehow continue with the existing setup outlined above? How & what are the best steps? What size should be the swap file and are there any other suggested settings that should be specifically taken care off for, hopefully, some peace of mind?

Luckily for now only few minor amtm addons are locked (connmon & scMerlin, which I cannot even uninstall due to a lock) and even if amtm addons would need to be re-created/re-installed, it shouldn't be any major issue, except maybe Adguard, I have "tons" of settings that I am not sure how to backup/restore...

Tips here highly desirable, thank you community & wish everyone happy holidays and New Year!
 
Maybe see if the BACKUPMON addon script may be of use for what you seek or desire.

Edit to add: From that BACKUPMON link:
Use-case: BACKUPMON was designed to backup from, and restore to an already configured router from an external network resource, given a situation of a corrupted USB drive, botched Entware environment, or other general corruption issues. It can, however, also restore you back to a previous state if you decide to completely wipe your router or external drive from scratch. You can use it to move from one external USB drive to another... say, upgrading from a flashdrive to an SSD! You could also use it to restore your environment to a similar router if your old one dies, and you pick up the same model + hardware revision + firmware level as a replacement (at your own risk).
 
Last edited:
However, using the BACKUPMON method will not repair your damaged files. If you're lucky you may just have to edit a few config. Worst case you lose everything and start again.
 
Seems BACKUPMON is also affected... I can open it, but none of the changes in the setup are really saved :( so I cannot change the location to point to correct IP/folder...

Trying also swap file addon...

Getting from fwupdate.asuswrt-merlin.net
! Module swap.mod download failed
! using fallback server diversion.ch
! Module swap.mod download failed

Bollocks... This USB is soooo over.
 
Here's what worked for me when I was in the same situation (dying USB):
  1. Remove the dead USB drive (I did this while the router was running)
  2. Plug in the new SSD and run amtm > fd to format it and create a swap file.
  3. Uninstall and re-install Skynet so it points to the correct/new swap file.
  4. Re-install Diversion (which installs Entware).
  5. Re-install every other script via amtm.
All of the essential router settings (WiFi properties, connection information, clients list etc.) and most of your add-ons and their settings are saved in either NVRAM or /jffs, so the loss should be minimal.

However, it's worth noting that I have a very basic network topology set up (see my signature) and the list of installed scripts might differ from yours, so YMMV.
 
Something's off... new/empty USB and trying to run amtm would make it loop with en error listing previous scripts:
rm: can't remove '/jffs/addons/amtm/diversion.mod': Read-only file system
2 open Skynet 8.0.7
8 open MerlinAU 1.5.7

Trying to remove amtm from previous posts (https://www.snbforums.com/threads/segmentation-fault-in-amtm.86496/page-3), but only get read-only system:

2022admim@RT-AX58U-9920:/tmp/home/root# rm -fr /jffs/addons/amtm
rm: can't remove '/jffs/addons/amtm/ntpmerlin.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/sc_update.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/a_fw/amtm.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/a_fw': Read-only file system
rm: can't remove '/jffs/addons/amtm/mail/emailpw.enc': Read-only file system
rm: can't remove '/jffs/addons/amtm/mail/email.conf': Read-only file system
rm: can't remove '/jffs/addons/amtm/mail': Read-only file system
rm: can't remove '/jffs/addons/amtm/.amtm_theme': Read-only file system
rm: can't remove '/jffs/addons/amtm/YazDHCP.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/email.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/uiDivStats.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/.ash_history': Read-only file system
rm: can't remove '/jffs/addons/amtm/MerlinAU.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/entware.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/connmon.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/mount-entware.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/shell_history.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/AdGuardHome.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/scmerlin.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/backupmon.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/disk_check.log': Read-only file system
rm: can't remove '/jffs/addons/amtm/disk_check.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/diversion.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm/skynet.mod': Read-only file system
rm: can't remove '/jffs/addons/amtm': Read-only file system

At this point dreaded factory-reset seems to be the only option, unless someone has some other ideas... Seems like read-only is not the problem of the USB.

By the way, router has been rebooted before I tried this :(
 
Before you go any further, go to Administration - Restore/Save/Upload Setting and create backups of your settings and JFFS partition.
 
I see my USB is probably failing with some files locked and no way to make updates for a few addons in amtm... So I saw several posts with the same problem and all suggest either replacing USB or, better version, SSD (M.2) 256Gb. As I have 4 routers (main AX58 + 3 older in AI mesh) and 38 devices, parental supervision, setting up everything from scratch would be a major PITA... MAJOR! Probably a day or two with gradually workable solution for 2 families, which means I will be eaten alive in the process by each and everyone...
I would shut off the router, take its USB drive, and simply clone it under Linux with "dd if=/dev/sda of=/dev/sdb". In my opinion, a SATA SSD with a simple adapter cable is best, plugged into USB2 port. You can add another partition using Linux if there is empty space on the bigger SSD.

If you are missing a Linux, grab and old laptop, and setup up Ubuntu on it.

This is very relatively fast, and with luck most of your configs will be as they were, and you can be up and running in a few minutes since the router will pick up the new SATA instead of the old USB.
 
I would shut off the router, take its USB drive, and simply clone it under Linux with "dd if=/dev/sda of=/dev/sdb". In my opinion, a SATA SSD with a simple adapter cable is best, plugged into USB2 port. You can add another partition using Linux if there is empty space on the bigger SSD.

If you are missing a Linux, grab and old laptop, and setup up Ubuntu on it.

This is very relatively fast, and with luck most of your configs will be as they were, and you can be up and running in a few minutes since the router will pick up the new SATA instead of the old USB.
Tried also that (cloned USB to SSD) and the result is the same.
What worries me is that even without USB/SSD, amtm shows locked files, so clearly on the router. I tried downgrading in hope this would aleviate some issues, no luck, then back upgrading, also no luck :(
 
Tips here highly desirable, thank you community & wish everyone happy holidays and New Year!

Might be a good time to take a fresh start and remove all of the 3rd party add-ons... seriously - times change and needs do as well...
 
Tried also that (cloned USB to SSD) and the result is the same.
What worries me is that even without USB/SSD, amtm shows locked files, so clearly on the router. I tried downgrading in hope this would aleviate some issues, no luck, then back upgrading, also no luck :(
OK, could it be your router flash chip is fried? Check what the log has for nand. Here is mine, I do have a bad flash block in there:
Code:
Jan  1 04:05:08 kernel: nand: Could not find valid ONFI parameter page; aborting
Jan  1 04:05:08 kernel: nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xda
Jan  1 04:05:08 kernel: nand: Macronix NAND 256MiB 3,3V 8-bit
Jan  1 04:05:08 kernel: nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
Jan  1 04:05:08 kernel: bcm63xx_nand ff801800.nand: Adjust timing_1 to 0x65324458 timing_2 to 0x80040e54
Jan  1 04:05:08 kernel: bcm63xx_nand ff801800.nand: detected 256MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4
Jan  1 04:05:08 kernel: nand_read_bbt: bad block at 0x000000280000
Jan  1 04:05:08 kernel: Creating 11 MTD partitions on "brcmnand.0":

My badblock maps to this:
Code:
dev:    size   erasesize  name
mtd7: 00480000 00020000 "bootfs_update"

mtdinfo -M /dev/mtd7 says:
 12: 00180000    BAD  13: 001a0000         14: 001c0000         15: 001e0000
( 1 bad blocks )

/sys/class/mtd/mtd7/bad_blocks says:
1

A couple of scripts would show where the bad blocks are. Once you create them, run /jffs/scripts/badblocks_all

/jffs/scripts/badblocks - taken from this post, thanks to @glens :
Code:
#!/bin/sh

case $1 in
        [0-9]* )
echo
sed -n '1p; /^mtd'$1':/p' /proc/mtd
echo
echo mtdinfo -M /dev/mtd${1} says:
mtdinfo -M /dev/mtd${1} | awk -F 'BAD' '
                                BEGIN { bads = 0 }
                                /BAD/{ bads = bads + ( NF - 1 ); print  }
                                END { printf "( %d bad blocks )\n", bads }'
echo
echo /sys/class/mtd/mtd${1}/bad_blocks says:
cat /sys/class/mtd/mtd${1}/bad_blocks
echo
;;

        * ) cat <<EOF

usage: $0 <mtd number>

EOF
;;
esac

/jff/scripts/badblocks_all
Code:
#!/bin/sh
for x in 0 1 2 3 4 5 6 7 8 9 10 11; do
/jffs/scripts/badblocks $x
done
 
When trying to save the script in nano, I get error:

[ Error writing badblocks: Read-only file system ]

There's no sudo or something to elevate it, right?
 
When trying to save the script in nano, I get error:

[ Error writing badblocks: Read-only file system ]

There's no sudo or something to elevate it, right?
That's a file system error, the drive has errors and is not writeable.
 
When trying to save the script in nano, I get error:

[ Error writing badblocks: Read-only file system ]

There's no sudo or something to elevate it, right?
Sounds like flash on the router is fried. Check the log for boot error messages.

Also, try those badblock scripts by placing them in /tmp, which is RAM. You should be able to run the scripts after all.
 
Sounds like flash on the router is fried. Check the log for boot error messages.

Also, try those badblock scripts by placing them in /tmp, which is RAM. You should be able to run the scripts after all.
Thanks, I could save & run the code from /tmp, but with not much success, everything is "fine" except for the first visible "4 bad blocks" at /dev/mtd0:

dev: size erasesize name
mtd0: 10000000 00020000 "brcmnand.0"

mtdinfo -M /dev/mtd0 says:
2044: 0ff80000 BAD 2045: 0ffa0000 BAD 2046: 0ffc0000 BAD 2047: 0ffe0000 BAD
( 4 bad blocks )

/sys/class/mtd/mtd0/bad_blocks says:
0


dev: size erasesize name
mtd1: 00200000 00020000 "loader"

mtdinfo -M /dev/mtd1 says:
( 0 bad blocks )

/sys/class/mtd/mtd1/bad_blocks says:
0


dev: size erasesize name
mtd2: 0fc00000 00020000 "image"

mtdinfo -M /dev/mtd2 says:
( 0 bad blocks )

/sys/class/mtd/mtd2/bad_blocks says:
0


dev: size erasesize name
mtd3: 00080000 00020000 "crashlog"

mtdinfo -M /dev/mtd3 says:
( 0 bad blocks )

/sys/class/mtd/mtd3/bad_blocks says:
0


dev: size erasesize name
mtd4: 00000500 0001f000 "metadata1"

mtdinfo -M /dev/mtd4 says:
( 0 bad blocks )

/sys/class/mtd/mtd4/bad_blocks says:
0


dev: size erasesize name
mtd5: 00000500 0001f000 "metadata2"

mtdinfo -M /dev/mtd5 says:
( 0 bad blocks )

/sys/class/mtd/mtd5/bad_blocks says:
0


dev: size erasesize name
mtd6: 009ad6e4 0001f000 "bootfs1"

mtdinfo -M /dev/mtd6 says:
( 0 bad blocks )

/sys/class/mtd/mtd6/bad_blocks says:
0


dev: size erasesize name
mtd7: 02c52000 0001f000 "rootfs1"

mtdinfo -M /dev/mtd7 says:
( 0 bad blocks )

/sys/class/mtd/mtd7/bad_blocks says:
0


dev: size erasesize name
mtd8: 009ad510 0001f000 "bootfs2"

mtdinfo -M /dev/mtd8 says:
( 0 bad blocks )

/sys/class/mtd/mtd8/bad_blocks says:
0


dev: size erasesize name
mtd9: 02e23000 0001f000 "rootfs2"

mtdinfo -M /dev/mtd9 says:
( 0 bad blocks )

/sys/class/mtd/mtd9/bad_blocks says:
0


dev: size erasesize name
mtd10: 0141a000 0001f000 "data"

mtdinfo -M /dev/mtd10 says:
mtdinfo: error!: couldn't open MTD dev: /dev/mtd10
error 16 (Device or resource busy)
mtdinfo: error!: could not read locked block info
error 19 (No such device)
( 0 bad blocks )

/sys/class/mtd/mtd10/bad_blocks says:
0


dev: size erasesize name
mtd11: 0081d000 0001f000 "defaults"

mtdinfo -M /dev/mtd11 says:
mtdinfo: error!: couldn't open MTD dev: /dev/mtd11
error 16 (Device or resource busy)
mtdinfo: error!: could not read locked block info
error 19 (No such device)
( 0 bad blocks )

/sys/class/mtd/mtd11/bad_blocks says:
0
 
Thanks, I could save & run the code from /tmp, but with not much success, everything is "fine" except for the first visible "4 bad blocks" at /dev/mtd0:

dev: size erasesize name
mtd0: 10000000 00020000 "brcmnand.0"

mtdinfo -M /dev/mtd0 says:
2044: 0ff80000 BAD 2045: 0ffa0000 BAD 2046: 0ffc0000 BAD 2047: 0ffe0000 BAD
( 4 bad blocks )

/sys/class/mtd/mtd0/bad_blocks says:
0
Yeah, it seems mtd0 does not know it has bad blocks though. The value in bad_blocks should say 4, not 0 I think.
 
@xmanyes Your flash memory is fine. You don't have any bad blocks, it's just that the ubifs filesystem for /jffs has been flagged as read-only.

I saw earlier that you were looking at the other thread that describes the same problem on a different model of router. You just have to go through the same process but modifying the commands to match your particular model.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top