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!

EXT4 disk formatting options on the router

Discussion in 'Asuswrt-Merlin' started by JimbobJay, Aug 13, 2018.

  1. JimbobJay

    JimbobJay Occasional Visitor

    Joined:
    Feb 16, 2017
    Messages:
    34
    Hi. Does anyone know how one can format a USB as ext4 with journaling disabled, from within the router's shell interface? When I've used the disk formatting options it seems to automatically use EXT2. Without getting onto a debate between ext2 vs ext4, does anyone know how ext4 without journaling can be accomplished? I'm doing it remotely so using a linux install on a pc isn't an option unfortunately.
     
  2. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,325
    Location:
    UK
    Try:
    Code:
    mke2fs -t ext4 /dev/sda1
    tune2fs -O ^has_journal /dev/sda1
     
  3. Zonkd

    Zonkd Senior Member

    Joined:
    Oct 19, 2014
    Messages:
    499
    Edit 29 Dec 2018: Please see my other post on the next page for a more comprehensive guide.
    ---

    Don't hold me responsible if these instructions don't work (I wrote them for myself as a guide ages ago and they might be funky).

    TL;DR Ext4 with journalling disabled: mke2fs -t ext4 -O ^has_journal -L 'DESIREDLABELHERE' '/dev/sd**'
    note: use the sd** of your target disk. Check for it with Display Disk Freespace command: man df

    Full guide below:

    # Formatting External Drives

    Alternative methods to reparation and format: Linux/Ubuntu Disk Utility, Gnome Partition Editor (GParted), or just do directly on router...

    ## Directly on the router

    ### Check disk details
    Discover the /dev/sd* number of the target usb drive using either of these commands.

    1. Show partition table for each DISK, then exit: `fdisk -l`
    2. Print filesystem usage statistics (only shows mounted disks): `df -h`

    ### Repartition the disk
    You must unmount the disk before repartitioning: `umount /tmp/mnt/disknamehere**`

    Begin partitioning the disk: `fdisk /dev/sd*`

    Display menu: `m` or `help`

    View the existing partition table: `p`

    Complete wipe and replace with a new partition table of type mdos MBR: `o`
    _Note: It's best to create a whole new empty partition table, because the existing partition table may be locked (such as when formatted on a Mac as GPT, you'd see displayed "Found valid GPT with protective MBR; using GPT" and it wouldn't give you any options in the menu)_

    Create new partition: `n` and choose `p` for primary.

    Make sure the partition is "Id 83 System Linux".

    Write/save the partition table and quit fdisk utility: `w`

    ### Format the partition

    View the saved partition table: `fdisk -l`

    Specify the partition to format **:

    Ext2 preset: `mkfs.ext2 /dev/sd**`
    Ext3 preset: `mkfs.ext3 /dev/sd**`
    Ext4 journalling disabled: `mke2fs -t ext4 -O ^has_journal -L 'LABELHERE' '/dev/sd**'`

    Popular options for the mke2fs command:
    -t : set file system type
    -L : set a new volume label
    -O : specify a feature to use (eg. '-O ^64bit' = disable 64 bit feature)

    Important Tip: mkfs.[type] is actually an alias of the real binary called `mke2fs`.

    ### Remount / Reboot

    _ASUS-WRT apparently doesn't truly understand how to remount disks, so it's best to reboot_

    Reboot the router: `/sbin/reboot`

    Or if you really can't be bothered rebooting during testing, this command should work, just don't rely on it.

    Remount the disk: `mount /dev/sd** /tmp/mnt/disknamehere`

    ### Change the label

    You can rename the partition anytime you like.

    `tune2fs -L "NEWLABELHERE" /dev/sd**`
     
    Last edited: Dec 29, 2018
  4. Zonkd

    Zonkd Senior Member

    Joined:
    Oct 19, 2014
    Messages:
    499
    Beat me to it ;)
     
    JimbobJay likes this.
  5. JimbobJay

    JimbobJay Occasional Visitor

    Joined:
    Feb 16, 2017
    Messages:
    34
    Great, that command worked! Thanks very much, both of you :)
     
    Nullity likes this.
  6. sfx2000

    sfx2000 Part of the Furniture

    Joined:
    Aug 11, 2011
    Messages:
    14,321
    Location:
    San Diego, CA
    Do it directly on the router - there's been changes on the upstream kernels and utilities that can and do present trouble down the road...
     
  7. Zonkd

    Zonkd Senior Member

    Joined:
    Oct 19, 2014
    Messages:
    499
    Thanks I wasn't aware, do you have further info on this? What issues that might appear if using methods other than direct on router? For larger disks like my 2TB external HDD I opted to use GParted. So far so good though.
     
  8. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,325
    Location:
    UK
  9. tomsk

    tomsk Very Senior Member

    Joined:
    Sep 3, 2016
    Messages:
    594
    If you already made an ext4 partition and you want to remove the journaling without wiping the data, i believe the
    Code:
    tune2fs -O ^has_journal /dev/sda1
    command should work ( adjusted for your particular device of course)
     
    SMS786 likes this.
  10. john9527

    john9527 Part of the Furniture

    Joined:
    Mar 28, 2014
    Messages:
    6,096
    Location:
    United States
    Generally the problems would show up in that the drive wouldn't mount on the router due to unrecognized options. If everything is working fine, I'd say you are OK.
     
  11. skeal

    skeal Part of the Furniture

    Joined:
    Apr 30, 2016
    Messages:
    3,642
    Location:
    Saskatchewan
    This is nice but flawed. I can't figure it out. I follow the instructions to the letter and when I commit the fdisk changes I get this for some reason:
    Code:
    fdisk: WARNING: rereading partition table failed, kernel still uses old table: Invalid argument
    I'm on the latest merlin f/w on a AC3100. I never see this:
    Code:
    Make sure the partition is "Id 83 System Linux".
    If you accept defaults twice in fdisk and then "w" to write the changes and I get that error. The disk will not mount of course. The usb2 drive is 4gig. If I format on my Ubuntu rig no matter what I get "unsupported flags" and the disk will not mount. Tried this with several drives and I mean several and every time it fails. Can anyone please offer me some guidance? I know I'm missing something. Thanks in advance. :):)
     
  12. skeal

    skeal Part of the Furniture

    Joined:
    Apr 30, 2016
    Messages:
    3,642
    Location:
    Saskatchewan
    On further examination; If I'm run"o" in fdisk, and "w" to write just that change, I get the same error.
     
  13. Zonkd

    Zonkd Senior Member

    Joined:
    Oct 19, 2014
    Messages:
    499
    I’ll check it out soon and make any corrections and rewrite so it’s all clearer. I was due to update my router to latest firmware anyway so I may as well repartition and format my USB drive while I’m at it, for science. :)
     
    ^Tripper^ and skeal like this.
  14. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,325
    Location:
    UK
    That's because you're trying to use a partition instead of a device. i.e.

    fdisk /dev/sdb1 = wrong
    fdisk /dev/sdb = right
     
    martinr and HuskyHerder like this.
  15. skeal

    skeal Part of the Furniture

    Joined:
    Apr 30, 2016
    Messages:
    3,642
    Location:
    Saskatchewan
    Are you kidding?.....Man I knew I missed something thanks for the help!!!:oops::oops:
     
  16. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,325
    Location:
    UK
    Yeah, we've all made that mistake before. :D
     
    martinr, Zonkd and skeal like this.
  17. Huib

    Huib Occasional Visitor

    Joined:
    Feb 26, 2018
    Messages:
    20
    I started with EXT4 on my SSD, no journal, using the same command shown above last year. Then I decided to switch to EXT2 and (at least in my setup) EXT2 seems to perform better. My guess would be less overhead?
     
  18. skeal

    skeal Part of the Furniture

    Joined:
    Apr 30, 2016
    Messages:
    3,642
    Location:
    Saskatchewan
    Yes I would agree with that. I however only have a 4gig drive and it's usb2, used for Entware and Skynet and a swap file. I have never experienced a problem, however I don't transfer a lot of data.:):)
     
  19. Huib

    Huib Occasional Visitor

    Joined:
    Feb 26, 2018
    Messages:
    20
    I use the disk for Entware, MiniDLNA and some swap, in USB2 mode, because USB3 kills my 2.4 GHz. I also didn't see much improvement with USB3 because the CPU is already close to maxing out when I push large amounts of data to it (using Samba). I noticed that with EXT4 transfers were hovering around 20 MB/s and with EXT2 it's hovering around 28 MB/s. This is all on an older AC68U.
     
    Last edited: Dec 24, 2018
  20. Zonkd

    Zonkd Senior Member

    Joined:
    Oct 19, 2014
    Messages:
    499
    On a 1st gen Ac68U I’ve been using a 16Gb USB3.1 Sandisk Cruzer Ultra Fit drive with Ext4 and journaling disabled. I run DNSCrypt, Diversion with logging (I was careful to choose only a few optimised blocklists), and Skynet in debug mode with a 1GB swap. No VPN server is running.

    So far performance has been brilliant so I can’t justify spending time to test Ext2 and compare. Checking the line sync stats on my bridges modem I can see the Ac68u is already delivering my max attainable speed.

    I’m comfortable recommending this exact configuration to others. I’m not sure if ext2 would perform better than ext4 under different circumstances like different model router or with heavier cpu load ( like running packages for torrenting or media server or openvpn.)
     
    Coldblackice and SMS786 like this.