Create and configure file systems Flashcards
to create a file system
use mkfs(may ways to use it depending on the file system type, ie) # mkfs -t ext4 /dev/sdb1 # mkfs.ext4 /dev/sdb1
tune2fs
helps us control how many times a filesystem can be mounted before a filesystem check needs to run on it.
Command to run after you’ve formatted a partition
#tune2fs -m0 /dev/sdb1
check info on a filesystem
tune2fs -l /dev/sdb1
check a filesystem
fsck /dev/sdb1 do not run on a mounted filesystem
to create an xfs filesystem
mkfs.xfs /dev/sdb2
to create a vfat filesystem
mkfs.vfat /dev/sdb3
To get details about a file system type
dumpe2fs /dev/sdb2
to repair an unmounted filesystem consistency (xfs filesystem)
xfs_repair /dev/sdb2
to get details about a mount xfs filesystem
xfs_info /dev/sdb2
to repair an unmounted vfat filesystem
fsck.vfat /dev/sdb3
steps to mount a filesystem
1 - create a directory #mkdir /mnt/data 2. mount the filesystem # mount -t ext4 /dev/sdb1 /mnt/data 3. check that it's mounted # mount | grep data 4. add entry to /etc/fstab to mount after reboot(permanent)
What’s needed to mount an NFS(network file system) filesystem
Install the NFS client package: # yum install -y nfs-utils
Activate the nfs-idmap service at boot: # systemctl enable nfs-idmap
Note: The nfs-idmap service is required by NFSv4 but doesn’t allow you any UID/GID mismatches between clients and server. It is only used when setting ACL by names or to display user/group names.
All permission checks are still done with the UID/GID used by the server (see this thread about nfs-idmap for more details).
Start the nfs-idmap service: # systemctl start nfs-idmap
Edit the /etc/fstab file and add the following line:
nfsserver:/home/tools /mnt nfs4 defaults 0 0
Execute the /etc/fstab file configuration: # mount -a
To check the current configuration, type: # mount | grep nfsserver
To unmount the NFS mounted directory # umount /mnt
Note: if you get a message like “/mnt: device is busy”, to check that you are not in the mounted directory and no process is using it, type: # umount /mnt
show which nfs filesystem is available on a system
showmount -e [ip or hostname]
mount nfs to a local directory
# mkdir /mnt/nfs # mount -t nfs ip:/srv/nfs /mnt/nfs you could also put hostname instead of ip For permanent entry add to /etc/fstabname:/srv/nfs /mnt/nfs nfs _netdev 0 0
for nfs use _netdev instead of defaults
It tells the mount command to wait for the network services to come up prior to mounting the share(to prevent hanging)
CIFS network file system
Install the samba client packages #yum install -y cifs-utils # yum install -y samba-client
Let’s assume that the /shared directory is exported by the smbserver server.
Edit the /etc/fstab file and add the following line:
//smbserver/shared /mnt cifs rw,username=user01,password=pass 0 0
Execute the /etc/fstab file configuration: # mount -a