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
First you need to install # yum -y install nfs-utils nfs-utils-lib Then you need to start the right services # service nfs start # service rpcbind start Afterward add them to start at boot # chkconfig nfs on #chkconfig --level 35 rpcbind on
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/fstab name:/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)
for CIFS network file system (common Internet File System)
Install the samba client packages #yum install -y cifs-utils # yum install -y samba-client
Cifs permanent mounting
//smbserver/shared /mnt cifs rw,user,credentials=/root/secret.txt 0 0
in /root/secret.txt add
username=visitor
password=Welcome123$
to see which shares are available on a cifs server
smbclient -U username -L [hostname/IP]
To login to the remote cifs share
smbclient -U username //ip/shared
You can run windows command when you’ve logged into a cifs shared
smb: > get filename.txt download a file
smb: > put file1.txt upload a file
To mount a cifs share(temporarily)
mount -t cifs -o user-[username] //IP-or-host/shared /mnt/shared
review man mount.cifs
You can also do it from the desktop
Go to Places -> connect to server
Change the service type to window share, enter info, then click connect
To increase the size of a logical volue
use the lvextend command. When you extend the logical volume, yo ucan indicate how much to extend the volume, or how large you want it to be after you extend it.
The following command extends the logical volume /dev/myvg/homevol to 12GB
lvextend -L 12G /dev/myvg/homevol
The following command adds another gigabyte to the logical volume
lvextend -L +1G /dev/myvg/homevol
The following command extends the logical volume called testlv to fill all of the unallocated space in the volume group myvg
lvextend -l +100% Free /dev/myvg/testlv
adding a filesystem on a logical volume
#mkfs.ext4 /dev/vg_new/lv_new #mkdir /extra directory to mount logical volume add entry to /etc/fstab /dev/vg_new/lv_new /extra ext4 defaults 0 0 # mount -a
To grow the logival volume lvresize can also be used
#lvresize -L 900M /dev/vg_new/lv_new Then resize the filesystem # resize2fs /dev/vg_new/lv_new
To shrink the logical volume(make sure to have a backup)
#unmount extra #fsck -f /dev/vg_new/lv_new #resize2fs /dev/vg_new/lv_new 800MB #lvresize -L 800MB /dev/vg_new/lv_new
Set-GID
set-gid directories are used for group collaboration. Everything that is created in a directory with that special permission bit, is automatically owned by the group
how to apply the set-git permission
applying the set-git permission on a directory by add a 2 before the standard permission set
# chmod 2755 share
-Then you’ll see the directory has a permission set that contains a ‘s’ now in place of the x for group
-the character based way to setup a set-gid directory
#chmod g+s share
ACL(Access Control Lists)
- to use AACLs first the acl property needs to be enabled on the partition. run the mount command to check
# mount - to change and turn on ACL make changes in /etc/fstab
before
/dev/mapper/vg_rhel01/lv_root / ext4 defaults 1 1
after
/dev/mapper/vg_rhel01/lv_root / ext4 defaults,acl 1 1
Then you need to remount or restart
to remount
# mount -o remount /
Without adding entry to fstab(this isn’t permanent)
# mount -o remount -o acl /dev/…
to check acl on a directory or file
use the getfacl command #getfacl file
to add user acl to a file or directory
setfacl -m u:user2:rw install.log m = modify
to add a group acl on a file
setfacl -m g:IT:rwx install.log
to remove all acls on a file
setfacl -b file1 -b for remove all
Note pay attention to “other” users in regard to ACL
#setfacl -m o:rwx file1 gives rwx to other, but you cannot use -x or -b to remobe such a change. The only way to remove this acl is either the follwoing command: #setfacl -m o:www file1 or #chmod o-rwx file1
to remove permissions allowed to the user bob(-x for remove)
setfacl -x u:bob file1
Apply ACL recursively
setfacl -R -m u:user1:rwx file1
The following command cancels ACL settings for a user recursively
setfacl -R -x u:user1 file1
The mask in regard to ACL
The mask associated with ACL limits the permission available on a file. In other words, with a mask of --r, you can try all other privileges, but all that can be set with that mask is read privileges. The command to set the mask: #setfacl -m mask:r-- acltest.txt
To set a default ACL
Add d: before the rule and specify a directory instead of a filename #setfacl -m d:o:rx /share
Man in regard to ACL
review these man pages #man acl #man getfacl #man setfacl #man star the star utility