Skip to main content

Partitions and file system creation in Linux

 


Storage:


types of storages:


• Local Storage.


• SAN (storage area network)


• NAS (network attached storage)



***************************************


Commands for disk partitions:


df: lists the filesystems and its info


fdisk: lists the disks and the partitions on the disks


***************************************


Adding the disk and creating the partitions and creating filesystem from partition and mounting it on the directory:


fdisk /dev/sdb: It will open the fdisk program.

n: create new partition

pick the partition number: 1 first sector: default 2048

Last sector: +1G (creating the partition of 1G)

partition 1 of type Linux of size 1Gb is set.

w: write the table to disk and exit.

fdisk  -l: it will now show the /dev/sdb1 partition created on the /dev/sdb disk,

mkfs.xfs /dev/sdb1: make the xfs filsystem for /dev/sdb1 partition

mkdir /data: create data directory

mount /dev/sdb1  /data: mount filesystem /dev/sdb1 on data directory.

df  -h: outputs the filesystems where we can see /dev/sdb1 filesystem mounted on /data.

write the below line to /etc/fstab so that /dev/sdb1 should mount automatically on /data after the reboot. 

/dev/sdb1   /data    xfs     defaults   0 0


umount  /data: unmount /data


mount  -a: mount all the filesystems mentioned in fstab file

*************************************

LVM:



fdisk /dev/sdc: It will open the fdisk program.

n: create new partition

pick the partition number: 1 first sector: default 2048

Last sector: +1G (creating the partition of 1G)

partition 1 of type Linux of size 1Gb is set.


t: change partition type

8e: change partition type to linux lvm

w: write the table to disk and exit.


fdisk  -l: it will now show the /dev/sdc1 partition created on the /dev/sdc disk.


pvcreate  /dev/sdc1: physical volume create.


pvs :shows the physical volumes info.


vgcreate  oraclevg  /dev/sdc1: creating volume group named oraclevg from physical volume /dev/sdc1.


vgs: gives the list of the volume groups.


lvcreate  -n oraclelv  --size 1G  oraclevg: creating oraclelv logical volume of 1gb from oraclevg volume group


lvs :gives the list of the logical volumes


lvdisplay: display the logical volume info also displays the Ivpath info


mkfs.xfs  /dev/oraclevg/oraclelv : creates the xfs filesystem where /dev/oraclevg/oraclelv is the Ivpath


mkdir   /oracle: create oracle directory

mount   /dev/oraclevg/oraclelv   /oracle: mount filesystem on the oracle directory


*********************************


Adding and extending the disk using the LVM:


lets add the new disk  /dev/sdd of 1GB and lets extend  /oracle filesystem which is created above.


fdisk /dev/sdd: It will open the fdisk program.


n: create new partition

p: primary partition

pick the partition number: 1

first sector: default 2048

Last sector: +1G (creating the partition of 16)

partition 1 of type Linux of size 1Gb is set.


t: change partition type

8e: change partition type to linux ivm

w: write the table to disk and exit


fdisk -l  : it will now show the /dev/sdd1 partition created on the /dev/sdd disk

pvcreate  /dev/sdd1: physical volume create

pvs: shows the physical volumes info

vgextend oraclevg  /dev/sdd1: extending the oraclevg volume group by the size of /dev/sdd1 physical volume.

Ivextend  -L  +1G  /dev/oraclevg/oraclelv  : extends the oraclelv logical volume because oraclevg volume group was extended

xfs_growfs  /dev/oraclevg/oraclelv : grow your filesystem


************************************


Implementing advance storage features:


Redhat 8 introduces the next generation volume management solution called Stratis.It uses thin

provisioning by default. It combines the process of creating logical volume management (LVM) and creation of filesystems into one management.


In LVM if the filesystem gets full you will have to extend it manually whereas stratis extends the filesystem automatically if it has available space in its pool.


•Install the stratis

yum/dnf  install  stratis-cli stratisd


• Enable and start stratis service.

systemctl enable/start stratisd


• Add 2 5gb disks and verfiy from OS level:

 lsblk (sdb and sdc) 



•creating the pool: 

stratis pool create pool1 /dev/sdb



•verify the pool has been created:

stratis pool list


•create a new filesystem using stratis: 

stratis filesystem create pool1 fs1


• verify fs1 filesystem created: 

stratis filesystem list


•create the directory: 

mkdir /bigdata


•mount the fs1 filesystem on bigdata directory: mount  /dev/stratis/pool1/fs1  /bigdata


• check if the filesystem has been created : 

lsblk and df -hT


•take the snapshot of your filesystem: 

stratis filesystem snapshot pool1   fs1  fs1-snap



•list the stratis filesystem:

stratis filesystem list : it will list 2 filesystems. fs1 and fs1-snap.



•Add the entry to /etc/fstab to mount at boot:

UUID="asf-0887afgdja-"   /bigdata   xfs   defaults, x-systemd.requires=stratisd.service   0  0


Comments

Popular posts from this blog

Linux basic commands

 Linux basic commands: du  -sh  *  |  sort  -h  -r   |  head  -n  40  :    list out first 40 files in the directory that are taking more space in the directory.  cd : change directory Is-l listing the items in long listing format  pwd : print working directory Is-I format: type :no of links:owner : group:size :month :day :time :name cd/: go to/directory whoami: tells us by which username we are logged in. touch jerry: creates the file named jerry in present working directory. cp jerry lex: copy the content of jerry file and paste it to lex file. vi text1: creates the file text1 and open it in vi editor mkdir superman: creates the directory called superman mkdir abc def  : creates 2 folder in one command. touch filename wont work in /etc/ folder if logged in by normal account. man cp: shows manual for cp command. echo "india is my country"> file1 puts the text in file1. rm filename: remove the filename  mv lex luther renames the file from lex to luther  mv luther /h

patching tasks

 Patching a Linux system is a critical task to ensure that the system remains secure, stable, and up-to-date with the latest features and fixes. Here’s a comprehensive guide to the tasks involved in Linux patching: 1. Pre-Patching Preparation Backup System : Ensure you have a full system backup, including critical data, configuration files, and applications. Test the backup to verify its integrity. Check Disk Space : Verify that you have enough disk space, particularly on /var , /tmp , and /boot partitions. Review Current Patch Level : Determine the current patch level and installed packages using package management tools like yum , apt , dpkg , or rpm . Check System Logs : Review system logs to identify any issues that might affect the patching process. Test in a Staging Environment : If possible, apply patches in a staging environment that mirrors production to identify potential issues. Notify Stakeholders : Inform stakeholders about the scheduled maintenance window and expected do