0% found this document useful (0 votes)
8 views2 pages

Linux Filesystem Setup Guide

This document discusses how to format, mount, and unmount Linux filesystems like ext4 and xfs. It covers using commands like mkfs, mount, tune2fs, and blkid. It also discusses configuring persistent mounts using UUIDs in /etc/fstab and customizing mount options.

Uploaded by

hiruzen
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Linux Filesystem Setup Guide

This document discusses how to format, mount, and unmount Linux filesystems like ext4 and xfs. It covers using commands like mkfs, mount, tune2fs, and blkid. It also discusses configuring persistent mounts using UUIDs in /etc/fstab and customizing mount options.

Uploaded by

hiruzen
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

####################################

Create, mount and unmount standard


Linux Filesystem
####################################

Formating ext4 filesystem


-------------------------

# mkfs.ext4 -L DATA /dev/sdb6


# tune2fs -L MYDATA -c 0 -i 0 /dev/sdb6
# dumpe2fs /dev/sdb6 | less

Formating xfs filesystem


------------------------
# [Link] -b size=1k -l size=10m /dev/sdb7 -f
# xfs_db -x /dev/sdb7
xfs_db> label DATA2
writing all SBs
new label = "DATA2"
xfs_db> label
label = "DATA2"
xfs_db> quit

Mount filesystem
-----------------

# mkdir -p /data/{mydata,data2}

# mount /dev/sdb6 /data/mydata/


# mount | grep mydata
/dev/sdb6 on /data/mydata type ext4 (rw,relatime,seclabel,data=ordered)

Remount with options


# mount -o remount,noexec /dev/sdb6 /data/mydata/
# mount | grep mydata
/dev/sdb6 on /data/mydata type ext4 (rw,noexec,relatime,seclabel,data=ordered)

Presistance Mount using UUID


----------------------------
Find the UUID
# blkid /dev/sdb6
/dev/sdb6: LABEL="MYDATA" UUID="af520c04-0b28-4b67-ac7a-cf986221a336" TYPE="ext4"

Edit /etc/fstab
UUID="af520c04-0b28-4b67-ac7a-cf986221a336" /data/mydata ext4 noexec 0 2

To verify everything is working


# mount -a

Mount Options
-------------
man page are very useful

Modify fstab file


UUID="af520c04-0b28-4b67-ac7a-cf986221a336" /data/mydata ext4 noatime,noexec
0 2
UUID="a7f0f069-1600-4437-ae75-75bb846f012d" /data/data2 xfs
noexec,noatime,uquota,gquota,gqnoenforce 0 0
Apply
# umount /data/data2/
# umount /data/mydata/
# mount -a
# mount | grep data
/dev/sdb6 on /data/mydata type ext4 (rw,noexec,noatime,seclabel,data=ordered)
/dev/sdb7 on /data/data2 type xfs
(rw,noexec,noatime,seclabel,attr2,inode64,usrquota,gqnoenforce)

Common questions

Powered by AI

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 .

You might also like