1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

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

Discussion in 'Asuswrt-Merlin' started by thelonelycoder, Jan 12, 2019.

  1. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    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
     
    Last edited: Jan 12, 2019
  2. JJohnson1988

    JJohnson1988 New Around Here

    Joined:
    Dec 28, 2018
    Messages:
    5
    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
     
  3. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    7,253
    Location:
    UK
    You might want to put in a check or warning that it's not compatible with disks larger than 2TB as per this post.
     
  4. cmkelley

    cmkelley Senior Member

    Joined:
    Aug 11, 2015
    Messages:
    251
    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.
     
  5. ^Tripper^

    ^Tripper^ Regular Contributor

    Joined:
    Aug 16, 2014
    Messages:
    101
    Location:
    Disneyland with the death penalty
    Nice! Thanks a lot The-lonely-script-automation-guy-coder. :)
     
    martinr and thelonelycoder like this.
  6. Zonkd

    Zonkd Regular Contributor

    Joined:
    Oct 19, 2014
    Messages:
    197
    martinr, thelonelycoder and skeal like this.
  7. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    @cmkelley sums it up in one sentence:
     
    Zonkd and JJohnson1988 like this.
  8. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    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?
     
  9. Zonkd

    Zonkd Regular Contributor

    Joined:
    Oct 19, 2014
    Messages:
    197
    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?..
     
    thelonelycoder likes this.
  10. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    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.
     
    Clark Griswald and Zonkd like this.
  11. Marin

    Marin Senior Member

    Joined:
    Sep 15, 2015
    Messages:
    367
    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
     
  12. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    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.
     
  13. Marin

    Marin Senior Member

    Joined:
    Sep 15, 2015
    Messages:
    367
    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
     
  14. Marin

    Marin Senior Member

    Joined:
    Sep 15, 2015
    Messages:
    367
    I can confirm that disk formatting installation works from amtm menu on AC86U and a new Sandisk USB drive!

    Excellent work @Zonkd and @thelonelycoder!




    Sent from my iPhone using Tapatalk
     
  15. Zonkd

    Zonkd Regular Contributor

    Joined:
    Oct 19, 2014
    Messages:
    197
    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.
     
    martinr likes this.
  16. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    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.
    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.
     
  17. JacquesR

    JacquesR Regular Contributor

    Joined:
    Feb 3, 2014
    Messages:
    66
    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.
     

    Attached Files:

  18. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    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.
     
    JacquesR and dave14305 like this.
  19. ^Tripper^

    ^Tripper^ Regular Contributor

    Joined:
    Aug 16, 2014
    Messages:
    101
    Location:
    Disneyland with the death penalty
    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!
     
    thelonelycoder likes this.
  20. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    4,846
    Location:
    Switzerland
    Thanks, will update wording, eventually...
     
    ^Tripper^ likes this.