Monday, December 1, 2014

RHEL7: Create filesystem on redhat EL 7

How to Create, mount, unmount, and use vfat, ext4 and xfs file systems.
Prerequisite

Basic Logical volume operation with xfs
# fdisk /dev/sdb
# pvcreate /dev/sdb1
# vgcreate myvg /dev/sdb1

To create a new partition called mylv with a size of 100MB, type:
# lvcreate --size 100M --name mylv /dev/myvg
Ext4 file system
To create an ext4 file system (here called /dev/myvg/mylv), type:
# mkfs.ext4 /dev/myvg/mylv

To mount this file system, type:
# mount /dev/myvg/mylv /mnt
Add entry to /etc/fstab
/dev/myvg/mylv /mnt ext4 defaults 1 2
To check an unmounted file system consistency, type:
# fsck /dev/myvg/mylv
To get details about a file system, type:
# dumpe2fs /dev/myvg/mylv

Playing around XFS.

XFS is default file system on RHEL7.


# lvcreate -n mylv -L 10G myvg
or
# lvcreate --name mylv --size 10G /dev/myvg

# mkfs.xfs /dev/myvg/mylv
Add entry to /etc/fstab file to save off the reboot.
/dev/mapper/myvg-mylv /mnt xfs defaults 1 2
# mount -a
or
# mount /dev/myvg/mylv /mnt
# df -h /mnt


Extending filesystem by 2GB
# vgs //check free space
# lvscan  // get device path
# lvextend -L +2G  /dev/myvg/mylv
# xfs_growfs /mnt
Note: do not use resize2fs, its only for ext fs

Resizing (reducing) filessytem under zfs
You can't resize zfs. If there is a scenario, you have to remove existing fs and create a new one.

To repair an unmounted file system consistency,
# xfs_repair /dev/myvg/mylv
# xfs_info /dev/myvg/mylv

C. create an Vfat file system
# mkfs.vfat /dev/myvg/mylv
Mount the filessystem.
# mount /dev/myvg/mylv /mnt
Add entry to /etc/fstab file
# vi /etc/fstab
/dev/mapper/myvg-mylv /mnt vfat defaults 1 2
To repair an unmounted file system consistency,
# fsck.vfat /dev/myvg/mylv

No comments:

Post a Comment