Differences

This shows you the differences between two versions of the page.

doc:uci:fstab [2013/05/16 16:17]
nill14
doc:uci:fstab [2014/09/06 19:27] (current)
ticpu TMPFS are not block devices nor partitions, they are directory that use system cache dynamically to store files and folders.
Line 1: Line 1:
====== Fstab Configuration ====== ====== Fstab Configuration ======
 +The [[wp>Fstab]], or **f**ile **s**ystems **tab**le, is a central configuration that defines how file systems (usually on block devices) should be mounted if requested (such as on booting the device or connecting it physically). This way, you don't have to manually mount your devices when you want to access them. The mounting configuration can consist of static file systems but also swap partitions. The fstab [[doc/UCI]] configuration file is where all the options for all devices and file systems to be mounted are defined and is located at... <code>/etc/config/fstab</code>
-The ''/etc/config/fstab'' configuration file defines static file systems and swap partitions that should be activated at boot. Please read the [[#Notes]] before proceeding.+The package **''block-mount''** (see [[doc/techref/block_mount]] for details) contains several scripts necessary for mounting the entries in this configuration. For example, block-mount contains scripts that run the mounting process at boot or upon insertion of a USB hot-plug storage device, all according to the specified Fstab configuration. It also contains the [[doc/howto/extroot|Extroot]] load script. This article explains how the UCI Fstab configuration should be configured.
-:!: The package **''block-mount''** is required:  +Please read the [[#Notes]] before proceeding. Also read [[doc/howto/Storage]] for general information on partitioning devices, formatting and mounting file systems manually.  
-  - Install <code>opkg update + 
-opkg install block-mount</code>+:!: BTRFS, JFS, UBI, XFS and potentially other (F2FS...) are not supported in /etc/config/fstab. Use manual scripting. 
 + 
 +|  {{:meta:icons:tango:48px-outdated.svg.png?nolink}} | In [[https://dev.openwrt.org/changeset/36988|r36988]] the package ''block-mount'' was changed. For fstab functionality, the new block-mount package now contains the executable ''block'' which facilitates mounting. The new package ''[[doc:techref:ubox]]'' which is automatically installed as dependency of ''block-mount'' replaced its mounting functionality. You can run ''block <info|mount|umount|detect>''.  | 
 + 
 +===== Initial Configuration ===== 
 + 
 +==== Package Installation ==== 
 +The package **''block-mount''** is required for fstab functionality. Its functionality is now provided by ''[[doc:techref:ubox]]''. It is set up as a standard [[doc/techref/initscripts|init.d]] configuration
 +  - Install <code> 
 +opkg update 
 +opkg install block-mount </code> 
 + 
 +==== Creating Initial fstab Automatically ==== 
 +After [[https://dev.openwrt.org/changeset/36988|r36988]], when installing ''block-mount'', you can use the new ''block'' utility. Call ''block detect'' to get a sample [[doc/UCI]] configuration file. You can change this to your liking.  
 + 
 +You can quickly install this standard configuration using: 
 +<code> 
 +block detect > /etc/config/fstab 
 +</code> 
 + 
 +Next, edit your fstab, as per the configuration below: 
 +<code> 
 +vi /etc/config/fstab 
 +</code> 
 + 
 +If the mount target is ''/'' then it will be used as external root upon boot. See [[doc/howto/extroot|Extroot]] for more information. Running ''block info'' is also valid to get the uuid of different file systems. Also see this guide: [[doc:techref:block_mount]] for technical details of the mounting process and scripts involved. 
 + 
 +==== Enable fstab at Boot ====
  - enable (make it start automatically on every boot up) <code>/etc/init.d/fstab enable</code>   - enable (make it start automatically on every boot up) <code>/etc/init.d/fstab enable</code>
  - and start (right now) <code>/etc/init.d/fstab start</code>   - and start (right now) <code>/etc/init.d/fstab start</code>
Whenever you change your configuration, restart this to make it take effect: <code>/etc/init.d/fstab restart</code> Whenever you change your configuration, restart this to make it take effect: <code>/etc/init.d/fstab restart</code>
 +
 +FIXME As of, or before 2014-04-14, running: <code sh>/etc/init.d/fstab start|restart</code> results in the following error message: <code sh>this file has been obseleted. please call "/sbin/block mount" directly</code>. Need to document the [b]new[b] proper way of doing things for Barrier Breaker.
 +
 +===== Configuration =====
 +The configuration file consists of mount sections defining file systems to be mounted and swap partitions to be activated.
 +
 +
 +==== Example Configuration ====
 +
 +A sample configuration looks as follows:
 +<code>
 +#### Global options
 +
 +config 'global'
 +        # mount swap devices that don't have their own config section
 +        option  anon_swap      '0'
 +        # mount block devices that don't have their own config section 
 +        option  anon_mount      '0'
 +        # automatically mount block devices when they appear
 +        option  auto_swap      '1'
 +        # automatically mount swap devices when they appear
 +        option  auto_mount      '1'
 +        # wait X seconds before trying to mount root devices on boot
 +        option  delay_root      '0'
 +        # run e2fsck on device prior to a mount
 +        option  check_fs        '0'
 +
 +#### Mount sections. Note that partitions/devices can either be defined it by their device file, mount point or UUID (or more at the same time).
 +
 +# a swap partition
 +config 'swap'
 +        option  device  'sda1'
 +        option  uuid    'd3c87695-886f-4579-ae94-0a3bb3eb6046'
 +
 +# a swap file
 +config 'swap'
 +        option  device  '/mnt/shared/swap'
 +
 +# a swap device by label (mkswap -L swap /dev/sdb2)
 +config 'swap'
 +        option  label 'swap'
 +
 +# a pivot overlay device (ext4) for extroot
 +config 'mount'
 +        option  target  '/overlay'
 +        option  uuid    '998d4bfc-81b5-469a-be2a-999ed2b81d88'
 +
 +# and a data partition (vfat)
 +config 'mount'
 +        option  target  '/data'
 +        option  uuid    'e10e-6812'
 +</code>
 +
 +
 +
 +
 +
 +:!: the sections below are often related to old versions before trunk r36988. FIXME
-===== Sections ===== 
-The configuration file can consist of sections defining file systems to be mounted and swap partitions to be activated. 
==== Automount ==== ==== Automount ====
Line 72: Line 156:
Each ''swap'' section defines a swap partition to be activated at boot.\\ 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!\\ :!: Swap partitions must be formatted before they can be used and the ''swap-utils'' package needs to be installed!\\
-:!: Swap partitions must be first defined using the ''mkswap /dev/device'' command!+:!: Swap partitions must be first defined (i.e. formatted and hex type 82 (LINUX_SWAP) selected as its partition type) using the ''mkswap /dev/device'' command!
This example is included by default: This example is included by default:
Line 105: Line 189:
Total:      553764        30876      522888</code> Total:      553764        30876      522888</code>
-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:+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 of swap are being used! And you do not see here, that actually a TMPFS-Directory is allowed to use as much as half the RAM. Use ''df'' to see that:
<code>root@OpenWrt:~# df  <code>root@OpenWrt:~# df 
Filesystem          1K-blocks      Used Available Use% Mounted on Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/root                1280      1280        0 100% /rom /dev/root                1280      1280        0 100% /rom
tmpfs                    14744      116    14628  1% /tmp      <= //Up to 14MiB of RAM may be used here, the// tmpfs                    14744      116    14628  1% /tmp      <= //Up to 14MiB of RAM may be used here, the//
-tmpfs                      512        0      512  0% /dev        //tmpfs partitions grow and shrink with usage!//+tmpfs                      512        0      512  0% /dev        //tmpfs directories grow and shrink with usage!//
/dev/mtdblock3            5440      4988      452  92% /overlay /dev/mtdblock3            5440      4988      452  92% /overlay
mini_fo:/overlay          1280      1280        0 100% / mini_fo:/overlay          1280      1280        0 100% /
Line 207: Line 291:
mount UUID=xxx /mnt mount UUID=xxx /mnt
</code> </code>
 +
 +

Back to top

doc/uci/fstab.1368713835.txt.bz2 · Last modified: 2013/05/16 16:17 by nill14