What's new

fstab - custom

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

mmmmmm

Occasional Visitor
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:
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.
 
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.
 
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
 
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"
 
Nice work, mmmmmm!

But you can also use the fstab file from /jffs/config/, writting in it:

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"

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.
 
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.
 
Swap is indeed a very useful feature, especially when you are transferring large quantities of data, like me. :D

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
 
Swap file is very usefull!

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 ?
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:
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
 
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


This is work for me ^^ thx. my sda3 don't know why after reboot will change to sda3(1)..................
 
Here is are my working scripts.
...
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

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.
 
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.
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"

there is no fstab in /jffs/config/ . Maybe was back in 2012...
 
sor
He was suggesting that you could create a (new) user fstab file in the config directory instead of using the one in /etc. That's all.
sorry, just realised that.

I have created such file with correct mounts but doesn't get picked up
 
Maybe mkdir mount point in /jffs/scripts/init-start

then add file /jffs/scripts/fstab.postconf to replace some text as uuid.

or use the /jffs/config/fstab.conf to replace all mount,but you need to set according /proc/mounts or /etc/mtab
 

Latest threads

Sign Up For SNBForums Daily Digest

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