Fstab Configuration
The /etc/config/fstab configuration file defines static file systems and swap partitions that should be activated at boot.
Note that the disks these filesystems and swap partitions reside on must be available when the system is booting.
Else you will have to mount them manually.
Also, the modules for the particular file systems must be installed and loaded into the kernel.
The paket names are kmod-fs-ext3, kmod-fs-ext4, kmod-fs-vfat, etc. Bear in mind that the file system ntfs is still closed source,
thus kmod-fs-ntfs will only grant you read access. To gain read-write access to this file system, you need to install the paket ntfs-3g.
Then type ntfs-3g /dev/sda1 /mnt/dir -o rw. Be aware that this performs very poorly.
The block-mount and block-hotplug packages must be installed to use this configuration file!
There is a bug: vim /etc/init.d/fstab and put a # in front of the line echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /etc/fstab. This creates the file /etc/fstab and thus prevents creating a symlink to /tmp/fstab. In order for uci to work, there need to be symlink!
Sections
The configuration file can consist of sections defining file systems to be mounted and swap partitions to be activated.
Automount
There is one global section named automount which defines the hotplug automounting behaviour.
This example is included by default:
config global automount
option from_fstab 1
option anon_mount 1
The automount section contains these settings:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
from_fstab | boolean | no | 1 | Whether to use mount sections when doing hotplug mounts |
anon_mount | boolean | no | 1 | When using hotplug mounts, whether to automatically mount filesystems not defined in a mount section under /mnt/$device |
Autoswap
There is one global section named autoswap which defines the hotplug auto swap behaviour.
This example is included by default:
config global autoswap
option from_fstab 1
option anon_swap 0
The autoswap section contains these settings:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
from_fstab | boolean | no | 1 | Whether to use swap sections when doing hotplug swap on |
anon_swap | boolean | no | 0 | When using hotplug swapon, whether to automatically swapon devices not defined in a swap section |
Mounting Filesystem
Each mount section defines a filesystem to be mounted at boot. Filesystems must be formatted before they can be used.
This example is included by default:
config mount
option target /home
option device /dev/sda1
option fstype ext3
option options rw,sync
option enabled 0
option enabled_fsck 0
The mount section contains these settings:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
device | string | yes or uuid or label | (none) | Device (partition) to mount the filesystem from. If uuid or label are specified, they are used, rather than device. |
uuid | string | yes or device or label | (none) | UUID of device (partition) to mount the filesystem from, as shown by blkid. If uuid is present in the mount section, it is used in preference to label or device. |
label | string | yes or device or uuid | (none) | LABEL of device (partition) to mount the filesystem from, as shown by blkid. If uuid is present in the mount section, it takes precedence. label takes precedence over device. |
enabled | boolean | no | 1 | Whether to mount this filesystem automatically at boot. |
fstype | string | no | auto | Type of the filesystem (i.e. ext3). |
options | string | no | rw | Mount options for this filesystem. |
target | string | yes | (none) | Target directory to mount the filesystem onto. |
enabled_fsck | boolean | no | 0 | Whether to automatically check for/repair errors before mounting the filesystem. |
is_rootfs | boolean | no | 0 | Whether this filesystem is a rootfs for use with block-extroot. If it is a rootfs and block-extroot is installed, then during preinit, this filesystem will be mounted on /overlay and used as the root overlay (like jffs2 on a normal squashfs boot, only with this filesystem). target is ignored for the purposes of a rootfs mount, however when doing the squashfs mount (e.g. a fallback, or on firstboot), it will be used as usual. rootfsonexternalstorage |
Adding Swap Partitions
Each swap section defines a swap partition to be activated at boot.
Swap partitions must be formatted before they can be used and the swap-utils package needs to be installed!
This example is included by default:
config swap
option device /dev/sda2
option enabled 0
The swap section contains these settings:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
device | string | yes or uuid or label | (none) | Device (partition) to mount the swap from. uuid and label take precedence |
uuid | string | yes or device or label | (none) | UUID of device (partition) to mount the swap from, as shown by blkid. If uuid is present in the mount section, it is used in preference to label or device. |
label | string | yes or device or uuid | (none) | LABEL of device (partition) to mount the swap from, as shown by blkid. If uuid is present in the mount section, it takes precedence. label takes precedence over device. |
enabled | boolean | no | 1 | Whether to activate this swap partition automatically at boot. |
The right amount of SWAP
If you ask people or search the net, you will find as a general rule of thumb double RAM for machines with 512MiB of RAM or less than, and same amount as RAM for machines with more. But this very rough estimate does apply for your embedded device! Be aware that there are exactly two differences between RAM and SWAP, that matter: the access time and the price. A CUPS spooling server will run just fine, when only SWAP is available, whereas some applications may perform very poorly when their data it stored on the SWAP rather then being kept in the "real" RAM. The decision which data is kept in the RAM and which is stored on the SWAP is made by the system. As explained here Debian Forum (german) since Kernel 2.6 you can define the swapiness of your system:
$ sysctl -w vm.swappiness=60 $ echo 60 > /proc/sys/vm/swappiness
In contrast to other operating systems, Linux makes ample use of memory, so that your system runs smoother and more efficiently. If memory is then needed by an application, the system will unload stuff again, and make memory available. For OpenWrt, let us just say to use as much SWAP-Space as needed by your applications running. If this should not perform well, because of the poor access time, it would not help to decrease the amount of SWAP, but only to run fewer services at the same time or increase the amount of RAM with a soldering iron
OpenWrt vanilla will run just fine, with no SWAP at all. But after you installed a couple of applications, you could try to mount a SWAP-Partition and see what is does for you. Do not worry, you can not brake anything by doing that. The manual commands are swapon /dev/sdaX to mount respectivly swapoff /dev/sdaX to unmount. Type in free to see the usage of memory:
# free
total used free shared buffers
Mem: 29484 28540 944 0 1116
Swap: 524280 2336 521944
Total: 553764 30876 522888
In this example there is 32MiB of RAM and 512MiB of SWAP. SWAP is a SWAP-formated 512MiB-Partition on a large USB-Harddisk. In this example, only 2MiB are being used! And you do not see here, that actually half the RAM is being wasted for a TMPFS-Drive. Use df to see that:
#df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 1280 1280 0 100% /rom tmpfs 14744 116 14628 1% /tmp <====up to 14MiB from the RAM //could// be wasted here. tmpfs-partitions grow and shrink with usage! tmpfs 512 0 512 0% /dev /dev/mtdblock3 5440 4988 452 92% /overlay mini_fo:/overlay 1280 1280 0 100% / /dev/sda2 2709204 86276 2485284 3% /mnt/sda2 /dev/sda3 7224600 147320 6710196 2% /mnt/sda3
In this example, it would probably perform better, to mount the /tmp-directory on the USB-Harddisk and not use TMPFS at all, rather than using a 512MiB-Swap Partition. But you can also see, that overlay has only 8% space left to install programs on. So in this example it would be even better to use the exroot option. See rootfsonexternalstorage
for that.
doc/uci/fstab.txt · Last modified: 2010/07/08 17:23 by orca

