Search the Community
Showing results for tags 'filesystems'.
-
Linux is widely known for its robust filesystem. This hierarchical structure stores and organizes all kinds of data, including files and directories. It offers disk fragmentations, symbolic linking, journaling, file permission management, and more. Hence, a beginner must understand the basics of Linux’s filesystem to navigate and manage the system efficiently. In this article, you will get to know about the fundamentals of the filesystem and explore its various types. We have also included the directory structure and the commands essential for you to get started. Types of Filesystems You’re not bound to use only the default filesystem when using Linux. It supports a few filesystems which you can install on your devices: Fourth Extended Filesystem(ext4): This is the default and the most widely used filesystem in many Linux distributions. X Filesystem(XFS): This file system is commonly used in enterprises. Its most prominent features are its scalability and performance. B-Tree Filesystem(Btrfs): This is the latest and most modern filesystem, which lets you take snapshots, create subvolumes, and more. It can be used in systems where you want advanced functionalities. Basic Directory Structure Regardless of their types, every filesystem in Linux follows a hierarchical tree-like structure that forms its backbone. It lays the foundation for many concepts, like navigation and management of files. Furthermore, the root directory is usually represented by ‘/,’ and all other directories branch from the root itself. Following is a list of other essential directories that you should know: /bin: Bin is binary and contains all binary executables required for system boot and repair. It is the storage house of standard system utilities like mv, rm, ls, etc. Moreover, anything stored in this directory is accessible to all the users. /tmp: This is a temporary storage location for files that are not significant beyond the current session. Your system clears all these files upon reboot. /boot: During boot, operating systems refer to some files such as Kernel images, bootloader configuration files, and initial RAM disk files. The /boot directory holds those files and is crucial for kernel upgrades. /etc: This directory comprises the configuration files for system-wide applications and settings. For example, /etc/passwd stores user password information, and /etc/hosts stores network configurations. You can modify these files to customize system behavior. /home: When multiple users use a single system, most get their home directories for their personal space. The subdirectories within the /home directory correspond to users who have read, write, and execute permission in their respective directories. /sbin: Like binaries, the sbin directory consists of essential system binaries. On the contrary, you must have the root privileges for execution. For example, it stores utilities like fdisk, ifconfig, and iptables. /var: It stores variable data, such as log files and spool directories, that changes while you operate the system. Administrators can monitor and manage its contents to ensure proper system functioning and resource utilization. Common Commands The cd command lets you change your current directory. cd /path Put your desired path in place of /path, and it will move you to that path. The ls command displays the contents of a directory, for example: ls The mv command helps move and rename files. mv file_name.txt target_location Here, replace file_name.txt with the name of the file you want to relocate and mention the intended new path in place of target_location. You can copy files or directories to a specific path using the cp command. For instance: cp file_name.txt /path With the rm command, you can delete any file. However, you should do it carefully, as the deleted files won’t be recoverable. For example: rm file.txt A Quick Wrap-up Understanding the filesystem is essential for any Linux user, whether a beginner or an experienced professional. Hence, this guide explores its various aspects, starting from different types of filesystems. We also looked at the directory structure and discussed using various prebuilt directories. At last, we explained the common commands you would need while navigating your systems. View the full article
-
Mounting is a process of accessing files or folders through the local file system and making modifications. Windows Share is a Windows built-in feature to share files or directories with others over a local area network (LAN). In this tutorial, I will be exploring Windows Share and how to mount it on a Linux file system using the mount.cifs utility. What is CIFS CIFS also known as Common Internet File System is a dialect of SMB protocol that is developed by Microsoft to access files or folders from users over the same network connection. However, the latest SMB protocols have replaced this widely used network file-sharing protocol for mounting Windows Share on Linux. There is a specific utility called mount.cifs which is used to mount Windows Share on Linux. In the next section, I will discuss the process of installing it on Linux. How to Install CIFS-Utils on Linux To mount Windows Share on Linux mount.cifs utility is needed which is a part of the CIFS-Utils package. To install cifs-utils on Ubuntu, Debian, and distributions based on them, use the default package manager. sudo apt install cifs-utils Use the dnf package manager to install cifs-utils on CentOS and Fedora distributions, sudo dnf install cifs-utils For Red Hat (RHEL) and Red Hat-based distributions use the yum package manager. sudo yum install cifs-utils Note: For the instructions implemented in this guide, I am using Ubuntu 22.04. The process is similar and can be performed without any issue on any Linux distribution. How to Mount Windows Share on Linux We need a mount point, a directory created anywhere on the Linux system, to mount the Windows share. I am creating a /media/WinShare directory on root using mkdir command with sudo privileges. sudo mkdir /media/WinShare We will follow the below-given syntax of the mount command to mount the Windows Share on Linux. sudo mount -t cifs //[IP-ADDRESS]/[SHARE-NAME] /[MOUNT] -o username=[USERNAME] In the above syntax: [IP-ADDRESS]: It is the IP address of the remote machine, which is Windows in this case; to access the IP address, open the command prompt and run the ipconfig command. Note the IPV 4 address. [SHARE-NAME]: It is the Windows Share name or the folder name that is shared for the network. [MOUNT]: It is the mount point directory set up on the client’s machine, which is Linux. -o: This is a flag used to define cifs-utils options, to read more about the cifs utils options run man mount.cifs command. The table below lists some options that users often use. username To provide the username of the remote machine password To provide password explicitly [Not recommended] credentials To set the file containing credentials [Recommended] vers To set the protocol version explicitly 1.0, 2.0, or 3.0 Now, I have created a Windows Share with the name MyFolder, to mount it on Linux using /media/WinShare as a mount point I will use the following command. sudo mount -t cifs //192.168.18.14/MyFolder /media/WinShare -o username=shahr After executing the command you will be asked to enter the password of the remote machine. On successfully mounting the Windows Share, you will not get any alert. To verify the successful mount use the df -h command; which is essentially used to get disk space of the file system. df -h In many instances, it may be necessary to state the user domain. Find the system domain of the Windows system using the wmic (Windows Management Instrumentation Command Line) command in the command prompt. wmic computersystem get domain After knowing the domain which is WORKGROUP in my case, simply insert it in the above command using the domain option. sudo mount -t cifs //192.168.18.14/MyFolder /media/WinShare/ -o username=shahr,domain=WORKGROUP However, this is not a secure way to mount the shared folder. To make it more secure, the mount.cifs utility has an option called credentials. The credentials option allows you to set a path of a plain text file containing the credentials of the remote machine instead of explicitly mentioning the username or password. Let’s create a text file that contains the credentials of the machine to be accessed; in this case, it is the Windows machine. sudo nano ~/.credentials-cifs Type the following information in the file. username=[USERNAME] password=[PASSWORD] domain=[DOMAIN] After adding this information to the file, save the file by pressing ctrl+x and then y. To mount the Windows Share with credentials option use the following command. sudo mount -t cifs //192.168.18.14/MyFolder /media/WinShare/ -o credentials=~/.credentials-cifs Note: I will advise giving the absolute path to the credentials file instead of using ~/. How to Make the Windows Share Mount Permanent Before attempting the following section, note key important points. If the permanent mount is not properly set up, then Linux will not boot. Ensure everything is correct before reboot. I will suggest using the mount -a command to check for errors. The IP of the remote machine must be static, otherwise, the mounting will fail, and eventually the system boot. To make the Windows Share mount permanent, we need to modify the fstab (File System Table) file. The fstab file manages the file system and also allows you to mount the external file system manually. Let’s open the fstab file located in the /etc directory using the nano editor. sudo nano /etc/fstab To make Windows Share permanent on Linux, follow the syntax given below. //[IP-ADDRESS]/[SHARE-NAME] /[MOUNT] cifs credentials=[CREDENTIALS-FILE-PATH] [DUMP] [PASS] Note: Use tab instead of space to separate the fields in the fstab file. Let’s replace the [IP-ADDRESS], [SHARE-NAME], [MOUNT], and [CREDENTIALS-FILE-PATH] with actual information. The [DUMP] and the [PASS] options are used to enable backup of the mounted file system and fsck check on boot, respectively. Set 0 and 0 for both options to keep them disabled. //192.168.18.14/MyFolder /media/WinShare cifs credentials=/home/user/.credentials-cifs 0 0 Note: Provide the absolute path of the credentials file. After modifying the fstab file, save and exit the editor using ctrl+x and then y. The subsequent step involves mounting the Windows Share by means of the mount command. sudo mount /media/WinShare If there are no errors, then the mount is successful and will remain permanent even on boot. How to Unmount the Windows Share To unmount the Windows Share, use the umount command with the mount point. sudo umount /[MOUNT] In our example, the [MOUNT] is /media/WinShare directory. sudo umount /media/WinShare If the above command fails to unmount the Windows Share, then try force unmounting using the -f flag. sudo umount -f /media/WinShare Or use the -l flag, which detaches the file system if the above command also fails. sudo umount -l /media/WinShare To read more about these options, run the man mount command. How to Create Windows Share Windows Share is a directory that is set to share on a local area network. Before accessing Windows Share on Linux, it has to be set up on Windows. First, ensure that Windows is enabled for CIFS communication. For that, open the Turn Windows feature on and off on Windows. Find SMB 1.0/CIFS File Sharing Support in the list and check it. After a few moments, you will be asked to restart the system. To enable network discovery on Windows, navigate to the Advanced sharing settings; once there, you should find the option for Network discovery and ensure that this option is enabled by selecting the Turn on network discovery option. Next, we need to create a Windows Share folder that will be mounted on Linux using mount.cifs utility. Create a folder anywhere on Windows and right-click on it, and then from the context menu click on Properties. Navigate to the Sharing tab on the opened window and click on the Share button to proceed with the folder-sharing settings. Now, click on the drop-down icon, select Everyone from the list, and then click on the Add button. Select the Permission Level, set it to Read/Write to this folder, and then click on Share. Now, the Windows Share is ready to share. Conclusion If you have recently moved to Linux, then you will definitely need to access data on your Windows system. Any sort of data can be shared on Linux from Windows using the Windows Share option. To access Windows Share on Linux, the IP address and password of the Windows machine are required. Mounting the Windows Share on Linux using mount.cifs utility requires two steps. First, set the mount point on Linux and then use the mount command with the -t cifs option to mount the Windows Share on Linux. View the full article
-
OCFS2 stands for Oracle Cluster File System version 2, which is an open-source, POSIX-compliant disk-based file system developed by Oracle Corporation. It was designed to be used with Linux-based systems. The key feature of OCFS2 is its ability to be accessed concurrently from multiple nodes in a cluster, making it particularly useful for shared-disk, high-availability applications, and for use with Oracle RAC (Real Application Clusters). OCFS2 supports features such as: Journaling: This helps ensure the integrity of the file system data, allowing quick recovery after a crash or power failure.Direct IO: For efficient access to disk, bypassing caching layers for certain types of applications.Sparse Files: These are files that can allocate storage space non-contiguously to save space, useful for databases.Extended Attributes: Allows files and directories to have additional metadata beyond standard filesystem attributes.POSIX Access Control Lists (ACLs): This provides a flexible permission mechanism.Cluster-wide Locking: Ensures data consistency when multiple nodes access the file system simultaneously.OCFS2 is designed to work in high-availability environments, where system continuity and data integrity are crucial. It’s often used in scenarios where a cluster of computers needs to access a common set of data on shared storage, such as SAN (Storage Area Network) environments. Oracle has integrated OCFS2 into its product ecosystem, ensuring that it works seamlessly with their other products, especially for database solutions that require high availability and scalability. OCFS2 Troubleshooting Guide Troubleshooting issues with OCFS2 can involve various steps depending on the specific problem you’re encountering. Here’s a structured approach to help you identify and address common issues: 1. Gather information: Distribution and version: Knowing your operating system (e.g., RHEL, SUSE) and version helps identify appropriate troubleshooting steps and potential distribution-specific quirks. Cluster setup: Is this a single-node or clustered setup? Clustered setups involve additional configuration checks. Error messages: Any relevant error messages from system logs (/var/log/messages and /var/log/dmesg) can provide valuable clues about the issue. Specific problem: Describe the exact behavior you’re observing (e.g., not mounting after reboot, I/O errors). 2. Initial checks: Network connectivity (if applicable): If the OCFS2 volume resides on shared storage, verify network connectivity between nodes and ensure firewalls aren’t blocking necessary ports. o2cb service (if applicable): In some setups, the o2cb service manages the OCFS2 cluster. Check if it’s running and enabled using commands like systemctl status o2cb and systemctl enable o2cb. 3. fstab entry: Ensure the fstab entry for the OCFS2 filesystem is correct. It should include: Device name (e.g., /dev/sdb) Mount point (e.g., /var/www) Filesystem type (ocfs2) Appropriate options: _netdev: Used for network-based mounts, ensures the network is up before attempting to mount. 4. Common troubleshooting steps: Manually mount the filesystem: Try mounting the filesystem manually using the mount.ocfs2 command. This can help identify permission or configuration issues preventing automatic mounting. Check permissions: Verify that the user or group mounting the filesystem has the necessary permissions to access the mount point directory. Verify disk space: Ensure sufficient free space is available on the OCFS2 volume. Review logs: System logs (/var/log/messages and /var/log/dmesg) might provide additional clues about the issue. Look for errors related to OCFS2 or the specific device. 5. Advanced troubleshooting (if necessary): Use fsck.ocfs2: This utility can check and potentially repair file system errors, but use it with caution and back up your data beforehand (refer to the documentation for specific options and usage). Cluster configuration (if applicable): In clustered setups, review configuration files (e.g., /etc/ocfs2/cluster.conf) and ensure consistency across all nodes. Consult distribution documentation or community forums: Refer to your specific OS and OCFS2 version documentation for detailed troubleshooting steps and known issues. Additionally, community forums can provide insights from other users who might have encountered similar problems. List of all commands to work with OCFS2 Here’s a list of some common commands used to work with OCFS2: Basic management: mkfs.ocfs2: Formats a partition or device for use with OCFS2. mount.ocfs2: Mounts an OCFS2 filesystem. umount.ocfs2: Unmounts an OCFS2 filesystem. fsck.ocfs2: Checks and potentially repairs an OCFS2 filesystem. Advanced management: tunefs.ocfs2: Changes various options and parameters of an OCFS2 filesystem. ocfs2_info: Displays information about an OCFS2 filesystem. ocfs2_clrchk: Checks and clears cluster configuration information. o2cb (cluster only): Manages the OCFS2 cluster communication layer. Informational: ocfs2_lsclusters (cluster only): Lists available OCFS2 clusters. ocfs2_showconfig (cluster only): Displays the current OCFS2 cluster configuration. ocfs2_controldump (cluster only): Dumps information from the OCFS2 cluster control daemon. Debugging: debugfs.ocfs2: A debugging tool for examining internal OCFS2 data structures. 1. o2cb Service Management: Manages the O2CB cluster service, which is crucial for OCFS2 operation. Start the service: service o2cb start Stop the service: service o2cb stop Check the status: service o2cb status Enable on boot: chkconfig o2cb on (SysVinit) or systemctl enable o2cb.service (systemd) 2. tunefs.ocfs2 Tune File System Parameters: Used to adjust various file system parameters on OCFS2 volumes. Example: tunefs.ocfs2 -L "NewLabel" /dev/sdb1 changes the volume label. 3. mkfs.ocfs2 Create File System: Used to format a disk partition as an OCFS2 file system. Example: mkfs.ocfs2 -L "VolumeLabel" /dev/sdb1 4. fsck.ocfs2 File System Check: Checks and optionally repairs an OCFS2 file system. Example: fsck.ocfs2 -fy /dev/sdb1 5. mounted.ocfs2 List Mounted Volumes: Lists all OCFS2 volumes currently mounted on the system. Example: mounted.ocfs2 6. o2info Cluster Information: Displays information about the cluster configuration and status. Example: o2info --status 7. mount and umount Mounting/Unmounting File Systems: Standard Linux commands used to mount and unmount OCFS2 file systems, with options specific to cluster file systems. Mount: mount -t ocfs2 /dev/sdb1 /mnt/point Unmount: umount /mnt/point 8. debugfs.ocfs2 Debugging Tool: Provides a means to examine and debug an OCFS2 file system. Example: debugfs.ocfs2 /dev/sdb1 Additional Tools and Files: /etc/ocfs2/cluster.conf: The main configuration file for OCFS2 clusters. This file defines nodes, cluster name, and other important settings. /etc/init.d/o2cb: The init script for managing the O2CB cluster stack on systems using SysVinit. systemctl [start|stop|status] o2cb: Commands to manage the O2CB service on systems using systemd. Notes: OCFS2 Console (ocfs2console): In some distributions, an OCFS2 management GUI called ocfs2console is available. This tool provides a graphical interface to configure and manage OCFS2 clusters, but it may not be included in all Linux distributions. Cluster Management: Managing an OCFS2 cluster often involves more than just handling the file system. It might require managing network configurations, coordinating with cluster management tools (like Pacemaker or Corosync), and ensuring that all nodes maintain consistent configurations and time synchronization. The post What is OCFS2 Oracle Cluster File System? appeared first on DevOpsSchool.com. View the full article
-
- 1
-
- fstab
- filesystems
-
(and 3 more)
Tagged with:
-
File management in Linux has always been the most essential part of a user’s workflow. Fortunately, it has a great file system and offers various features for efficient file management. It has commands for creating or deleting the directories, listing them, displaying their content, limiting the access, and many more. It lets you view the mounted drives and is handy for system monitoring, storage management, troubleshooting disk issues, remote system management, etc. However, learning how to show the mounts is essential for every Linux user. So, in this quick blog, we will explain the different commands to show the mounts in Linux. How to Show the Mounts in Linux To display the mounted drives, you merely need to enter a few commands. Here, we included multiple commands to show the mounts easily. 1. The Mount Command The “mount” command displays a comprehensive list of the mounts including their mount point, file system type, and mount options. mount 2. The Df Command If you want to have a detailed insight into the mounted file systems and disk space that are used by them, use the “df” command. df -h The “-h” option instructs the system to display it in a human-readable format. 3. Read /etc/fstab File You can view the disk drives and their partitioning information by reading the “/etc/fstab” file. Cat /etc/fstab This command, upon execution, presents everything on the command line itself. 4. The Findmnt Command The “findmnt” command is an advanced version of the mount command as it provides a more detailed output. Further, it also shows the mounts in a tree-like structure with their file type and mount options. Conclusion Linux has a sturdy file management system, and listing the mounts is fundamental for most users. You can accomplish it using different commands according to the use cases. Thus, this blog includes four methods of showing the mounts in Linux: the mount, df, and findmnt commands, and the “/etc/fstab” file. View the full article
-
- linux
- filesystems
-
(and 3 more)
Tagged with:
-
Author: Kevin Hannon (Red Hat) A common issue in running/operating Kubernetes clusters is running out of disk space. When the node is provisioned, you should aim to have a good amount of storage space for your container images and running containers. The container runtime usually writes to /var. This can be located as a separate partition or on the root filesystem. CRI-O, by default, writes its containers and images to /var/lib/containers, while containerd writes its containers and images to /var/lib/containerd. In this blog post, we want to bring attention to ways that you can configure your container runtime to store its content separately from the default partition. This allows for more flexibility in configuring Kubernetes and provides support for adding a larger disk for the container storage while keeping the default filesystem untouched. One area that needs more explaining is where/what Kubernetes is writing to disk. Understanding Kubernetes disk usage Kubernetes has persistent data and ephemeral data. The base path for the kubelet and local Kubernetes-specific storage is configurable, but it is usually assumed to be /var/lib/kubelet. In the Kubernetes docs, this is sometimes referred to as the root or node filesystem. The bulk of this data can be categorized into: ephemeral storage logs and container runtime This is different from most POSIX systems as the root/node filesystem is not / but the disk that /var/lib/kubelet is on. Ephemeral storage Pods and containers can require temporary or transient local storage for their operation. The lifetime of the ephemeral storage does not extend beyond the life of the individual pod, and the ephemeral storage cannot be shared across pods. Logs By default, Kubernetes stores the logs of each running container, as files within /var/log. These logs are ephemeral and are monitored by the kubelet to make sure that they do not grow too large while the pods are running. You can customize the log rotation settings for each node to manage the size of these logs, and configure log shipping (using a 3rd party solution) to avoid relying on the node-local storage. Container runtime The container runtime has two different areas of storage for containers and images. read-only layer: Images are usually denoted as the read-only layer, as they are not modified when containers are running. The read-only layer can consist of multiple layers that are combined into a single read-only layer. There is a thin layer on top of containers that provides ephemeral storage for containers if the container is writing to the filesystem. writeable layer: Depending on your container runtime, local writes might be implemented as a layered write mechanism (for example, overlayfs on Linux or CimFS on Windows). This is referred to as the writable layer. Local writes could also use a writeable filesystem that is initialized with a full clone of the container image; this is used for some runtimes based on hypervisor virtualisation. The container runtime filesystem contains both the read-only layer and the writeable layer. This is considered the imagefs in Kubernetes documentation. Container runtime configurations CRI-O CRI-O uses a storage configuration file in TOML format that lets you control how the container runtime stores persistent and temporary data. CRI-O utilizes the storage library. Some Linux distributions have a manual entry for storage (man 5 containers-storage.conf). The main configuration for storage is located in /etc/containers/storage.conf and one can control the location for temporary data and the root directory. The root directory is where CRI-O stores the persistent data. [storage] # Default storage driver driver = "overlay" # Temporary storage location runroot = "/var/run/containers/storage" # Primary read/write location of container storage graphroot = "/var/lib/containers/storage" graphroot Persistent data stored from the container runtime If SELinux is enabled, this must match the /var/lib/containers/storage runroot Temporary read/write access for container Recommended to have this on a temporary filesystem Here is a quick way to relabel your graphroot directory to match /var/lib/containers/storage: semanage fcontext -a -e /var/lib/containers/storage <YOUR-STORAGE-PATH> restorecon -R -v <YOUR-STORAGE-PATH> containerd The containerd runtime uses a TOML configuration file to control where persistent and ephemeral data is stored. The default path for the config file is located at /etc/containerd/config.toml. The relevant fields for containerd storage are root and state. root The root directory for containerd metadata Default is /var/lib/containerd Root also requires SELinux labels if your OS requires it state Temporary data for containerd Default is /run/containerd Kubernetes node pressure eviction Kubernetes will automatically detect if the container filesystem is split from the node filesystem. When one separates the filesystem, Kubernetes is responsible for monitoring both the node filesystem and the container runtime filesystem. Kubernetes documentation refers to the node filesystem and the container runtime filesystem as nodefs and imagefs. If either nodefs or the imagefs are running out of disk space, then the overall node is considered to have disk pressure. Kubernetes will first reclaim space by deleting unusued containers and images, and then it will resort to evicting pods. On a node that has a nodefs and an imagefs, the kubelet will garbage collect unused container images on imagefs and will remove dead pods and their containers from the nodefs. If there is only a nodefs, then Kubernetes garbage collection includes dead containers, dead pods and unused images. Kubernetes allows more configurations for determining if your disk is full. The eviction manager within the kubelet has some configuration settings that let you control the relevant thresholds. For filesystems, the relevant measurements are nodefs.available, nodefs.inodesfree, imagefs.available, and imagefs.inodesfree. If there is not a dedicated disk for the container runtime then imagefs is ignored. Users can use the existing defaults: memory.available < 100MiB nodefs.available < 10% imagefs.available < 15% nodefs.inodesFree < 5% (Linux nodes) Kubernetes allows you to set user defined values in EvictionHard and EvictionSoft in the kubelet configuration file. EvictionHard defines limits; once these limits are exceeded, pods will be evicted without any grace period. EvictionSoft defines limits; once these limits are exceeded, pods will be evicted with a grace period that can be set per signal. If you specify a value for EvictionHard, it will replace the defaults. This means it is important to set all signals in your configuration. For example, the following kubelet configuration could be used to configure eviction signals and grace period options. apiVersion: kubelet.config.k8s.io/v1beta1 kind: KubeletConfiguration address: "192.168.0.8" port: 20250 serializeImagePulls: false evictionHard: memory.available: "100Mi" nodefs.available: "10%" nodefs.inodesFree: "5%" imagefs.available: "15%" imagefs.inodesFree: "5%" evictionSoft: memory.available: "100Mi" nodefs.available: "10%" nodefs.inodesFree: "5%" imagefs.available: "15%" imagefs.inodesFree: "5%" evictionSoftGracePeriod: memory.available: "1m30s" nodefs.available: "2m" nodefs.inodesFree: "2m" imagefs.available: "2m" imagefs.inodesFree: "2m" evictionMaxPodGracePeriod: 60s Problems The Kubernetes project recommends that you either use the default settings for eviction or you set all the fields for eviction. You can use the default settings or specify your own evictionHard settings. If you miss a signal, then Kubernetes will not monitor that resource. One common misconfiguration administrators or users can hit is mounting a new filesystem to /var/lib/containers/storage or /var/lib/containerd. Kubernetes will detect a separate filesystem, so you want to make sure to check that imagefs.inodesfree and imagefs.available match your needs if you've done this. Another area of confusion is that ephemeral storage reporting does not change if you define an image filesystem for your node. The image filesystem (imagefs) is used to store container image layers; if a container writes to its own root filesystem, that local write doesn't count towards the size of the container image. The place where the container runtime stores those local modifications is runtime-defined, but is often the image filesystem. If a container in a pod is writing to a filesystem-backed emptyDir volume, then this uses space from the nodefs filesystem. The kubelet always reports ephemeral storage capacity and allocations based on the filesystem represented by nodefs; this can be confusing when ephemeral writes are actually going to the image filesystem. Future work To fix the ephemeral storage reporting limitations and provide more configuration options to the container runtime, SIG Node are working on KEP-4191. In KEP-4191, Kubernetes will detect if the writeable layer is separated from the read-only layer (images). This would allow us to have all ephemeral storage, including the writeable layer, on the same disk as well as allowing for a separate disk for images. Getting involved If you would like to get involved, you can join Kubernetes Node Special-Interest-Group (SIG). If you would like to share feedback, you can do so on our #sig-node Slack channel. If you're not already part of that Slack workspace, you can visit https://slack.k8s.io/ for an invitation. Special thanks to all the contributors who provided great reviews, shared valuable insights or suggested the topic idea. Peter Hunt Mrunal Patel Ryan Phillips Gaurav Singh View the full article
-
The OS(operating system) employs the file system which is known as the file system in a computer language that is commonly abbreviated to “fs”. The “fs” is a technique that regulates how well the piece of information is protected and accessed. Without a file system, the content of the file in a memory device would not distinguish between one type of information. The information can be easily extracted and recognized by making the groups and assigning each group a name. Each group of information is referred to as a “file,” which is a terminology derived from a paper-based data management system. A “file system” is the term referring to both the organizational framework and logical principles that are used to handle the names and groupings of information. Different Techniques of Checking the Filesystem Mounted Type in Linux There are many different file system varieties in Linux that will provide several terminal commands and techniques to check the filesystem mounted type in Linux. Let us just start delving and fully understanding how well the filesystem functions in terms of understanding the various filesystem varieties in Linux and how we are going to execute each method one at a time. Prerequisite: Installing util-linux To use the root privileges of accessing the different types of file systems in Linux, we will first write the “sudo” keyword in the Linux terminal. Then, we will write the “apt” which will upgrade the deb packages. To access the mounted files system in the Linux, we use different steps to install the “util-linux” as seen below: linux@linux-VirtualBox:~ sudo apt install util-linux After writing the “sudo” command, we first have to enter the password of the Linux then it will show further details. [sudo] password for linux: Reading package lists... Done Building dependency tree Reading state information... Done util-linux is already the newest version (2.34-0.1ubuntu9.3). 0 upgraded, 0 newly installed, 0 to remove and 31 not upgraded. After installing the “util-linux”, now we can easily apply the different techniques to check the filesystem mounted type. Technique 01: The “fsck” Command The Linux command fsck stands for File System Consistency Check which analyzes filesystems for faults or unresolved problems. Step: 01 The instruction employed to produce statistics and correct potential problems is written below: linux@linux-VirtualBox:~$ sudo fsck -N fsck from util-linux 2.34 [/usr/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/sda5 [/usr/sbin/fsck.vfat (1) -- /boot/efi] fsck.vfat /dev/sda1 To get the certain filesystem, we will write the path of the filesystem which we want to get: linux@linux-VirtualBox:~$ sudo fsck –N /dev/sda5 fsck from util-linux 2.34 [/usr/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/sda5 Step: 02 To get additional information on the “fsck” statement, use the “man fsck” statement. Following is the full command: linux@linux-VirtualBox:~$ man fsck Technique 02: The “mount” Command The “mount” statement will provide all the mounted devices along with the filesystem format and mounted location in Linux. Step 01: To get the mounted filesystem’s type, we will write first the “mount” keyword along with “grep” so that we can only get those mounted files that we want to display. This is why we have provided the “^/dev” path. linux@linux-VirtualBox:~$ mount | grep “^/dev” /dev/sda5 on / type ext4 (rw,relatime,errors remount-ro) /dev/sda1 on /boot/efi type vfat (rw, relatime, fmask=0077, dmask=0077,codepage=43 7,iocharset=iso8859-1, shortname-mixed, errors=remount-ro) Step: 02 To understand more clearly about the “mount” command, write the below INSTRUCTION: linux@linux-VirtualBox:~$ man mount Technique 03: The “findmnt” Command Now, we are going to implement another technique to check the filesystem type which is “findmnt” statements in Linux. In the findmnt statement, it will show all the mounted filesystems in the device. Step: 01 The “findmnt” statement returns the target, source, and fstype which means file system type and the options which contain whether the file is read/write or read-only. At the top of the tree of the filesystem, it will be the root directory and here it is “ext4”. linux@linux-VirtualBox:~$ findmnt TARGET SOURCE FSTYPE OPTIONS / /dev/sda5 ext4 rw,relatime,errors=rem ├─/sys sysfs sysfs rw,nosuid,nodev,noexec │ ├─/sys/kernel/security securityfs securi rw,nosuid,nodev,noexec │ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/unified cgroup2 cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/rdma cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/misc cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec │ │ ├─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec │ │ └─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec │ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec │ ├─/sys/fs/bpf bpf bpf rw,nosuid,nodev,noexec │ ├─/sys/kernel/debug debugfs debugf rw,nosuid,nodev,noexec │ ├─/sys/kernel/tracing tracefs tracef rw,nosuid,nodev,noexec │ ├─/sys/fs/fuse/connections fusectl fusect rw,nosuid,nodev,noexec │ └─/sys/kernel/config configfs config rw,nosuid,nodev,noexec ├─/proc proc proc rw,nosuid,nodev,noexec │ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=28,pgrp │ └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt rw,nosuid,nodev,noexec ├─/dev udev devtmp rw,nosuid,noexec,relat │ ├─/dev/pts devpts devpts rw,nosuid,noexec,relat │ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev,inode6 │ ├─/dev/mqueue mqueue mqueue rw,nosuid,nodev,noexec │ └─/dev/hugepages hugetlbfs hugetl rw,relatime,pagesize=2 ├─/run tmpfs tmpfs rw,nosuid,nodev,noexec │ ├─/run/lock tmpfs tmpfs rw,nosuid,nodev,noexec │ └─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relati │ └─/run/user/1000/gvfs gvfsd-fuse fuse.g rw,nosuid,nodev,relati ├─/snap/bare/5 /dev/loop0 squash ro,nodev,relatime,erro ├─/snap/glances/1243 /dev/loop1 squash ro,nodev,relatime,erro ├─/snap/core20/1778 /dev/loop2 squash ro,nodev,relatime,erro ├─/snap/core20/1738 /dev/loop3 squash ro,nodev,relatime,erro ├─/snap/glances/1168 /dev/loop4 squash ro,nodev,relatime,erro ├─/snap/gnome-3-38-2004/115 /dev/loop5 squash ro,nodev,relatime,erro ├─/snap/gnome-3-38-2004/119 /dev/loop6 squash ro,nodev,relatime,erro ├─/snap/gtk-common-themes/1535 /dev/loop7 squash ro,nodev,relatime,erro ├─/snap/snap-store/558 /dev/loop8 squash ro,nodev,relatime,erro ├─/snap/snap-store/638 /dev/loop9 squash ro,nodev,relatime,erro ├─/snap/snapd/17883 /dev/loop10 squash ro,nodev,relatime,erro └─/boot/efi /dev/sda1 vfat rw,relatime,fmask=0077 Step: 02 If you want to dig deeper into the understanding of the “findmnt” command: linux@linux-VirtualBox:~$ man findmnt Here is the detailed information about the “findmnt” command which was open on another Linux man terminal page. If you want to go back to the man terminal page, you have to press “q” to exit the “man findmnt” terminal. Technique 04: The “file” Command The “file” statement, which is employed to verify the kind of a certain file, is a further technique we will employ in the filesystems in Linux. Step: 01 Below is a different example where we are checking the different filesystems while giving the different filesystems paths. linux@linux-VirtualBox:~$ sudo file –sL /dev/sda1 /dev/sda1: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "mkfs.fat", sectors/ cluster 8, Media descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 2048, sectors 1048576 (volumes > 32 MB), FAT (32 bit), sectors/FAT 1024, reserve d 0x1, serial number 0x58c97606, unlabeled linux@linux-VirtualBox:~$ sudo file –sL /dev/sda5 /dev/sda5: Linux rev 1.0 ext4 filesysten data, UUID=6e3d13f8-16f7-4e12-bff8-8ca 1bbb6d0bd (needs journal recovery) (extents) (64bit) (large files) (huge files) Step: 02 Write the following command on the terminal and hit enter if you want further information: linux@linux-VirtualBox:~$ man file Technique 05: The “blkid” Command The “blkid” statement is another technique of the filesystem in Linux which is used to find and print the block device’s information. Step: 01 To access the information of blocked devices, we will simply write the blkid command in the terminal. linux@linux-VirtualBox:~$ sudo blkid As shown in the terminal, we have gotten the information along with the type of the filesystem. /dev/sda5: UUID="6e3d13f8-16f7-4e12-bff8-8ca1bbb6d0bd" TYPE="ext4" PARTUUID="e8ce01c9-05" /dev/loop0: TYPE="squashfs" /dev/loop1: TYPE="squashfs" /dev/loop2: TYPE="squashfs" /dev/loop3: TYPE="squashfs" /dev/loop4: TYPE="squashfs" /dev/loop5: TYPE="squashfs" /dev/loop6: TYPE="squashfs" /dev/loop7: TYPE="squashfs" /dev/sda1: UUID="58C9-7606" TYPE="vfat" PARTUUID="e8ce01c9-01" /dev/loop8: TYPE="squashfs" /dev/loop9: TYPE="squashfs" /dev/loop10: TYPE="squashfs" In the “blkid” command, if we want to display the information of the specific device, then we will write the path of the device which we want to get after writing the “sudo blkid” in the terminal. linux@linux-VirtualBox:~$ sudo blkid /dev/sda1 /dev/sda1: UUID="58C9-7606" TYPE="vfat" PARTUUID="e8ce01c9-01" Step: 02 We can access the “man” page of the “blkid” phrase in Linux and view additional details about it by typing the command below. linux@linux-VirtualBox:~$ man blkid Technique 06: The “df” Command Here is another technique to figure out the overall disc space and free space on a Linux filesystem, by utilizing the “df” command in the terminal. Step: 01 Let us just learn how to examine the quantity of free space still available in the Linux filesystem using the “df” statement. As you see below, we have got the filesystem which is the name of the mounted filesystem and it will also display the type. The “1k-blocks” is the size that is represented in one-kilo blocks and the free and used storage of the mounted filesystem. linux@linux-VirtualBox:~$ sudo df -T Filesystem Type 1K-blocks Used Available Use% Mounted on udev devtmpfs 1970752 0 1970752 0% /dev tmpfs tmpfs 401852 1360 400492 1% /run /dev/sda5 ext4 25107716 9980164 13826816 42% / tmpfs tmpfs 2009244 0 2009244 0% /dev/shm tmpfs tmpfs 5120 4 5116 1% /run/lock tmpfs tmpfs 2009244 0 2009244 0% /sys/fs/cgroup /dev/loop0 squashfs 128 128 0 100% /snap/bare/5 /dev/loop1 squashfs 10112 10112 0 100% /snap/glances/1243 /dev/loop2 squashfs 64896 64896 0 100% /snap/core20/1778 /dev/loop3 squashfs 64768 64768 0 100% /snap/core20/1738 /dev/loop4 squashfs 10240 10240 0 100% /snap/glances/1168 /dev/loop5 squashfs 354688 354688 0 100% /snap/gnome-3-38-2004/115 /dev/loop6 squashfs 354688 354688 0 100% /snap/gnome-3-38-2004/119 /dev/loop7 squashfs 93952 93952 0 100% /snap/gtk-common-themes/1535 /dev/loop8 squashfs 55552 55552 0 100% /snap/snap-store/558 /dev/loop9 squashfs 47104 47104 0 100% /snap/snap-store/638 /dev/loop10 squashfs 50816 50816 0 100% /snap/snapd/17883 /dev/sda1 vfat 523248 4 523244 1% /boot/efi tmpfs tmpfs 401848 28 401820 1% /run/user/1000 Step: 02 We shall type the man df statement on the terminal to obtain extra knowledge about the “df” statement: linux@linux-VirtualBox:~$ man df Technique 07: The “fstab” Command This technique will hold the static information of the filesystem in Linux. Step: 01 We first write the “cat” command so that we can access the filesystem information and then we write the path /etc/fstab. linux@linux-VirtualBox:~$ cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda5 during installation UUID=6e3d13f8-16f7-4e12-bff8-8ca1bbb6d0bd / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/sda1 during installation UUID=58C9-7606 /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0 Step: 02 The following command can be used to dig deeply into the “fstab” statement: linux@linux-VirtualBox:~$ man fstab Technique 08: The “lsblk” Command The “lsblk” technique is utilized to show data on block devices, which except for RAM discs, are essentially files that indicate linked devices. Step: 01 We have used “-f” in the command so that we can represent the arguments of the files. linux@linux-VirtualBox:~$ lsblk -f NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT loop0 squash 0 100% /snap/bare loop1 squash 0 100% /snap/glan loop2 squash 0 100% /snap/core loop3 squash 0 100% /snap/core loop4 squash 0 100% /snap/glan loop5 squash 0 100% /snap/gnom loop6 squash 0 100% /snap/gnom loop7 squash 0 100% /snap/gtk- loop8 squash 0 100% /snap/snap loop9 squash 0 100% /snap/snap loop10 squash 0 100% /snap/snap sda ├─sda1 │ vfat 58C9-7606 511M 0% /boot/efi ├─sda2 │ └─sda5 ext4 6e3d13f8-16f7-4e12-bff8-8ca1bbb6d0bd 13.2G 40% / sr0 Step: 02 Use the command below to see the additional information on the “lsblk” statement: linux@linux-VirtualBox:~$ man lsblk” Technique 09: The “udevadm” Command The udevadm command is one of the techniques which we are going to use to check the filesystem type. The udev library is queried for device information using the udevadm command. But it also contains information about the filesystem type in Linux. Step 01: To check the file system type, the very first command we are going to use is the “udevadm” command in the Linux terminal. Write the following command in the Linux terminal: linux@linux-VirtualBox:~$ udevadm info –query=property /dev/sda1 | egrep “DEVNAME|ID_FS_TYPE” We have used the above command to query the database for the desired file type of device data with the “—query” statement. If we simply write the “udevadm –query”, the terminal will show us a lengthy output. This is why we have to use the “grep” statement that will show the necessary information to determine the file system type by further writing the “/dev/sda1” path. DEVNAME=/dev/sda1 ID_FS_TYPE=vfat Step 02: To get further details about the “udevadm” command in the Linux, we will use the “man” command in the Linux terminal: linux@linux-VirtualBox:~$ man udevadm The udevadm command will be opened into a new terminal of the Linux as shown below in the snapshot: Conclusion We have learned what is filesystem and how to check the type of mounted filesystem in Linux. We have discussed the different techniques of the mounted filesystem by writing every command of the filesystem type in the Linux terminal. View the full article
-
- filesystems
- linux
-
(and 1 more)
Tagged with:
-
In Linux, every directory has its own purpose for its existence. The same is true for the sysfs directory. The sysfs entries are used by the kernel to export the information to processes in the user domain and to get input from the user. These entries travel through the file system to find the show and store functions registered for it. Entries in sysfs can be sorted based on the bus type, object type, device type, parent/child relationships, etc. Symlinks aid in reducing redundancies. What Will We Cover? In this article, we will explore the sysfs filesystem in Linux. Let’s start with an overview of the sysfs. Overview of the sysfs File System Sysfs was introduced in Linux for the first time in kernel version 2.6.0. The sysfs is a virtual file system in Linux. It means that the files on sysfs do not reside on a disk or any physical media. However, the contents of the file systems are stored in memory. Originally, sysfs was based on ramfs and was called ddfs (Device Driver Filesystem). Sysfs sends data to user space using virtual files. These data comprise data about various kernel subsystems, hardware devices, and associated device drivers. Usually, sysfs is mounted on the /sys partition and is automatically mounted by the system. Also, it can be mounted manually on boot using the fstab file: $ mount -t sysfs sysfs /sys From the previous command, we note that the sysfs is mounted on /sys. This is the standard location where the sysfs is mounted on. The Sysfs Hierarchy Sysfs is a cluster of files, folders, and symlinks. Most of the files inside /sys are read-only. Some files are also writable, which helps in modifying kernel variables. Symlinks are widely used for linking entries throughout the filesystem tree. We recommend using the “tree” command to see a complete view of this directory. On our system, the “tree” command shows a total of 9480 directories and 38635 files which is an extensive collection of files and directories. On the top level, 11 major subdirectories are created at system boot. These subdirectories are representations of the major subsystems registered with the sysfs. At boot-up, these subsystems are registered with the kobject core. Once initialization is done, they start to find objects registered within their corresponding directories. Files and Subdirectories of the /sys File System Let’s now see a few files and subdirectories of the /sys file system and discuss their basic purpose. The most important virtual subdirectories on the top level of /sys are block, bus, hypervisor, class, devices, kernel, firmware, module, and power. 1. /sys/block: It has one symlink and directories for every block device discovered on the system. These symlinks point to their respective directories under the directory /sys/devices. There are many subdirectories inside here: These block devices, shown in cyan color, have attributes containing information about the partitions. Examples of these subdirectories are sda, sdb, etc. 2. /sys/bus: A bus is a medium/channel between a processor and a device or devices. Examples of bus types include PCI, PCMCIA, SCSI, or USB. For every bus type in the kernel, there is a subdirectory that resides in the /sys/bus directory. Each such subdirectory has further two more subdirectories: devices and drivers. i) devices: It contains symlinks to the entries in /sys/devices (the global device tree) for every device discovered on the bus. ii) driver: It contains a subdirectory for every device driver loaded on the bus. These subdirectories contain attributes for managing driver parameters and symlinks. 3. /sys/class: A class is a high-level view of a device. This directory further contains one more level of subdirectories for every device class registered on the system. These classes may be terminals, network devices, sound devices, etc. These subdirectories contain symlinks for every device in a class. These symlinks point to the entries in the /sys/devices directory. 4. /sys/class/net: Every symlink in this directory represents either one of the real or virtual networking devices, which are visible in the network namespace of the process accessing the directory. Every such symlink points to the entries in the /sys/devices directory. 5. /sys/devices: The /sys/device directory contains the entire kernel device tree in the file system view. It includes each physical device found by the bus types registered with the kernel. 6. /sys/firmware: It contains interfaces for managing objects and attributes that are firmware specific. Here, firmware is a code that is executed on system boot-up. For example, the platform may be x86 bios, OpenFirmware, and ia64. There are many files in the EFI folder as an example. Sample output: $ ls firmware/efi/ config_table esrt fw_vendor runtime systab efivars fw_platform_size mok-variables runtime-map vars Each of these files contains some value for a parameter. 7. /sys/kernel: There are many files and folders in this subdirectory that give data about the active kernel. 8. /sys/module: For every module loaded into the kernel, there is a subdirectory that resides in this directory. The naming of these subdirectories is based on the name of the corresponding kernel. Inside each module directory, there is a subdirectory called sections which contains attributes about the module sections. Many files are like coresize, initsize, initstate, srcversion, etc. Similarly, there are many subdirectories like drivers, holders, notes, parameters, etc. 9. /sys/power: It represents the power subsystem and has only two attributes: disk and state. The method by which the system will go to sleep/suspend state is controlled by “disk”. “State” permits a power to gain a low-power state. Conclusion In this guide, we learned about the sysfs file systems in Linux and also seen various sub-directories and their purposes. The sysfs contains a vast amount of data. More information can be found on the man pages and also on this page, which is hosted on kernel.org View the full article
-
How to tune the Linux kernel with the /proc filesystem Image Photo by Boris Hamer on Pexels The Linux kernel is a tunable marvel that allows you to make changes to its parameters while it is running and without requiring a reboot. Posted: August 25, 2022 | %t min read | by David Both Topics: Linux administration Linux Read the full article on redhat.com Read More at Enable Sysadmin The post How to tune the Linux kernel with the /proc filesystem appeared first on Linux.com. View the full article
-
- linux
- linux kernel
-
(and 1 more)
Tagged with:
-
Logical Volume Management, or LVM, is a system used to manage logical volumes and filesystems. LVM has much more advanced features than the other volume management tools (like gparted) used to divide a disk into one or more partitions. In order to play around with LVM, we need to have concepts about the following terms. Physical Volume is the actual hard disk drive. Volume Group gathers all the logical and physical volumes into one group Logical Volume is the equivalent of disk partition conceptually in a non-LVM system. File Systems are created on logical volumes, and after creating file systems, we can mount these filesystems on the machine. This tutorial will use lvm, an apt package, to create logical volumes and filesystems. Installing LVM The lvm package does not come pre-installed on ubuntu. Install the lvm package using the apt command-line tool. ubuntu@ubuntu:~$ sudo apt-get install lvm2 -y After installing, check the version of lvm to verify the installation. ubuntu@ubuntu:~$ lvm version Creating Physical Volume, Volume Group, and Logical Volume In order to create a logical volume on a block device, a physical volume and a volume group must be created. In this section, we will create a physical volume /dev/sdc; then, we will create a volume group (/dev/vg01) from that physical volume. After this, we will create a logical volume (/dev/vg01/lv01) in this volume group. Creating Physical Volume So before creating any physical volume, let’s display all the available physical volumes on the machine. Use pvs, pvscan or pvdisplay command to display all the physical volumes. ubuntu@ubuntu:~$ sudo pvs OR ubuntu@ubuntu:~$ sudo pvscan OR ubuntu@ubuntu:~$ sudo pvdisplay So there is no physical volume already initialized from any block device on the machine. Before creating a physical volume from a block device, list all the block devices available on the machine, which can be used to create physical volumes. Use the lvmdiskscan command to list all the block devices on the machine. ubuntu@ubuntu:~$ sudo lvmdiskscan We will initialize /dev/sdc as our physical volume using the pvcreate command. A block device can not be initialized as physical volume if it is mounted on the machine. Use umount command to unmount a block device. ubuntu@ubuntu:~$ sudo umount /dev/sdc Now initialize the block device as a physical volume using the pvcreate command. ubuntu@ubuntu:~$ sudo pvcreate /dev/sdc After initializing the block device as a physical volume, now again list all the physical volume using the pvdisplay command, and the recently created physical volume will show up there. Creating Volume Group So far, we have created a physical volume; now, we will create a volume group (vg01) from the physical volume we just created. Before creating any volume group, display all the available volume groups using the vgdisplay or vgs command. ubuntu@ubuntu:~$ sudo vgs OR ubuntu@ubuntu:~$ sudo vgdisplay There is no volume group on the machine, so create a new one from the physical volume (/dev/sdc), which we just created in the previous step. The vgcreate command will be used to create a volume group. ubuntu@ubuntu:~$ sudo vgcreate vg01 /dev/sdc The above command will create a volume group (vg01) from the /dev/sdc physical volume. NOTE: We can create a volume group from more than one physical volume by using the vgcreate command as follows. ubuntu@ubuntu:~$ sudo vgcreate vg01 /dev/sdc /dev/sda /dev/sdb Now again, display all the volume groups using the vgdisplay command, and the recently created volume group vg01 will be listed there. ubuntu@ubuntu:~$ sudo vgdisplay In the above figure, we can see that the physical extent (PE) size is 7679, a maximum number of physical volumes is 0 (as we have not set its value), and the maximum number of logical volumes is 0 (as we have not set its value). We can set these parameters while creating the volume group by using the following flags. -s: physical extent size -p: maximum number physical volumes -l: maximum number of logical volumes So now we have one volume group, vg01, and we can activate and deactivate this volume group using the vgchange command. To activate the volume group, set the value of -a flag to y and deactivate the volume group, set the value of the -a flag to n along with the vgchange command. ubuntu@ubuntu:~$ sudo vgchange -a n vg01 The above command has deactivated the volume group vg01. To activate the volume group, use the following command. ubuntu@ubuntu:~$ sudo vgchange -a y vg01 Creating Logical Volume After creating a physical volume and volume group, now create the logical volume in the volume group. Before creating the logical volume, list all the available logical volumes by using the lvs, lvscan or lvdisplay command. ubuntu@ubuntu:~$ sudo lvs OR ubuntu@ubuntu:~$ sudo lvscan OR ubuntu@ubuntu:~$ sudo lvdisplay There is no logical volume, so create a logical volume of size 10GB in the vg01 volume group using the lvcreate command. ubuntu@ubuntu:~$ sudo lvcreate -L 10G -n lv01 vg01 After creating the logical volume, now list all the logical volumes by using the lvdisplay command. ubuntu@ubuntu:~$ sudo lvdisplay Creating Filesystems After creating the logical volumes, now the final step is to create a filesystem on top of the logical volume. After creating a filesystem, mount it on a directory to be accessible and can be used to store data in it. There are different file system formats (like FAT16, FAT32, NTFS, ext2, ext3, etc.) that can be used to create a filesystem. Create an ext4 filesystem by using the mkfs command. ubuntu@ubuntu:~$ sudo mkfs.ext4 /dev/vg01/lv01 After creating the filesystem, mount it on a directory to access it. Create a directory ‘/media/$USER/lv01’. ubuntu@ubuntu:~$ sudo mkdir /media/$USER/lv01 Mount the filesystem on this directory using the mount command. ubuntu@ubuntu:~$ sudo mount /dev/vg01/lv01 /media/$USER/lv01 Now the /dev/vg01/lv01 filesystem can be accessed from the ‘/media/$USER/lv01’ directory, and data can be stored on this location. In order to mount the filesystem automatically on reboot, add the entry for this filesystem in the ‘/etc/fstab’ file. Open the ‘/etc/fstab’ file in nano editor and append the line in the file. ubuntu@ubuntu:~$ sudo nano /etc/fstab /dev/vg01/lv01 /media/ubuntu/lv01 ext4 defaults 0 0 After creating and mounting the filesystem, we can use different commands like fdisk, df, or lsblk to display the file system. ubuntu@ubuntu:~$ sudo lsblk | grep lv01 OR ubuntu@ubuntu:~$ sudo df -h | grep lv01 OR ubuntu@ubuntu:~$ sudo fdisk -l | grep lv01 Using Graphical Tool For LVM So far, we have used lvm through the command-line interface, but there is a graphical tool (kvpm) available used to create logical volumes and filesystems using a nice graphical user interface. Install the kvpm by using the apt command-line tool. ubuntu@ubuntu:~$ sudo apt-get install kvpm -y After installing kvpm, open the tool from the terminal by typing the following command. ubuntu@ubuntu:~$ sudo kvpm In the storage devices tab, it is showing all the block devices available on the machine. For /dev/sdc block device, it is showing 20GiB of space remaining from a total of 30GiB space because we have created a 10GiB filesystem on this block device. Alongside the ‘Storage Devices’ tab, there is the ‘Group: vg01’ tab, and it has all the data related to the volume group we created in this tutorial. This window has all the information about the volume group, logical volume, and the filesystem created. In order to create a new logical volume using the kvpm tool, click on ‘New volume’ in the volume group tab. Specify the volume name and size of the logical volume. It will create a new logical volume named lv02, and the volume will be listed there. Confirm whether the logical volume is created or not by using the lvs command in the terminal. ubuntu@ubuntu:~$ sudo lvs To create a filesystem on lv02 using a graphical tool, select the logical volume lv02 on which you want to create a filesystem and click on ‘mkfs’. It will ask for confirmation and then create the file system after entering the file system format. In order to confirm whether the filesystem was created or not, use the following commands to list all the filesystems. ubuntu@ubuntu:~$ sudo fdisk -l | grep lv02 OR ubuntu@ubuntu:~$ sudo lsblk | grep lv02 Now, this file system can be mounted on any directory and can be used to store and retrieve data. Conclusion To manage data on a system, we need to store it in an organized way. Some files need to be stored in one filesystem and some files in another depending upon the requirement. In this scenario, we have to manage filesystems on our block devices in the machine. In this tutorial, we learned how we could create logical volumes and different filesystems on block devices. We discussed how to initialize block devices as physical volumes and how volume groups, logical volumes, and filesystems can be created using a command-line interface and a graphical user interface tool. View the full article
-
We already know that many filesystems are used and supported by the Linux operating system, e.g., ext2, ext3, ext4, FAT16, FAT32, and a lot more. The file system is necessary for working in the Linux and Windows operating systems. If you want to know what type of filesystem your Linux OS supports this article is meant for you. This article will give you a step-by-step guide to know what kind of filesystem is mounted in a Linux operating system. To start working, you must have any Linux distribution installed on your system. Login from your Linux system and open the command terminal. Make sure you have the “util-linux” package installed on your system to start checking the mounted filesystem. For this purpose, try the below “apt” command followed by the keyword “install” in a shell. Instantly, the installation will be completed, and you can now check the mounted filesystem. $ sudo apt install util-linux There are many methods available to check the file system on your system. We will illustrate each one of them one by one. Method 01: Using Findmnt Command Our first and most used way in the Linux system to know the filesystem type is the “findmnt” command. The “findmnt” command helps us find all the mounted filesystems. Let’s start working on it. To see the list of mounted filesystems, type the simple “findmnt” command in the shell as below, which will list all the filesystems in a tree-type format. This snapshot contains all the necessary details about the filesystem; its type, source, and many more. It is clear from the image that our main filesystem is “ext4”. $ findmnt Let us display the filesystems in a simple format using the below “findmnt” command with a “-l” flag. $ findmnt -l We can list the type of our mounted filesystem using the findmnt command along with the “-t” flag followed by the name of the filesystem, e.g., “ext4”. So, execute the below-stated command in the shell. The output shows the information regarding the “ext4” filesystem. $ findmnt –t ext4 To see the “df” style list of output about the filesystem, you have to use the below command. You can see that it will show extra information regarding the filesystems and their sources. $ findmnt --df You can use the modified form of this command as follows: $ findmnt -D If you want to search for the configured filesystem in a particular device, you can do so using the below command. You can see that the output shows the “vfat” type filesystem for the specific device. $ findmnt /dev/sda1 If you want to see the mount point of a filesystem, try using the below “findmnt” command followed by the backslash “/” sign. $ findmnt / If you want to know more details about the filesystem, use the man command as follows: $ man findmnt The output is shown below. Method 02: Using Blkid Command In most cases, the “findmnt” command will be enough in knowing the filesystem’s type, but there are some alternative commands for this purpose. One of them is the “blkid” command which we don’t need to mount. After the execution of the “blkid” command below, along with the “sudo” keyword, we will be able to display all the block devices along with the filesystem type. $ sudo blkid We can use the “blkid” command to know the filesystem for the particular device. $ sudo blkid /dev/sda1 To see extra details about the filesystem, try the below command: $ sudo blkid –po udev /dev/sda1 For further details try the man command below: $ man blkid The output is given below. Method 03: Using DF Command The DF command is cast-off to know the disk space usage of the filesystem. Use it with the “-T” flag to know all the filesystem’s types. $ df -T Go through the man page to know more. $ man df The detail is given in the snapshot. Method 04: Using File Command Another method to check the mounted file system is using the “file” command in the shell. You can use it for files having no extension. Hence, execute the below command to know the filesystem for a partition. It may require your password to function. $ sudo file –sL /dev/sda1 To have extra information, try the below man command in the shell. $ man file You can see the details on the main page as shown in the appended image. Method 05: Usinf Fsck Command The “fsck” command may be used to verify or restore the reliability of a filesystem by providing the partition as an argument. You will decide what sort of filesystem it is. $ fsck –N /dev/sda1 For further details, have a look at the main page. $ man fsck And you can see the details shown below. Method 06: Using Fstab Command Another new way to view the filesystem is using the “fstab” in the cat command. Therefore, try executing the below cat command in the shell. $ cat /etc/fstab For extra details, try the same man command along with the keyword “fstab”. $ man fstab Now you will be having details about the filesystem, as shown in the image attached. Method 07: Using Lsblk Command The “lsbkl” command will show the filesystem types and the devices. $ lsblk -f Run the below man command to see the details. $ man lsblk And the extra information regarding the filesystem is displayed below. Method 08: Using grep Command Last but not least, the “grep” command is used to check the filesystem. $ mount | grep “^/dev” Conclusion: We have done all the commands to check the mounted filesystem. I hope you can easily check the mounted filesystem in your Linux distribution. View the full article
-
In computing, a filesystem is a layout or format used to store files in a storage device. A filesystem is used to logically divide a storage device to keep different files organized nicely in the storage device to be searched, accessed, modified, removed, etc. easily from the storage device. There are many filesystems available today. Different filesystems have different structures, logics, features, flexibility, security, etc. Some of the most common filesystems are Ext4, Btrfs, XFS, ZFS, NTFS, FAT32, etc. There are times when a Linux system administrator will need to determine the filesystem type to simply mount the filesystem or to diagnose problems with the filesystem. Different filesystems have different tools for diagnosing problems, checking for errors and fixing them, etc. So, you have to know the filesystem a storage device is using to determine the maintenance tool/tools to use. In this article, I will show you different ways you can determine the filesystem type in Linux. So, let’s get started. Way 1: Using the df Command-Line Tool The df command-line program is preinstalled on almost every Linux distribution you will find. You can use the df command-line program to find the Filesystem type all the mounted storage devices and partitions. To find the filesystem type of all the mounted storage devices and partitions of your computer, run the df command as follows: $ df -Th The df command will show you the following information: Filesystem: The storage device name or partition name that is currently mounted. Mounted on: The directory where the storage device/partition (Filesystem) is mounted. Type: The filesystem type of the mounted storage device/partition. Size: The size of the mounted storage device/partition. Used: The disk space that is used from the mounted storage device/partition. Use%: The percentage of disk space that is used from the mounted storage device/partition. Avail: The amount of free disk space of the mounted storage device/partition. On Ubuntu, the df command will show you many loop devices as you can see in the screenshot below. You can hide the loop devices with the -x option of the df command as follows: $ df -Th -x squashfs You can also hide the tmpfs devices from the output of the df command. To hide the tmpfs devices from the output of the df command as well, run the df command with the -x option as follows: $ df -Th -x squashfs -x tmpfs Now, the output looks much cleaner. If you want, you can remove the udev devices from the df command’s output. To remove the udev devices from the output of the df command as well, run the df command as follows: $ df -Th -x squashfs -x tmpfs -x devtmpfs Only the physical storage devices and partitions will be displayed in the output of the df command. The output looks much nicer than before as well. Way 2: Using the lsblk Command The lsblk command-line program is preinstalled on almost every Linux distribution you will find. You can use the lsblk command-line program to find the Filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer. To find the filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer, run the lsblk command as follows: $ lsblk -f The lsblk command will show you the following information: NAME: The storage device name or partition name of a storage device. MOUNTPOINT: The directory where the storage device/partition (Filesystem) is mounted (if mounted). FSTYPE: The filesystem type of the storage device/partition. LABEL: The filesystem label of the storage device/partition. UUID: The UUID (Universally Unique IDentifier) of the filesystem of the storage device/partition. FSUSE%: The percentage of disk space that is used from the storage device/partition. FSAVAIL: The amount of free disk space of the storage device/partition Just as before, you can hide the loop devices from the output of the lsblk command. To hide the loop devices from the output of the lsblk command, run the lsblk command with the -e7 option as follows: $ lsblk -f -e7 As you can see, all the loop devices are removed from the output of the lsblk command. The output looks a lot cleaner than before. Way 3: Using the blkid Command The blkid command-line program is preinstalled on almost every Linux distribution you will find. You can use the blkid command-line program to find the Filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer. To find the filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer, run the blkid command as follows: $ blkid The lsblk command will show you the following information: NAME: The name of the storage device or partition name of the storage device. i.e. /dev/sda1, /dev/sda5. UUID: The UUID (Universally Unique IDentifier) of the filesystem of the storage device/partition. TYPE: The filesystem type of the storage device/partition. PARTUUID: The UUID (Universally Unique IDentifier) of the partition. You can also hide the loop devices from the output of the blkid command as before. To hide the loop devices from the output of the blkid command, run the blkid command as follows: $ blkid | grep -v 'TYPE="squashfs"' As you can see, the loop devices are not displayed in the output of the blkid command. The output looks much nicer than before. Way 4: Using the file Command The file command-line program is preinstalled on almost every Linux distribution you will find. You can use the find command-line program to identify the file type of a file on Linux. As every device is considered a file in Linux, you can use the find command-line program to determine the filesystem type of a storage device or partition in Linux. For example, to determine the filesystem type of the partition sdb1, you can run the file command as follows: $ sudo file -sL /dev/sda1 If you read the file command’s output, you can see that the sdb1 partition is using the FAT32 filesystem. In the same way, you can find the filesystem type of the sda5 partition with the file command as follows: $ sudo file -sL /dev/sda5 As you can see, the partition sda5 is using the EXT4filesystem. Way 5: Using the mount Command and /etc/mtab File The /etc/mtab file contains an entry for all the mounted storage devices and partitions of your computer. You can read this file to find the filesystem type of your storage devices and partitions. The mount command-line program also prints the contents of the /etc/mtab file. So, you can use the mount command-line program as well to find the same data. You can read the contents of the /etc/mtab file with the following command: $ sudo /etc/mtab As you can see, there is a lot of mount information in the /etc/mtab file. You can find the same information with the mount command as you can see in the screenshot below. $ mount As the /etc/mtab file or the mount command’s output has many mount entries, it’s hard to interpret it. You can use the grep command to filter the output and find what you need very easily. For example, to find the filesystem type of the sda1 partition using either the mount command or /etc/mtab file, run one of the following commands: $ cat /etc/mtab | grep /dev/sda1 Or, $ mount | grep /dev/sda1 As you can see, the filesystem type of the sda1 partition is FAT32/vfat . In the same way, to find the filesystem type of the sda5 partition using either the mount command or /etc/mtab file, run one of the following commands: $ cat /etc/mtab | grep /dev/sda5 Or, $ mount | grep /dev/sda5 As you can see, the filesystem type of the sda5 partition is EXT4. Way 6: Using the /etc/fstab File The /etc/fstab file keeps an entry for each of the storage devices or partitions that is to be mounted automatically at boot time. So, you can read this file to find the filesystem type of your desired storage device or partition. Suppose your computer is not configured to mount a storage device or partition at boot time automatically. In that case, it’s very likely that there won’t be any entry for that storage device or partition in the /etc/fstab file. In that case, you won’t find any information on that storage device or partition in the /etc/fstab file. You will have to use the other methods described in this article to find the storage device’s filesystem type or partition. You can read the contents of the /etc/fstab file with the following command: $ cat /etc/fstab The contents of the /etc/fstab file. You can see that the storage device or partition with the UUID 3f962401-ba93-46cb-ad87-64ed6cf55a5f uses the EXT4 filesystem. The storage device or partition that has the UUID dd55-ae26 is using the vfat/FAT32 filesystem. The lines starting with a # in the /etc/fstab file is a comment. These lines don’t have a real purpose. They are used for documentation purposes only. If you want, you can hide them using the grep command as follows: $ grep -v '^#' /etc/fstab As you can see, the comments are gone, and the output looks a lot cleaner than before. The /etc/fstab file uses UUID instead of the storage device name or partition name by default. You can use the blkid command to convert the UUID to storage device name or partition name. For example, to convert the UUID 3f962401-ba93-46cb-ad87-64ed6cf55a5f to the name of the storage device or partition, run the blkid command as follows: $ blkid -U 3f962401-ba93-46cb-ad87-64ed6cf55a5f As you can see, the partition sda5 has the UUID 3f962401-ba93-46cb-ad87-64ed6cf55a5f. In the same way, you can find the storage device or partition name that has the UUID DD55-AE26 as follows: $ blkid -U DD55-AE26 As you can see, the partition sda1 has the UUID DD55-AE26. Conclusion: This article has shown you different ways to determine the filesystem type of a storage device/partition in Linux. I have shown you how to use the df, lsblk, blkid, file, and mount command to determine the filesystem type of the Linux storage devices and partitions. I have also shown you how to determine the filesystem type of the storage devices and partitions of your Linux system by reading the /etc/mtab and /etc/fstab files. References: [1] File system – Wikipedia – https://en.wikipedia.org/wiki/File_system View the full article
-
Like any other filesystems, the Btrfs filesystem also has a lot of mount options that you can use to configure the Btrfs filesystem’s behavior while mounting the filesystem. This article will show you how to mount a Btrfs filesystem with your desired mount options. I will explain some of the useful Btrfs mount options as well. So, let’s get started. Abbreviations ACL – Access Control List RAID – Redundant Array of Independent/Inexpensive Disks UUID – Universally Unique Identifier Where to Put Btrfs Mount Options You can mount a Btrfs filesystem using the mount command-line program or the /etc/fstab file at boot time. You can configure the behavior of the Btrfs filesystem using mount options. In this section, I am going to show you how to mount a Btrfs filesystem using different mount options: from the command-line. using the /etc/fstab From the command-line, you can mount a Btrfs filesystem (created on the sdb storage device) on the /data directory with the mount options option1, option2, option3, etc. as follows: $ sudo mount -o option1,option2,option3,… /dev/sdb /data To mount the same Btrfs filesystem at boot time using the /etc/fstab file, you need to find the UUID of the Btrfs filesystem. You can find the UUID of the Btrfs filesystem with the following command: $ sudo blkid --match-token TYPE=btrfs As you can see, the UUID of the Btrfs filesystem created on the sdb storage device is c69a889a-8fd2-4571-bd97-a3c2e4543b6b. Open the /etc/fstab file with the following command: $ sudo nano /etc/fstab To automatically mount the Btrfs filesystem that has the UUID c69a889a-8fd2-4571-bd97-a3c2e4543b6b on the /data directory with the mount options option1,option2,option3, etc., add the following line at the end of the /etc/fstab file. UUID=c69a889a-8fd2-4571-bd97-a3c2e4543b6b /data btrfs option1,option2,option3,… 0 0 Once you’re done, press <Ctrl> + X followed by Y and <Enter> to save the /etc/fstab file. Your Btrfs filesystem should be mounted with your desired mount options. Important Btrfs Mount Options In this section, I am going to explain some of the important Btrfs mount options. So, let’s get started. The most important Btrfs mount options are: 1. acl and noacl ACL manages user and group permissions for the files/directories of the Btrfs filesystem. The acl Btrfs mount option enables ACL. To disable ACL, you can use the noacl mount option. By default, ACL is enabled. So, the Btrfs filesystem uses the acl mount option by default. 2. autodefrag and noautodefrag Defragmenting a Btrfs filesystem will improve the filesystem’s performance by reducing data fragmentation. The autodefrag mount option enables automatic defragmentation of the Btrfs filesystem. The noautodefrag mount option disables automatic defragmentation of the Btrfs filesystem. By default, automatic defragmentation is disabled. So, the Btrfs filesystem uses the noautodefrag mount option by default. 3. compress and compress-force Controls the filesystem-level data compression of the Btrfs filesystem. The compress option compresses only the files that are worth compressing (if compressing the file saves disk space). The compress-force option compresses every file of the Btrfs filesystem even if compressing the file increases its size. The Btrfs filesystem support many compression algorithms and each of the compression algorithm has different levels of compression. The Btrfs supported compression algorithms are: lzo, zlib (level 1 to 9), and zstd (level 1 to 15). You can specify what compression algorithm to use for the Btrfs filesystem with one of the following mount options: compress=algorithm:level compress-force=algorithm:level For more information, check my article How to Enable Btrfs Filesystem Compression. 4. subvol and subvolid These mount options are used to separately mount a specific subvolume of a Btrfs filesystem. The subvol mount option is used to mount the subvolume of a Btrfs filesystem using its relative path. The subvolid mount option is used to mount the subvolume of a Btrfs filesystem using the ID of the subvolume. For more information, check my article How to Create and Mount Btrfs Subvolumes. 5. device The device mount option is used in multi-device Btrfs filesystem or Btrfs RAID. In some cases, the operating system may fail to detect the storage devices used in a multi-device Btrfs filesystem or Btrfs RAID. In such cases, you can use the device mount option to specify the devices that you want to use for the Btrfs multi-device filesystem or RAID. You can use the device mount option multiple times to load different storage devices for the Btrfs multi-device filesystem or RAID. You can use the device name (i.e., sdb, sdc) or UUID, UUID_SUB, or PARTUUID of the storage device with the device mount option to identify the storage device. For example, device=/dev/sdb device=/dev/sdb,device=/dev/sdc device=UUID_SUB=490a263d-eb9a-4558-931e-998d4d080c5d device=UUID_SUB=490a263d-eb9a-4558-931e-998d4d080c5d,device=UUID_SUB=f7ce4875-0874-436a-b47d-3edef66d3424 6. degraded The degraded mount option allows a Btrfs RAID to be mounted with fewer storage devices than the RAID profile requires. For example, the raid1 profile requires 2 storage devices to be present. If one of the storage devices is not available in any case, you use the degraded mount option to mount the RAID even though 1 out of 2 storage devices is available. 7. commit The commit mount option is used to set the interval (in seconds) within which the data will be written to the storage device. The default is set to 30 seconds. To set the commit interval to 15 seconds, you can use the mount option commit=15 (let’s say). 8. ssd and nossd The ssd mount option tells the Btrfs filesystem that the filesystem is using an SSD storage device, and the Btrfs filesystem does the necessary SSD optimization. The nossd mount option disables SSD optimization. The Btrfs filesystem automatically detects whether an SSD is used for the Btrfs filesystem. If an SSD is used, the ssd mount option is enabled. Otherwise, the nossd mount option is enabled. 9. ssd_spread and nossd_spread The ssd_spread mount option tries to allocate big continuous chunks of unused space from the SSD. This feature improves the performance of low-end (cheap) SSDs. The nossd_spread mount option disables the ssd_spread feature. The Btrfs filesystem automatically detects whether an SSD is used for the Btrfs filesystem. If an SSD is used, the ssd_spread mount option is enabled. Otherwise, the nossd_spread mount option is enabled. 10. discard and nodiscard If you’re using an SSD that supports asynchronous queued TRIM (SATA rev3.1), then the discard mount option will enable the discarding of freed file blocks. This will improve the performance of the SSD. If the SSD does not support asynchronous queued TRIM, then the discard mount option will degrade the SSD’s performance. In that case, the nodiscard mount option should be used. By default, the nodiscard mount option is used. 11. norecovery If the norecovery mount option is used, the Btrfs filesystem will not try to perform the data recovery operation at mount time. 12. usebackuproot and nousebackuproot If the usebackuproot mount option is used, the Btrfs filesystem will try to recover any bad/corrupted tree root at mount time. The Btrfs filesystem may store multiple tree roots in the filesystem. The usebackuproot mount option will scan for a good tree root and use the first good one it finds. The nousebackuproot mount option will not check or recover bad/corrupted tree roots at mount time. This is the default behavior of the Btrfs filesystem. 13. space_cache, space_cache=version, nospace_cache, and clear_cache The space_cache mount option is used to control the free space cache. Free space cache is used to improve the performance of reading the block group free space of the Btrfs filesystem into memory (RAM). The Btrfs filesystem supports 2 versions of the free space cache: v1 (default) and v2 The v2 free space caching mechanism improves the performance of big filesystems (multi terabytes in size). You can use the mount option space_cache=v1 to set the v1 of the free space cache and the mount option space_cache=v2 to set the v2 of the free space cache. The clear_cache mount option is used to clear the free space cache. When the v2 free space cache is created, the cache must be cleared to create a v1 free space cache. So, to use the v1 free space cache after the v2 free space cache is created, the clear_cache and space_cache=v1 mount options must be combined: clear_cache,space_cache=v1 The nospace_cache mount option is used to disable free space caching. To disable the free space caching after the v1 or v2 cache is created, the nospace_cache and clear_cache mount option must be combined: clear_cache,nosapce_cache 14. skip_balance By default, interrupted/paused balance operation of a multi-device Btrfs filesystem or Btrfs RAID will be automatically resumed once the Btrfs filesystem is mounted. To disable automatic resuming of interrupted/paused balance operation on a multi-device Btrfs filesystem or Btrfs RAID, you can use the skip_balance mount option. 15. datacow and nodatacow The datacow mount option enables the Copy-on-Write (CoW) feature of the Btrfs filesystem. It is the default behavior. If you want to disable the Copy-on-Write (CoW) feature of the Btrfs filesystem for the newly created files, mount the Btrfs filesystem with the nodatacow mount option. 16. datasum and nodatasum The datasum mount option enables data checksumming for newly created files of the Btrfs filesystem. This is the default behavior. If you don’t want the Btrfs filesystem to checksum the data for newly created files, mount the Btrfs filesystem with the nodatasum mount option. Conclusion This article has shown you how to mount a Btrfs filesystem with your desired mount options. I have explained some of the useful Btrfs mount options as well. References [1] The Btrfs Mount Options Manpage – man 5 btrfs View the full article
-
- mounts
- filesystems
-
(and 1 more)
Tagged with:
-
The Btrfs filesystem-level encryption feature is still not available. But you can use a 3rd party encryption tool like dm-crypt to encrypt the entire storage devices of your Btrfs filesystem. In this article, I am going to show you how to encrypt the storage devices added to a Btrfs filesystem with dm-crypt. So, let’s get started. Abbreviations LUKS – Linux Unified Key Setup HDD – Hard Disk Drive SSD – Solid-State Drive Prerequisites To follow this article: You must be running either Fedora 33 Workstation or Ubuntu 20.04 LTS Linux distribution on your computer. You must have a free HDD/SSD on your computer. As you can see, I have an HDD sdb on my Ubuntu 20.04 LTS machine. I will encrypt it and format it with the Btrfs filesystem. $ sudo lsblk -e7 Installing Required Packages on Ubuntu 20.04 LTS To encrypt storage devices and format them with the Btrfs filesystem, you need to have the btrfs-progs and cryptsetup packages installed on your Ubuntu 20.04 LTS machine. Luckily, these packages are available in the official package repository of Ubuntu 20.04 LTS. First, update the APT package repository cache with the following command: $ sudo apt update To install btrfs-progs and cryptsetup, run the following command: $ sudo apt install btrfs-progs cryptsetup --install-suggests To confirm the installation, press Y and then press <Enter>. The btrfs-progs and cryptsetup packages and their dependencies are being installed. The btrfs-progs and cryptsetup packages should be installed at this point. Installing Required Packages on Fedora 33 To encrypt storage devices and format them with the Btrfs filesystem, you need to have the btrfs-progs and cryptsetup packages installed on your Fedora 33 Workstation machine. Luckily, these packages are available in the official package repository of Fedora 33 Workstation. First, update the DNF package repository cache with the following command: $ sudo dnf makecache To install btrfs-progs and cryptsetup, run the following command: $ sudo dnf install btrfs-progs cryptsetup -y Fedora 33 Workstation uses the Btrfs filesystem by default. So, it’s more likely that you will have these packages installed already, as you can see in the screenshot below. If for some reason, they are not installed, they will be installed. Generating an Encryption Key Before you can encrypt your storage devices with cryptsetup, you need to generate a 64 bytes long random key. You can generate your encryption key and store it in the /etc/cryptkey file with the following command: $ sudo dd if=/dev/urandom of=/etc/cryptkey bs=64 count=1 A new encryption key should be generated and stored in the /etc/cryptkey file. The encryption key file /etc/cryptkey can be read by everyone by default, as you can see in the screenshot below. This is a security risk. We want only the root user to be able to read/write to the /etc/cryptkey file. $ ls -lh /etc/cryptkey To allow only the root user to read/write to the /etc/cryptkey file, change the file permissions as follows: $ sudo chmod -v 600 /etc/cryptkey As you can see, only the root user has read/write (rw) permission to the /etc/cryptkey file. So, no one else can see what’s in the /etc/cryptkey file. $ ls -lh /etc/cryptkey Encrypting the Storage Devices with dm-crypt Now that you have generated an encryption key, you can encrypt your storage device. let’s say, sdb, with the LUKS v2 (version 2) disk encryption technology as follows: $ sudo cryptsetup -v --type luks2 luksFormat /dev/sdb /etc/cryptkey cryptsetup will prompt you to confirm the encryption operation. NOTE: All the data of your HDD/SSD should be removed. So, make sure to move all of your important data before you attempt to encrypt your HDD/SSD. To confirm the disk encryption operation, type in YES (in uppercase) and press <Enter>. It may take a while to complete. At this point, the storage device /dev/sdb should be encrypted with the encryption key /etc/cryptkey. Opening Encrypted Storage Devices Once you’ve encrypted a storage device with cryptsetup, you need to open it with the cryptsetup tool to be able to use it. You can open the encrypted storage device sdb and map it to your computer as a data storage device as follows: $ sudo cryptsetup open --key-file=/etc/cryptkey --type luks2 /dev/sdb data Now, the decrypted storage device will be available in the path /dev/mapper/data. You have to create your desired filesystem in the /dev/mapper/data device and mount the /dev/mapper/data device instead of /dev/sdb from now on. Creating Btrfs Filesystem on Encrypted Devices: To create a Btrfs filesystem on the decrypted storage device /dev/mapper/data with the label data, run the following command: $ sudo mkfs.btrfs -L data /dev/mapper/data A Btrfs filesystem should be created on the /dev/mapper/data storage device, which is decrypted from the storage device /dev/sdb (encrypted with LUKS 2). Mounting Encrypted Btrfs Filesystem You can mount the Btrfs filesystem you have created earlier as well. Let’s say, you want to mount the Btrfs filesystem you’ve created earlier in the /data directory. So, create the /data directory as follows: $ sudo mkdir -v /data To mount the Btrfs filesystem created on the /dev/mapper/data storage device in the /data directory, run the following command: $ sudo mount /dev/mapper/data /data As you can see, the Btrfs filesystem created on the encrypted storage device sdb is mounted in the /data directory. $ sudo btrfs filesystem show /data Automatically Mounting Encrypted Btrfs Filesystem at Boot-Time You can mount the encrypted Btrfs filesystem at boot time as well. To mount the encrypted Btrfs filesystem at boot time, you need to: decrypt the storage device /dev/sdb at boot time using the /etc/cryptkey encryption key file mount the decrypted storage device /dev/mapper/data to the /data directory First, find the UUID of the sdb encrypted storage device with the following command: $ sudo blkid /dev/sdb As you can see, the UUID of the sdb encrypted storage device is 1c66b0de-b2a3-4d28-81c5-81950434f972. It will be different for you. So, make sure to change it with yours from now on. To automatically decrypt the sdb storage device at boot time, you have to add an entry for it on the /etc/crypttab file. Open the /etc/crypttab file with the nano text editor as follows: $ sudo nano /etc/crypttab Add the following line at the end of the /etc/crypttab file if you’re using an HDD. data UUID=1c66b0de-b2a3-4d28-81c5-81950434f972 /etc/cryptkey luks,noearly Add the following line at the end of the /etc/crypttab file if you’re using an SSD. data UUID=1c66b0de-b2a3-4d28-81c5-81950434f972 /etc/cryptkey luks,noearly,discard Once you’re done, press <Ctrl> + X, followed by Y, and <Enter> to save the /etc/crypttab file. Now, find the UUID of the decrypted /dev/mapper/data storage device with the following command: $ sudo blkid /dev/mapper/data As you can see, the UUID of the /dev/mapper/data decrypted storage device is dafd9d61-bdc9-446a-8b0c-aa209bfab98d. It will be different for you. So, make sure to change it with yours from now on. To automatically mount the decrypted storage device /dev/mapper/data in the /data directory at boot time, you have to add an entry for it on the /etc/fstab file. Open the /etc/fstab file with the nano text editor as follows: $ sudo nano /etc/fstab Now, add the following line at the end of the /etc/fstab file: UUID=dafd9d61-bdc9-446a-8b0c-aa209bfab98d /data btrfs defaults 0 0 Once you’re done, press <Ctrl> + X, followed by Y, and <Enter> to save the /etc/fstab file. Finally, reboot your computer for the changes to take effect. $ sudo reboot The encrypted storage device sdb is decrypted into a data storage device, and the data storage device is mounted in the /data directory. $ sudo lsblk -e7 As you can see, the Btrfs filesystem, which was created on the decrypted /dev/mapper/data storage device is mounted in the /data directory. $ sudo btrfs filesystem show /data Conclusion In this article, I have shown you how to encrypt a storage device using the LUKS 2 encryption technology with cryptsetup. You also learn how to decrypt the encrypted storage device and format it with the Btrfs filesystem as well. As well as how to automatically decrypt the encrypted storage device and mount it at boot time. This article should help you get started with Btrfs filesystem encryption. View the full article
-
- encryption
- filesystems
-
(and 1 more)
Tagged with:
-
Network File System (NFS) is an application that allows users to access and modify files on a remote computer as if they are accessing the local storage of their own computer. It is what is called a distributed file system, and it serves as a centralized filing system for a large network of computers. NFS works with networks shared by systems with different operating systems. The administrator can also select which sections of the mounting information are made available to the client systems. This article shows you how to install and configure NFS on your ArchLinux system. Step 1: Set Up NFS packages First, we will install the packages for NFS. To do so, issue the following command: $ sudo pacman -S nfs-utils Step 2: Set NFS to Launch at Startup Use the commands below to set NFS to launch at startup: $ chkconfignfs on $ service rpcbind start $ service nfs start Now, NFS should launch at the startup. Step 3: Share Directory with Client Next, you will select a directory to share with the client and move it to /etc/exports. Use the command below to do so: $ vi /etc/exports Then, append this line to the files: # /share 192.168.87.158(rw,sync,no_root_squash,no_subtree_check) Finally, export these files with the command below: $ exportfs -a Step 4: Prepare the Client The synchronization will require certain packages that you can download with the commands below: $ sudo pacman -S nfs-utils Step 5: Mount the Shared Directory Once the packages are installed on the remote computer, it is now time to mount the shared directory: $ mkdir -p /mnt/share Then, mount the shared directory: $ mount 192.168.87.156:/share /mnt/share/ Run a confirmation test to see if the share is mounted: $ df -h Type in #mount to list the mounted file systems: $ mount Running A Test Bring over the contents to be distributed to the client through the server share directory. Type in the following command to run a test: $ touch test1 $ mkdir test Go to the /mnt/share folders in the remote computer that is serving as the client: $ ls /mnt/share/ -lh Then, add the entries in the /etc/fstab file to automatically mount the shared folder permanently. Append the /etc/fstab file with the following lines: $ vi /etc/fstab This should mount the share folder files and all its contents. Using NFS We will now go over some of the options specific to NFS that might come in handy: Fire up the terminal on the server and type the command below to see the contents up for sharing on the client machine: $ showmount -e To see the contents up for sharing on the server, you can use a variation of this command. Type the command below: $ showmount -e 192.168.87.156 The following command allows you to list all the share files on the server: $ exportfs -v To clear the /etc/exports location and send contents back to the source, enter the following: $ exportfs -u Conclusion NFS is a very simple, yet exceptionally convenient, network file sharing application. The extensive central filing system of NFS saves tons of HDD space, as many folders present on the host no longer need to be stored on each computer. The straightforward interface of NFS allows users to access the server for contents as they would access the local storage. Keep in mind that NFS is susceptible to many exploitative attacks from the internet. As such, you should also consider setting up a firewall to protect your host from these attacks. That is all we have for today. Stick around at linuxhint.com for more articles like this. We will post follow-ups to this particular post. View the full article
-
Forum Statistics
63.6k
Total Topics61.7k
Total Posts