LinuxCommandLibrary

vgmknodes

Create device nodes for Volume Groups

SYNOPSIS

vgmknodes [OPTIONS] [VolumeGroupName...]

PARAMETERS

-a, --all
    Creates device nodes for all known LVM logical volumes across all volume groups.

-c, --chown {User|Group}
    Changes the user or group owner of the created device nodes. For example, root:disk.

-g, --chgrp Group
    Changes the group owner of the created device nodes.

-m, --chmod Mode
    Sets the permissions mode for the created device nodes (e.g., 0600 or 0660).

-f, --force
    Forces the creation or recreation of nodes, even if they already exist or other conditions might prevent it.

-n, --node-format Format
    Specifies a custom format string for naming the device nodes, allowing placeholders like %VG (Volume Group name) and %LV (Logical Volume name).

-t, --test
    Runs the command in test mode, displaying what actions would be performed without actually creating or modifying any device nodes.

-v, --verbose
    Enables verbose debugging output, providing more detailed information about the command's execution.

VolumeGroupName...
    Specifies one or more Volume Group names for which to create logical volume device nodes. If omitted and --all is not used, it typically processes active volume groups.

DESCRIPTION

vgmknodes is a utility within the LVM2 (Logical Volume Manager) suite. Its primary purpose is to ensure that the special block device files (nodes) corresponding to LVM logical volumes (LVs) exist in the /dev directory.

These device nodes are essential for accessing the logical volumes, allowing them to be mounted, used by applications, or otherwise interacted with like regular block devices. In modern Linux systems, udev (or similar dynamic device management systems) typically handles the automatic creation and management of these device nodes when LVM volumes are activated or detected.

Therefore, vgmknodes is less frequently needed for day-to-day operations. However, it remains a crucial tool for troubleshooting, recovery scenarios, or in environments where udev might not be fully functional or enabled. It can be used to manually re-create missing device nodes after system reboots, LVM configuration changes, or if the /dev directory has been cleaned. The command can operate on specific volume groups or all detected LVM volumes, ensuring their respective device files are present and have the correct permissions.

CAVEATS

Automatic Management: In most modern Linux distributions, udev (or a similar system) automatically creates LVM device nodes when volumes are activated or detected. Manual use of vgmknodes is typically only necessary for troubleshooting, system recovery, or in environments without udev.

Permissions: Incorrect use of --chown, --chgrp, or --chmod can lead to permission issues, preventing proper access to logical volumes.

Major/Minor Numbers: While options for specifying major/minor numbers exist (e.g., -s, -M), they are rarely used directly by administrators as these are handled by the kernel and device management systems.

NODE PATHS

LVM device nodes are typically found in /dev//. For example, /dev/myvg/mylv. These are symbolic links pointing to the actual device files in /dev/mapper/.

INTERACTION WITH UDEV

When udev is running, vgmknodes is often invoked internally by other LVM commands (like vgchange -a y) or by udev rules themselves, rather than being run as a standalone command by the user. If udev is not running or misconfigured, vgmknodes can be used to manually populate /dev.

HISTORY

vgmknodes is an integral part of the LVM2 project, which significantly re-architected LVM from its original LVM1 version. Its importance has shifted over time; in earlier Linux systems or those without robust dynamic device management, manually running vgmknodes after reboots or LVM configuration changes was common. With the widespread adoption and sophistication of udev (and systemd integration), the need for explicit manual execution of vgmknodes has greatly diminished, as udev handles the dynamic creation and removal of LVM device nodes as volumes are activated/deactivated. Despite less frequent direct usage, it remains a vital component of LVM's underlying functionality and a fallback tool for system administrators.

SEE ALSO

lvm(8), vgchange(8), lvcreate(8), udevadm(8), mknod(1)

Copied to clipboard