Difference between revisions of "Format And Mount local2"

From DISI
Jump to navigation Jump to search
Line 12: Line 12:
  
  
== Mount Local2 using LVM ==
+
== Mount storage disks using LVM ==
 
Reference guide: '''https://www.thegeekdiary.com/redhat-centos-a-beginners-guide-to-lvm-logical-volume-manager/'''
 
Reference guide: '''https://www.thegeekdiary.com/redhat-centos-a-beginners-guide-to-lvm-logical-volume-manager/'''
* pvcreate /dev/sdb1
+
 
* vgcreate zinc /dev/sdb1
+
'''Scan devices to be used as physical volumes (PV)'''
* lvcreate -l 100%FREE -n zinc_lv zinc
+
* lvmdiskscan
* mkfs.ext4 -L zinc /dev/mapper/zinc-zinc_lv
+
 
* mkdir /local2
+
'''Initialize the block devices'''
 +
* pvcreate <drive1> <drive2> <...> ...
 +
** Example: pvcreate /dev/sdb /dev/sdc /dev/sdd
 +
 
 +
'''To double check PV'''
 +
* pvdisplay
 +
* pvscan
 +
* pvs
 +
 
 +
'''After PV, create a Volume Group (VG)'''
 +
* vgcreate <name of volume> <drive1> <drive2> <...> ...
 +
** Example: vgcreate soft2 /dev/sdb /dev/sdc /dev/sdd
 +
 
 +
'''To double check VG'''
 +
* vgs <VG name>
 +
* vgdisplay <VG name>
 +
 
 +
''' After VG, create a Logical Volume (LV) '''
 +
* lvcreate <options> <name of LV> <VG Name>
 +
** Example: lvcreate -l 100%FREE -n soft_lv soft2
 +
***-l is for storage space in percent, 100%FREE means use all space in VG
 +
***-n is for name of LV
 +
 
 +
''' Double Check LV '''
 +
* lvs /dev/<VG NAME>/<LV NAME>
 +
* lvdisplay /dev/<VG NAME>/<LV NAME>
 +
* lvscan
 +
 
 +
'''Last step, create a File System'''
 +
* mkfs.ext4 <options> /dev/<VG NAME>/<LV NAME>
 +
* Example: mkfs.ext4 /dev/soft2/soft_lv
 +
 
 +
''' It's time to mount '''
 +
Make the directory first:
 +
* mkdir <somewhere>
 +
** Example: mkdir /export/soft2
 +
* mount /dev/<VG NAME>/<LV NAME> <somewhere>
 +
** Example: mount /dev/soft2/soft_lv /export/soft2/
 +
Make it permanent by editing fstab:
 
* vim /etc/fstab
 
* vim /etc/fstab
** /dev/zinc/zinc_lv /local2 ext4 defaults 1 2
+
/dev/<VG NAME>/<LV NAME>      <somewhere>      <type of file system>      <mount options>      <dump>        <fsck>
* mount /local2
+
example:
 +
/dev/soft2/soft_lv /export/soft2 ext4 defaults 1 2
  
 
== Partition Disk ==
 
== Partition Disk ==
 
* https://www.techotopia.com/index.php/Adding_a_New_Disk_Drive_to_a_CentOS_System
 
* https://www.techotopia.com/index.php/Adding_a_New_Disk_Drive_to_a_CentOS_System

Revision as of 21:38, 5 March 2021

Format Disk

Do these commands as root:

  • fdisk -l
    • Find disks/RAID disks to format
  • parted
  • print
  • mklabel gpt
  • mkpart logical 0GB 9995GB. (based on what we read in result of print above)
  • print. (to confirm)
  • quit


Mount storage disks using LVM

Reference guide: https://www.thegeekdiary.com/redhat-centos-a-beginners-guide-to-lvm-logical-volume-manager/

Scan devices to be used as physical volumes (PV)

  • lvmdiskscan

Initialize the block devices

  • pvcreate <drive1> <drive2> <...> ...
    • Example: pvcreate /dev/sdb /dev/sdc /dev/sdd

To double check PV

  • pvdisplay
  • pvscan
  • pvs

After PV, create a Volume Group (VG)

  • vgcreate <name of volume> <drive1> <drive2> <...> ...
    • Example: vgcreate soft2 /dev/sdb /dev/sdc /dev/sdd

To double check VG

  • vgs <VG name>
  • vgdisplay <VG name>

After VG, create a Logical Volume (LV)

  • lvcreate <options> <name of LV> <VG Name>
    • Example: lvcreate -l 100%FREE -n soft_lv soft2
      • -l is for storage space in percent, 100%FREE means use all space in VG
      • -n is for name of LV

Double Check LV

  • lvs /dev/<VG NAME>/<LV NAME>
  • lvdisplay /dev/<VG NAME>/<LV NAME>
  • lvscan

Last step, create a File System

  • mkfs.ext4 <options> /dev/<VG NAME>/<LV NAME>
  • Example: mkfs.ext4 /dev/soft2/soft_lv

It's time to mount Make the directory first:

  • mkdir <somewhere>
    • Example: mkdir /export/soft2
  • mount /dev/<VG NAME>/<LV NAME> <somewhere>
    • Example: mount /dev/soft2/soft_lv /export/soft2/

Make it permanent by editing fstab:

  • vim /etc/fstab
/dev/<VG NAME>/<LV NAME>      <somewhere>       <type of file system>      <mount options>      <dump>         <fsck>
example:
/dev/soft2/soft_lv	/export/soft2	ext4	defaults	1	2

Partition Disk