Linux Filesystem Setup Guide
Linux Filesystem Setup Guide
Using 'usrquota' and 'gquota' enables user and group quotas, respectively, allowing administrators to control and limit disk usage per user or group. To implement, modify '/etc/fstab' with options like 'UUID="..." /data/data2 xfs noexec,noatime,uquota,gquota' and remount the filesystem. This helps in managing storage resources efficiently but requires additional administrative overhead .
The block size, chosen with 'mkfs.xfs -b size=<size>', determines the smallest unit of storage on disk and should match the workload type; larger blocks can improve sequential access performance but waste space with small files. The log size affects the journal and transaction capabilities, with 'mkfs.xfs -l size=<size>', impacting transaction speed and reliability. Choosing these parameters requires balancing performance demands and resource constraints .
To configure persistent mounting using UUID, identify the UUID with 'blkid /dev/sdb6', which outputs something like 'UUID="af520c04-0b28-4b67-ac7a-cf986221a336"'. Then, modify '/etc/fstab' to include 'UUID="af520c04-0b28-4b67-ac7a-cf986221a336" /data/mydata ext4 noexec 0 2'. UUIDs are preferred because they remain consistent even if device paths change due to hardware reconfiguration, thus providing a more stable identifier .
The 'relatime' option updates access time only if they are earlier than the current modification time, offering a compromise between performance and timestamp accuracy, whereas 'strictatime' updates access time with every file read. This reduces unnecessary disk writes, enhancing performance, particularly in read-heavy environments, while still maintaining adequate timestamp information for most applications .
The 'tune2fs' command allows you to adjust various settings, such as disabling the maximum mount count or changing the check interval with 'tune2fs -L MYDATA -c 0 -i 0 /dev/sdb6'. Adjusting these can improve boot times by reducing unnecessary checks or optimize filesystem performance based on specific use cases .
Use 'mount | grep <filesystem_name>' to check the currently mounted filesystems and their options. This command lists the mountpoints along with the options they are mounted with, such as 'noexec' and 'noatime', allowing administrators to verify current settings and diagnose issues .
To create and mount an ext4 filesystem, you first need to format the partition using the command 'mkfs.ext4 -L DATA /dev/sdb6'. Then, you can adjust filesystem parameters, such as disabling the maximum mount count and interval with 'tune2fs -L MYDATA -c 0 -i 0 /dev/sdb6'. After formatting, create the mount point directory using 'mkdir -p /data/mydata' and mount the filesystem with 'mount /dev/sdb6 /data/mydata/'. Finally, verify with 'mount | grep mydata' that it is mounted as ext4 .
The 'noexec' option prevents the execution of binaries within the filesystem, enhancing security by reducing the risk of executing unwanted or malicious code. The 'noatime' option improves performance by not updating access timestamps on read operations, which can reduce disk writes. However, these options can hinder the functionality of programs that rely on execution within the filesystem or need access time updates for caching .
Use the 'umount' command, such as 'umount /data/mydata/' to safely unmount filesystems. It is crucial to ensure no processes are using the filesystem to avoid data corruption or process errors. Use 'fuser -c /data/mydata' to check and kill using processes if needed .
To remount a filesystem with specific options, use the command 'mount -o remount,noexec /dev/sdb6 /data/mydata/'. This allows you to apply different options or permissions without unmounting and can improve system security or performance by, for example, disallowing the execution of binaries directly from the mounted filesystem .