Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:techref:block_mount [2019/02/14 07:24] – Improved config generation method vgaeteradocs:techref:block_mount [2023/04/06 07:20] (current) – Old scripts were removed 10 years ago https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=d55316af38d76fc62d5354b9f444d474406f801d so remove the descriptions too to avoid confusing current users paulfertser
Line 15: Line 15:
  
 :!: block info cannot detect btrfs (added [[https://dev.openwrt.org/changeset/43868/trunk|r43868]]), xfs , jfs, ntfs, exfat, and some other FS. Use manual scripting to mount them. :!: block info cannot detect btrfs (added [[https://dev.openwrt.org/changeset/43868/trunk|r43868]]), xfs , jfs, ntfs, exfat, and some other FS. Use manual scripting to mount them.
 +
 +:!: For ntfs mount [[https://forum.openwrt.org/t/block-mount-ntfs-not-a-tty/64350|read here]]
  
 <code> <code>
Line 87: Line 89:
 |vfat|  @lightgreen:✔  |  @lightgreen:✔  |  @lightgreen:✔  |  @lightgreen:✔  |  @lightgreen:✔  | kmod-fs-vfat | kmod-nls-base, kmod-nls-cp437, kmod-nls-iso8859-1, kmod-nls-utf8 | |vfat|  @lightgreen:✔  |  @lightgreen:✔  |  @lightgreen:✔  |  @lightgreen:✔  |  @lightgreen:✔  | kmod-fs-vfat | kmod-nls-base, kmod-nls-cp437, kmod-nls-iso8859-1, kmod-nls-utf8 |
 |btrfs|  @red:✘((use btrfs-show to get the UUID))  |  @red:✘  |  @red:✘  |  @red:✘  |  @red:✘  | kmod-fs-btrfs | btrfs-progs | |btrfs|  @red:✘((use btrfs-show to get the UUID))  |  @red:✘  |  @red:✘  |  @red:✘  |  @red:✘  | kmod-fs-btrfs | btrfs-progs |
- 
-FIXME Are the following sections also all defunct, now that we have the ubox based block-mount? 
- 
- 
- 
- 
-==== block.sh ==== 
-This the core script for mounting of block devices.  It consists of the following functions: 
- 
-^ Function ^ Description ^ 
-| ''reset_block_cb'' | Sets the functions ''mount_cb'' and ''swap_cb'' to the default functions | 
-| ''mount_cb'' | This subfunction is used return the values from a call to ''config_get_mount'' It is usually overridden by a more specific version.  The default version just takes the parameters passed to it by ''config_get_mount'' and assigns them to variables (which are global, unless made local by the calling function, then they are local to the calling function). | 
-| ''swap_cb'' | Like ''mount_cb'' but for ''config_get_swap'' | 
-| ''reset_dev_section_cb'' | Sets the functions ''mount_dev_section_cb'' and ''swap_dev_section_cb'' to the default functions. | 
-| ''mount_dev_section_cb'' | Like ''mount_cb'', but for a call to ''get_mount_section_by_device'' | 
-| ''swap_dev_section_db'' | Like ''mount_dev_section_cb'', but for a  call to ''get_swap_section_by_device'' | 
-| ''config_get_mount'' | Gets the values of options from specified ''mount'' section and returns using ''mount_cb'' See [[docs:guide-user:storage:fstab]]. | 
-| ''config_get_swap'' | Gets the values of options from specified ''swap'' section and returns using ''swap_cb'' See [[docs:guide-user:storage:fstab]].  | 
-| ''config_get_automount'' | Gets values of options from ''global'' section named ''automount'' See [[docs:guide-user:storage:fstab]]. | 
-| ''config_get_autoswap'' | Get values of options from ''global'' section named ''autoswap''. See [[docs:guide-user:storage:fstab]]. | 
-| ''config_create_swap_fstab_entry''| Creates an entry in ''/tmp/fstab'' (which by default is used as ''/etc/fstab'' by OpenWRT) for an enabled swap device. | 
-| ''config_create_mount_fstab_entry''| Creates an entry in ''/tmp/fstab'' (which by default is used as ''/etc/fstab'' by OpenWRT) for an enabled fs device. | 
-| ''libmount_find_token'' | Uses blkid to find the device (if any) with a given UUID or LABEL (token = UUID or LABEL, value = the uuid to find or label to find) | 
-| ''libmount_find_device_by_id'' | Takes a uuid, label and device (e.g. of which may be empty), and finds the device with the given uuid, or, if (and only if), no uuid is specifed, the given label, and if (and only if) no uuid or label is specified, the given device.  Return the device found for the given 'id' | 
-| ''config_get_mount_section_by_device'' | Uses ''mount_dev_section_cb'' to return the values of the ''mount'' section which corresponds to the device the function is asked to find, and creates an ''/tmp/fstab'' entry for it.   Overrides mount_cb, then resets it to default. | 
-| ''config_get_swap_section_by_device'' | Uses ''swap_dev_section_cb'' to return the values of the ''swap'' section which corresponds to the device the function is asked to find, and creates an ''/tmp/fstab'' entry for it.   Overrides swap_cb, then resets it to default.  | 
- 
-=== Usage notes === 
-Most of these functions are only used internally.  Generally of the functions only the callbacks and config_get_x_by_device and config_get_x are relevant outside this file.  The usage is usually to override the callback to only return the desired values, and then to do e.g. 
-<code> 
-device=/dev/sda1 
-config_load fstab 
-config_foreach config_get_mount_by_device mount $device 
-</code> 
-Which would return the ''mount'' section associated with ''/dev/sda1'' (e.g. when called by hotplug because ''/dev/sda1'' was mounted).  Will correctly find the section associated with this ''/dev/sda1'', even if the ''mount'' section is defined by ''uuid'' and not ''device''. 
- 
-===== mount.sh ===== 
-This script library is used by ''/etc/init.d/fstab'' and by the ''block-extroot'' package.  It consists of the following functions: 
- 
-^Function ^Description ^ 
-| ''config_mount_by_section'' | For the specified ''mount'' section, finds the device associated with it.  If ''enabled_fsck'' is specified, checks the filesystem for errors and repairs any found, then create an ''/tmp/fstab'' entry for it and mounts it' If the device section is a rootfs (i.e. ''is_rootfs'' is specfied), the device is mounted on ''/overlay'', otherwise, if mounted (and in the fstab entry), the directory is the ''target'' option of this ''mount'' section.  Overrides ''mount_cb'' and resets it to default. | 
-| ''config_swap_by_section'' | Like ''config_mount_by_section'' but for a ''swap'' section (and there is not ''is_rootfs'' type option).  Overrides ''swap_cb'' and resets it to default. | 
- 
-=== Usage notes === 
-These functions are generally called like: 
-<code> 
-config_load fstab 
-config_foreach config_mount_by_section mount 
-</code> 
-for a normal mount, or 
-<code> 
-config_load fstab 
-config_foreach config_mount_by_section mount 1 
-</code> 
-to mount a rootfs on ''/overlay'' (if any rootfs section specified). 
- 
- 
-===== fsck.sh ===== 
-this script library is used by the ''block-mount'' and ''block-hotplug'' packages.  It has one function ''libmount_fsck'' and expects that fsck programs will place files under ''/lib/functions/fsck'' which contain functions ''fsck_{fstype}'' for each fstype the fsck program supports and will append the supported filesystems to the variable ''libmount_known_fsck'' e.g. the package ''e2fsprogs'' has ''/lib/functions/fsck/e2fsck.sh'', which defines ''fsck_ext2'', ''fsck_ext3'', and ''fsck_ext4'', and and if the fsck in the image is ''e2fsck'', then ''libmount_known_fsck'' will equal the string ''"ext2 ext3 ext4"''. 
- 
-The function ''libmount_fsck'' is called with the device, fstype, and boolean fsck_enabled as parameters.  If fsck is enabled and fstype is one of the known types, and the filesystem is not already mounted, or a swap, then the function will attempt to call ''fsck_{fstype} $device''. 
  
 ===== block-hotplug (binary package) ===== ===== block-hotplug (binary package) =====
 Block hotplug consists of three scripts, ''10-swap'', ''20-fsck'', and ''40-mount'' When a block devices is added these scripts are executed in the order listed.  So, first the device is checked for being a ''swap'' section, or to attempt to mount as swap, if it is not a defined section for swap or mount (this is known as ''anon_swap'' or anonymous swap).  Then ''20-fsck'' checks if the device is listed as ''enabled_fsck'' and if so, attempts to check/repair the filesystem, and, finally, we check if the device should be mounted, either named, or anonymously (i.e. not listed in any section). Block hotplug consists of three scripts, ''10-swap'', ''20-fsck'', and ''40-mount'' When a block devices is added these scripts are executed in the order listed.  So, first the device is checked for being a ''swap'' section, or to attempt to mount as swap, if it is not a defined section for swap or mount (this is known as ''anon_swap'' or anonymous swap).  Then ''20-fsck'' checks if the device is listed as ''enabled_fsck'' and if so, attempts to check/repair the filesystem, and, finally, we check if the device should be mounted, either named, or anonymously (i.e. not listed in any section).
  • Last modified: 2019/02/14 07:24
  • by vgaetera