fstab - custom

Discussion in 'Asuswrt-Merlin' started by mmmmmm, Feb 5, 2013.

  1. mmmmmm

    mmmmmm Occasional Visitor

    Joined:
    Nov 29, 2012
    Messages:
    35
    I have an USB stick that I am using to install optional packages.
    My problem is that sometime gets mounted as sda1 other times as sdb1.

    This is a bit of a problem and I am trying to use the fstab.add feature of Merlin's version to mount the usb stick by UUID.

    I've created a /jffs/config/fstab.add file, with the content below, but it does not seem to solve my problem. I suppose that my fstab.add file is not correct.
    Code:
    UUID=c6062286-5f15-4aaa-a142-580f9441ce92       /mnt/sda1       ext2    default,umask=077,gid=46         0      0
    Beside this, I have another USB HDD with 2 partitions that also gets switched sometimes. Since I am using this HDD for my transmission download, this is quite problematic.

    The UUIDs are:
    Code:
    admin@RT-N66U:/tmp/etc# blkid
    /dev/sdc5: LABEL="SAMSUNG" UUID="01CCAADD89839CA0"
    /dev/sdc1: LABEL="SAMSUNG" UUID="01CCAADD84C35570"
    /dev/sdb1: UUID="c6062286-5f15-4aaa-a142-580f9441ce92"
    Please advice.
     
    Last edited: Feb 5, 2013
  2. Log in / Register to remove this ad

  3. mmmmmm

    mmmmmm Occasional Visitor

    Joined:
    Nov 29, 2012
    Messages:
    35
    RMerlin,

    please help!

    I was not able to find any tutorial on how to properly use the custom config files so maybe the information here will turn out to be useful.

    Thank you.
     
  4. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    14,044
    Location:
    Canada
    From the README:
    Code:
    The list of available config overrides:
    
    * dnsmasq.conf
    * vsftpd.conf
    * pptpd.conf
    * dhcp6s.conf
    * hosts (for /etc/hosts)
    * smb.conf
    * minidlna.conf
    * profile (shell profile, only profile.add suypported)
    * upnp (for miniupnpd)
    * radvd.conf
    * fstab (only fstab supported, remember to create mount point
            through init-start first if it doesn't exist!)
    
    There is no support for fstab.add, only a full replacement in the form of fstab. The reason is that the firmware does not create an fstab file, so there is nothing to append to.
     
  5. mmmmmm

    mmmmmm Occasional Visitor

    Joined:
    Nov 29, 2012
    Messages:
    35
    Sorry about that. I read the readme but it was not that clear to me. My bad.
    So the init-start is the way to go.


    Thank you very much.

    PS. I will post my finding once I get my setup working.
     
  6. mmmmmm

    mmmmmm Occasional Visitor

    Joined:
    Nov 29, 2012
    Messages:
    35
    Here is are my working scripts.

    1. Get the UUIDs, current mount points, mount options of the connected USB devices:
    Code:
    # more /etc/mtab 
    rootfs / rootfs rw 0 0
    ..............................
    /dev/sda1 /tmp/mnt/sda1 ext2 rw,nodev,noatime 0 0
    /dev/sdc1 /tmp/mnt/samsungp ufsd rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force 0 0
    /dev/sdc5 /tmp/mnt/samsungo ufsd rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force 0 0
    
    Code:
    # blkid
    /dev/sdc5: LABEL="SAMSUNG" UUID="01CCAADD89839CA0"
    /dev/sdc1: LABEL="SAMSUNG" UUID="01CCAADD84C35570"
    /dev/sda1: UUID="c6062286-5f15-4aaa-a142-580f9441ce92"
    2. Create /jffs/scripts/init-start script:
    Code:
    # more /jffs/scripts/init-start 
    #!/bin/sh
    
    mkdir -p /tmp/mnt/sda1
    echo  "UUID=c6062286-5f15-4aaa-a142-580f9441ce92        /tmp/mnt/sda1   ext2    rw,nodev,noatime        0       0" > /etc/fstab
    
    mkdir -p /tmp/mnt/samsungo
    echo  "UUID=01CCAADD89839CA0    /tmp/mnt/samsungo       ufsd    rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force 0       0" >> /etc/fstab
    
    mkdir -p /tmp/mnt/samsungp
    echo  "UUID=01CCAADD84C35570    /tmp/mnt/samsungp       ufsd    rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force 0       0" >> /etc/fstab
    
    A reboot or a 'mount -a' should mount the drives as configured in the fstab file.

    Beside the mount point switching issue, due to the fact that my HDD is NTFS formatted, I was experiencing some problems with transmission daemon not being able to find the download directory on the drive. I decided to delay the transmission daemon starting and I did the following:

    1. Remove the x permission of the "/opt/etc/init.d/S88transmission" script.
    2. Create /jffs/post-mount script:
    Code:
    # more /jffs/scripts/post-mount 
    #!/bin/sh
    
    sleep 1
    
    transmission_file=`find /opt/etc/init.d/ -name *transmission*`
    chmod 777 $transmission_file
    $transmission_file start
    chmod -x $transmission_file
    
     
  7. Serpent

    Serpent Occasional Visitor

    Joined:
    Jul 2, 2012
    Messages:
    20
    Nice work, mmmmmm!

    But you can also use the fstab file from /jffs/config/, writting in it:
    Code:
    UUID=c6062286-5f15-4aaa-a142-580f9441ce92        /tmp/mnt/sda1   ext2    rw,nodev,noatime        0       0
    
    UUID=01CCAADD89839CA0    /tmp/mnt/samsungo       ufsd    rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force 0       0
    
    UUID=01CCAADD84C35570    /tmp/mnt/samsungp       ufsd    rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,force 0       0
    
    Leave in init-start only the mkdir lines and a "mount -a" line (maybe isn't required, but doesn't harm...).

    I think it's worth to add also a swap space, using this line in init-start:
    Code:
    swapon UUID="swap_partition_UUID"
     
  8. mmmmmm

    mmmmmm Occasional Visitor

    Joined:
    Nov 29, 2012
    Messages:
    35
    Thank you Serpent for sharing this.
    I will do the changes as you suggested as it makes more sense.

    I was not aware about the swapon instruction.
    I think it is a nice feature. Is there a way to set the size of the swap?

    Thanks again.
     
  9. Serpent

    Serpent Occasional Visitor

    Joined:
    Jul 2, 2012
    Messages:
    20
    Swap is indeed a very useful feature, especially when you are transferring large quantities of data, like me. :D

    Usually you will use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are almost as fast as swap partitions, although I recommend using a swap partition.

    The beginning(first cylinders) of a HDD is the best place for a swap space, on any OS. So you need to make a partition of 256 or 512 MB and leave it raw(not formated).
    After that run the mkswap command:
    Code:
    mkswap /dev/sd[B]x[/B]1  
    Find the UUID of that swap partition with blkid and test it:
    Code:
    swapon UUID="swap_partition_UUID"
    
    Verify it with free command.

    If is working add the command swapon to init-start.
     
  10. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    421
    Location:
    Montreal
    This is something new for me (swapping in the context of a router). Could you give a little bit more information about how useful it is and why ?

    Thanks,

    GH
     
  11. joegreat

    joegreat Very Senior Member

    Joined:
    Jan 9, 2013
    Messages:
    560
    Location:
    Vienna, Austria
    Swap file is very usefull!

    Hi,

    Well, if you run Transmission (or any other memory heavy piece of software) then it can easily run out of memory.

    Here my memory stat:
    Code:
    chief@RT-N66U:/# free
                 total         used         free       shared      buffers
    Mem:        239868       185944        53924            0        34884
    -/+ buffers:             151060        88808
    Swap:        64252         2160        62092
    
    As you can see from above, ~2MB are swapped out to disk. :rolleyes:

    If the swap is not used, it does no harm.
    But if the kernel runs out of memory, you better have a swap avaliable, or you run into serious troubles! :eek:

    There are two situations, where Linux kernels get into panic mode: Out of memory and out of space on the root filesystem. :eek:

    With kind regards
    Joe :cool:
     
    Last edited: Feb 12, 2013
  12. Brouno

    Brouno Occasional Visitor

    Joined:
    May 3, 2013
    Messages:
    30
    Hello,

    Just activated swap on my RT-N66U with your infos, thanks

    I notice that I get error in the syslog ("e2fsck: Superblock invalid, trying backup blocks...") due to the filesystem check from pre-mount script on the swap partition at boot time :

    To avoid that I change the pre-mount script by the following (compare the type of the current mounting partition against swap partitions on the system from "fdisk -l"), and log things accordingly in syslog

    /jffs/scripts/pre-mount :
    Code:
    #!/bin/sh
    
    if [ `fdisk -l | grep swap | awk '{print \$1}'` == $1 ]; then 
        # Swap partition detected, not running e2fsck
        logger -t $(basename $0) "started [$@], SWAP partition detected, not running e2fsck"
    else
        # Swap partition not detected, running e2fsck
        logger -t $(basename $0) "started [$@], SWAP partition not detected, running e2fsck"
        grep -q $1 /proc/mounts || e2fsck -p $1 2>&1 | logger -t e2fsck
    fi
    
     
  13. garychu628

    garychu628 New Around Here

    Joined:
    Feb 14, 2015
    Messages:
    1

    This is work for me ^^ thx. my sda3 don't know why after reboot will change to sda3(1)..................
     
  14. coldwizard

    coldwizard Regular Contributor

    Joined:
    Apr 17, 2014
    Messages:
    132
    Please do NOT ever use 7 as the last digit in chmod unless there is no other choice. That makes the file world write and negates any security obtained by running a task like dnsmasq as nobody.
    Use chmod 755 instead.
     
    mmmmmm likes this.

Share This Page