What's new

[beta] amtm v1.6_beta, now with Disk formatting automated

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

thelonelycoder

Part of the Furniture
Since I'm the script automation guy around here, I thought I try my hand on formatting disks.

I'm all impressed by the detailed write-up by @Zonkd in his post in the EXT4 disk formatting options on the router thread, thank you Mr. Zonkd.
Looking over it and running it myself manually, I thought these steps could be automated.

So, without further ado, here's the result: fd Format Disk in amtm - the SNBForum Asuswrt-Merlin Terminal Menu.

How to install amtm v1.6_beta
Copy and paste the complete command below into your SSH terminal and press Enter.


What you need to know
- The fd function will erase all data and all partitions on the selected device
- To be on the safe side, remove all other attached USB storage devices. This is beta software and things can go wrong
- Have a backup plan before formatting the device

What can fd do
- Format ext*, FAT and NTFS to ext2, ext3 or ext4 (ext4 ARM and HND routers only).
- Set journalling on or off while formatting, ext4 only.
- Set a label
- Formatted device is dc Disk check script compatible
 
Last edited:
Do you still recommend a non-journaled file system? Especially for only running router scripts in a USB 2 port.

Sent from my A0001 using Tapatalk
 
Do you still recommend a non-journaled file system? Especially for only running router scripts in a USB 2 port.

Sent from my A0001 using Tapatalk
In all likelihood, a non-journaled file system will be fine for just running scripts and the basic entware install some scripts need.

But for me, a better question would be, why NOT use a journaling file system (i.e. ext4 w/journaling)? You'd really have to format your thumb drive both with and without journaling and different filesystems and run a utility like iozone to see if it made a difference. While sometimes there are outliers, I suspect you'd find that in general the difference in speed is very small. See this post for my number comparing ext2, ext4 with journaling and ext4 without journaling, on an external 120Gb SSD - ext2 was only 1% to 2% faster than ext4 with journaling.

It all boils down to personal preference, and what's right for one person might not be right for another.
 
You might want to put in a check or warning that it's not compatible with disks larger than 2TB as per this post.
Thanks, will add this note and probably a test for size of the /dev/. I don't have a 2TB device to test this on, what test code would you recommend?
 
Thanks, will add this note and probably a test for size of the /dev/. I don't have a 2TB device to test this on, what test code would you recommend?

Test code? You mean suggestions code wise of how do disk size checks? Code isn’t my strength, but I suppose inertavtibely ask user for target disk, set it’s sda as variable, then fdisk -l and grep line of desired Disk ads and check it’s bytes don’t exceed 2 Tb which is I think 2199023255552 B?..
 
Test code? You mean suggestions code wise of how do disk size checks? Code isn’t my strength, but I suppose inertavtibely ask user for target disk, set it’s sda as variable, then fdisk -l and grep line of desired Disk ads and check it’s bytes don’t exceed 2 Tb which is I think 2199023255552 B?..
Yes, early morning after a long night of coding for me...
I got it covered, thanks!

Also there are coding errors I found when not formatting to ext4. It would try to enable journalling for ext2 and ext3 disks.
Will be fixed soon in a coming update.
 
Since I'm the script automation guy around here, I thought I try my hand on formatting disks.

I'm all impressed by the detailed write-up by @Zonkd in his post in the EXT4 disk formatting options on the router thread, thank you Mr. Zonkd.
Looking over it and running it myself manually, I thought these steps could be automated.

So, without further ado, here's the result: fd Format Disk in amtm - the SNBForum Asuswrt-Merlin Terminal Menu.

How to install amtm v1.6_beta
Copy and paste the complete command below into your SSH terminal and press Enter.
Code:
curl -s "https://diversion.ch/scripts/amtm-beta/amtm" -o "/jffs/scripts/amtm" && chmod 755 /jffs/scripts/amtm && sh /jffs/scripts/amtm

What you need to know
- The fd function will erase all data and all partitions on the selected device
- To be on the safe side, remove all other attached USB storage devices. This is beta software and things can go wrong
- Have a backup plan before formatting the device

What can fd do
- Format ext*, FAT and NTFS to ext2, ext3 or ext4 (ext4 ARM and HND routers only).
- Set journalling on or off while formatting, ext4 only.
- Set a label
- Formatted device is dc Disk check script compatible

So, in the event of a new USB thumb drive installation....I am assuming that formatting would have to be done prior to AMTM installation using @Zonkd’s instructions, since AMTM wouldn’t install if the new drive’s formatting is different than exfat, correct?


Sent from my iPhone using Tapatalk
 
So, in the event of a new USB thumb drive installation....I am assuming that formatting would have to be done prior to AMTM installation using @Zonkd’s instructions, since AMTM wouldn’t install if the new drive’s formatting is different than exfat, correct?
That's why I include the formatting in amtm because amtm only resides in /jffs/scripts/

The idea is to install amtm first, do the formatting of the disk and continue installing whatever's next.
Diversion would be my next choice as it installs Entware, benefiting all subsequent script installs that use it.
 
That's why I include the formatting in amtm because amtm only resides in /jffs/scripts/

The idea is to install amtm first, do the formatting of the disk and continue installing whatever's next.
Diversion would be my next choice as it installs Entware, benefiting all subsequent script installs that use it.

Ok thank you very much! This makes sense. I have a brand new Sandisk. So I will install AMTM and then attempt formatting and see how everything goes! Have a great rest of the weekend!


Sent from my iPhone using Tapatalk
 
I can confirm that disk formatting installation works from amtm menu on AC86U and a new Sandisk USB drive!

Excellent work @Zonkd and @thelonelycoder!
It's not proper yet, hence the beta.
What works 99% is formatting an new FAT device to ext*. I struggle with re-formatting existing ext* devices here.
Thanks for mentioning me but all credit goes to @thelonelycoder for developing the amtm script. I haven’t tested or had time to read the code yet, but I’m sure it’s good.
You layed the groundwork. The formatting code is a step by step adaption of your tutorial.
What I'm struggling with is that while reformatting, after the fdisk partition creation a ghost device is mounted, named in the format like /tmp/mnt/sda(1) that prevents running mke2fs. I have not been entirely successful to umount that device to make mke2fs work every time.
 
Installed and reformatted to Ext4 (journalled) from Ext2. The formatting code seems to have worked fine - I've reinstalled Diversion and Skynet, but the disk check option seems to have disappeared - I can just remove it, rather than check the log.
 

Attachments

  • Screenshot 2019-01-13 at 21.49.34.png
    Screenshot 2019-01-13 at 21.49.34.png
    143.5 KB · Views: 392
Installed and reformatted to Ext4 (journalled) from Ext2. The formatting code seems to have worked fine - I've reinstalled Diversion and Skynet, but the disk check option seems to have disappeared - I can just remove it, rather than check the log.
The "remove" means it's installed at /jffs/scripts/disk-check. Looks like /jffs/amtm-disk-check.log went out for a long walk. It will return when next plugging in a device or rebooting the router. The disk checker is only run just before a device is mounted.
If not, just remove dc and re-install it.
 
Just tried it after an unrelated router meltdown. Some suggestions;

Code:
 At the eventual promt: Proceed anyway? (y,n)
 Answer with y.

Typo?

Also, it took me a moment to actually get what you meant there, would it be clearer if it was the following?

Code:
 You will be asked later : "Proceed anyway? (y,n)"
 
Answer with y.

If its possible to also add those dashing red lines like you did with the earlier options might help too.

Other then that, it seems to have done the job. Will report back if I run into any issues.

Thank you!
 
Just tried it after an unrelated router meltdown. Some suggestions;

Code:
 At the eventual promt: Proceed anyway? (y,n)
 Answer with y.

Typo?

Also, it took me a moment to actually get what you meant there, would it be clearer if it was the following?

Code:
 You will be asked later : "Proceed anyway? (y,n)"
 
Answer with y.

If its possible to also add those dashing red lines like you did with the earlier options might help too.

Other then that, it seems to have done the job. Will report back if I run into any issues.

Thank you!
Thanks, will update wording, eventually...
 

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!
Top