SlideShare a Scribd company logo
1 of 38
Storage Management
Storage Basic
• Devices
• Partitions
Partitions types :
• Physical
• Extended
• Logical
Components of storage
• Files
• Directories
• File systems
• Logical storage
• Physical storage
• Logical Volume Manager (LVM)
Hard disk partitions
• IDE and SCSI hard disks can be partitioned
• Maximum of four primary partitions
• One primary partition may be an extended partition
• An extended partition can hold an unlimited amount of
logical partitions (Linux: max 59 for IDE, 11 for SCSI)
master boot record
partition table
Windows
Linux /
Linux /home
Linux swap
sda: The first sector of the disk contains the MBR
and Partition Table
sda1: First primary partition holds a Windows
filesystem
sda2: Second primary partition is an extended
partition and holds three logical partitions
sda5: First logical partition holds a Linux
filesystem that will be mounted as /
sda6: Second logical partition holds a Linux
filesystem that will be mounted as /home
sda7: Third logical partition holds a Linux swap
space
Partitioning tools
• fdisk
– Virtually every PC OS comes with a tool fdisk to create
partitions for that OS
• Linux, Windows, and so forth
• parted
– GPLed Linux program, available at www.gnu.org
– Can create/resize/move/delete partitions
• GParted, QTParted
– GUI utilities that use GNU Parted
– Can create/resize/move/delete partitions
• Disk Druid and others
– Partitioning program integrated in Linux install program
Steps for creating and using partitions in Linux
Step 1: Creating a partition
Step 2: Formatting a partition
Step 3: Mounting a partition
fdisk utility
fdisk also known as format disk is a dialog-driven command in Linux
used for creating and manipulating disk partition table. It is used for the
view, create, delete, change, resize, copy and move partitions on a
hard drive using the dialog-driven interface.
fdisk allows you to create a maximum of four primary partitions and the
number of logical partition depends on the size of the hard disk you are
using. It allows the user:
• To Create space for new partitions.
• Organizing space for new drives.
• Re-organizing old drives.
• Copying or Moving data to new disks(partitions).
• Syntax :
# fdisk [options] device
View All Disk Partitions:
# fdisk –l
View Partition on a Specific Disk:
# fdisk –l /dev/sda
• To check either disk is detected or not
# dmesg | grep sd
1. View all Disk Partitions in Linux
The following basic command list all existing disk partition on your system. The
‘-l‘ argument stand for (listing all partitions) is used with fdisk command to view
all available partitions on Linux. The partitions are displayed by their device’s
names. For example: /dev/sda, /dev/sdb or /dev/sdc.
2. View Specific Disk Partition in Linux
• To view all partitions of specific hard disk use the option ‘-l‘ with
device name. For example, the following command will display all
disk partitions of device /dev/sda. If you’ve different device names,
simple write device name as /dev/sdb or /dev/sdc.
3. Check all Available fdisk Commands
• If you would like to view all commands which are available for fdisk. Simply
use the following command by mentioning the hard disk name such as
/dev/sda as shown below. The following command will give you output
similar to below.
• Type ‘m‘ to see the list of all available commands of fdisk
which can be operated on /dev/sda hard disk. After, I
enter ‘m‘ on the screen, you will see the all available
options for fdisk that you can be used on the /dev/sda
device.
4. Print all Partition Table in Linux
• To print all partition table of hard disk, you must be on command mode of
specific hard disk say /dev/sda.
From the command mode, enter ‘p‘ instead of ‘m‘ as we did earlier. As I enter
‘p‘, it will print the specific /dev/sda partition table.
6. Create a New Partition in Linux
• If you’ve free space left on one of your device say /dev/sda and would like
to create a new partition under it. Then you must be in fdisk command mode
of /dev/sda. Type the following command to enter into command mode of
specific hard disk.
After entering in command mode, now press “n” command to create a new
partition under /dev/sda with specific size. This can be demonstrated with
the help of following given output.
While creating a new partition, it will ask you two options ‘extended‘ or
‘primary‘ partition creation. Press ‘e‘ for extended partition and ‘p‘ for primary
partition. Then it will ask you to enter following two inputs.
• First cylinder number of the partition to be create.
• Last cylinder number of the partition to be created (Last cylinder, +cylinders
or +size).
You can enter the size of cylinder by adding “+5000M” in last cylinder. Here, ‘+‘
means addition and 5000M means size of new partition (i.e 5000MB). Please
keep in mind that after creating a new partition, you should run ‘w‘ command to
alter and save new changes to partition table and finally reboot your system to
verify newly created partition.
7. How to Check Size of a Partition in Linux
• By default, fdisk command shows the boot flag (i.e. ‘*‘)
symbol on first partition. If you want to enable or disable
boot flag on a specific partition, do the following steps.
• Press ‘p‘ command to view the current partition table,
you see there is a boot flag (asterisk (*) symbol in
orange color) on /dev/sda1 disk as shown below.
• Next enter command ‘a‘ to disable boot flag, then enter partition
number ‘1‘ as (i.e. /dev/sda1) in my case. This will disable boot flag
on the partition /dev/sda1. This will remove the asterisk (*) flag.
6. Delete a Hard Disk Partition
To delete a partition for the hard disk and free up space occupied by that
partition for example /dev/sdb. Go to the command menu using following:
$ sudo fdisk /dev/sda
and then type d to go to the delete partition menu. It will prompt the partition
number you want to delete(type the number).
Formatting a Partition in Linux
File System in Linux
• Types of file system
• To create an ext file system use :
# mkfs.ext2 /dev/sdb6
# mkfs.ext3 /dev/sdb6
# mkfs.ext4 /dev/sdb6
• To create xfs file system install package xfsprogs:
# yum install xfsprogs
# mkfs.xfs /dev/sdb6
• To create jfs file system install package jfsutils :
# yum install jfsutils
# mkfs.jfs /dev/sdb6
Creating file System on partation
Creating swap partition
• To create and activate swap partition
# mkswap /dev/sdb5
To activate swap partition
# swapon /dev/sdb5
To check swap partition is activated or not :
# dmesg | tail –n 1 or use
# free -m
To tune file system
• Use tune2fs tool
# tune2fs
# tune2fs –l /dev/sdb6
# tune2fs [options] <partition name>
# tune2fs -c 0 –m 0 /dev/sdb6
Mounting a partition:
• Create directory under /mnt directory
#mkdir /mnt/data
• Use mount command to mount partition to a
created directory under /mnt
# mount /dev/sdb6 /mnt/data
• Use following commands to check either
partition is mounted or not
#df
#dmesg
# mount
Unmounting file system
• Use umount command
# umount /mnt/data
• To check whether any links are open use:
# lsof /mnt/data 6
Auto mounting a partation
• For auto mounting make entry into
/etc/fstab file
•
Traditional disk storage
PROBLEMS:
• Fixed partitions
• Expanding size of the partition
• Limitation on size of a file system and a file
• Contiguous data requirement
• Time and effort required in planning ahead
Partition 1
Partition 2
Partition 3
Partition 4
Partition 5
Benefits of the LVM(Logical Volumes Management)
• Logical volumes solve noncontiguous space problems
• Logical volumes can span disks
• Logical volume sizes can be dynamically increased
• Logical volumes can be mirrored
• Physical volumes are easily added to the system
• Logical volumes can be relocated
• Volume group and logical volume statistics can be collected
These tasks can be performed dynamically!
Logical volume management
• Logical volume management solves the disadvantages of
traditional disk storage:
– One or more physical volumes (hard disks, partitions) are assigned to
a volume group (VG)
– All physical volumes (PV) are split into physical extents (PE) of
identical size (default 4 MB)
– PEs in a VG can be combined into logical volumes (LV), which can
be used like any block device
• An LV can span multiple disks
• To increase the size of an LV, add PEs
• To increase the size of a VG, add PVs
Logical volume management on Linux
PE PE PE
PE PE PE
PE PE PE
PE PE PE
PE PE PE
PE PE PE
volume group
physical volume
(hard disk or partition)
physical volume
(hard disk or partition)
logical volume
LVM has three layers :
• Bottom layer : Physical volumes
• Middle layer : Volume group
• Top layer : Logical volume
Commands for Physical Volume & Volume Group:
• For Physical Volume :
# pvcreate
# pvremove
# pvdisplay / pvs
• For Volume Group :
# vgcreate
# vgremove
# vgextend
# vgreduce
#vgdisplay / vgs
1. Creating Groups and Volumes
1. Creating Physical volume :
# pvcreate /dev/sdb6
• To display all the physical volumes created :
# pvs
2. Now create Volume Group :
# vgs - to check available groups
Create new Volume group :
# vgcreate mygrp /dev/sdb6
3. Extend or reduce volume group
# vgextend vg_linuxhost /dev/sdb6
# vgreduce vg_linuxhost /dev/sdb6
2. Creating Logical Volume :
• Commands :
# lvcreate
# lvremove
# lvextend
# lvreduce
# lvdisplay / lvs
• Create new logical volume :
# lvcreate - -name mylv1 - - size 2G mygrp
• Expanding logical volume :
# lvextend - -size +2G /dev/mygrp/mylv1
• Reducing the size :
# lvreduce - - size 2G /dev/mygrp/mylv1
LVM implementation overview
• Add hard disks and/or create partitions (type 0x8e) on existing
hard disks
• Initialize physical volumes (disks or partitions)
# pvcreate /dev/sda3
# pvcreate /dev/sdb
• Create volume group vg00 with physical volumes
# vgcreate vg00 /dev/sda3 /dev/sdb
• Create logical volume lv00 in volume group
# lvcreate -L 50M -n lv00 vg00
• Can now use /dev/vg00/lv00 as block device
Recovering from Failure
• File system and auto recovering tools
• Ext2 ,Ext3, Ext4 -- e2fsck
• XFS File system -- xfs_repair
• JFS File System -- jfs_fsck

More Related Content

What's hot

Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 

What's hot (20)

Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
User management
User managementUser management
User management
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Swap Administration in linux platform
Swap Administration in linux platformSwap Administration in linux platform
Swap Administration in linux platform
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & Commands
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux
LinuxLinux
Linux
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
Linux directory structure by jitu mistry
Linux directory structure by jitu mistryLinux directory structure by jitu mistry
Linux directory structure by jitu mistry
 
Linux
Linux Linux
Linux
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 

Similar to Storage Management in Linux OS.ppt

101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
Acácio Oliveira
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
Acácio Oliveira
 
Chapter06 Managing Disks And Data Storage
Chapter06      Managing  Disks And  Data  StorageChapter06      Managing  Disks And  Data  Storage
Chapter06 Managing Disks And Data Storage
Raja Waseem Akhtar
 
Fedora linux installtion
Fedora linux installtionFedora linux installtion
Fedora linux installtion
Deepa Rani
 

Similar to Storage Management in Linux OS.ppt (20)

Unix Administration 4
Unix Administration 4Unix Administration 4
Unix Administration 4
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
 
logical volume manager.ppt
logical volume manager.pptlogical volume manager.ppt
logical volume manager.ppt
 
3 - Disk Partitioning in Red Hat
3 - Disk Partitioning in Red Hat3 - Disk Partitioning in Red Hat
3 - Disk Partitioning in Red Hat
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
 
CSA-lecture 6.pptx
CSA-lecture 6.pptxCSA-lecture 6.pptx
CSA-lecture 6.pptx
 
Chapter06 Managing Disks And Data Storage
Chapter06      Managing  Disks And  Data  StorageChapter06      Managing  Disks And  Data  Storage
Chapter06 Managing Disks And Data Storage
 
Linux
Linux Linux
Linux
 
Linux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyLinux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of Technology
 
How to mount ntfs in linux
How to mount ntfs in linuxHow to mount ntfs in linux
How to mount ntfs in linux
 
Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)
 
Real time systems
Real time systemsReal time systems
Real time systems
 
HARD DISK PARTITIONING,FORMATING
HARD DISK PARTITIONING,FORMATINGHARD DISK PARTITIONING,FORMATING
HARD DISK PARTITIONING,FORMATING
 
101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2
 
Rh202 q&amp;a-demo-cert magic
Rh202 q&amp;a-demo-cert magicRh202 q&amp;a-demo-cert magic
Rh202 q&amp;a-demo-cert magic
 
Fedora linux installtion
Fedora linux installtionFedora linux installtion
Fedora linux installtion
 
Manage disk
Manage diskManage disk
Manage disk
 
RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)
RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)
RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)
 
FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016
 
Red Hat Training
Red Hat   TrainingRed Hat   Training
Red Hat Training
 

Recently uploaded

Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
pritamlangde
 
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
dannyijwest
 

Recently uploaded (20)

Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdf
 
Post office management system project ..pdf
Post office management system project ..pdfPost office management system project ..pdf
Post office management system project ..pdf
 
Danikor Product Catalog- Screw Feeder.pdf
Danikor Product Catalog- Screw Feeder.pdfDanikor Product Catalog- Screw Feeder.pdf
Danikor Product Catalog- Screw Feeder.pdf
 
Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
Cybercrimes in the Darknet and Their Detections: A Comprehensive Analysis and...
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 

Storage Management in Linux OS.ppt

  • 3. Partitions types : • Physical • Extended • Logical
  • 4. Components of storage • Files • Directories • File systems • Logical storage • Physical storage • Logical Volume Manager (LVM)
  • 5. Hard disk partitions • IDE and SCSI hard disks can be partitioned • Maximum of four primary partitions • One primary partition may be an extended partition • An extended partition can hold an unlimited amount of logical partitions (Linux: max 59 for IDE, 11 for SCSI) master boot record partition table Windows Linux / Linux /home Linux swap sda: The first sector of the disk contains the MBR and Partition Table sda1: First primary partition holds a Windows filesystem sda2: Second primary partition is an extended partition and holds three logical partitions sda5: First logical partition holds a Linux filesystem that will be mounted as / sda6: Second logical partition holds a Linux filesystem that will be mounted as /home sda7: Third logical partition holds a Linux swap space
  • 6. Partitioning tools • fdisk – Virtually every PC OS comes with a tool fdisk to create partitions for that OS • Linux, Windows, and so forth • parted – GPLed Linux program, available at www.gnu.org – Can create/resize/move/delete partitions • GParted, QTParted – GUI utilities that use GNU Parted – Can create/resize/move/delete partitions • Disk Druid and others – Partitioning program integrated in Linux install program
  • 7. Steps for creating and using partitions in Linux Step 1: Creating a partition Step 2: Formatting a partition Step 3: Mounting a partition
  • 8. fdisk utility fdisk also known as format disk is a dialog-driven command in Linux used for creating and manipulating disk partition table. It is used for the view, create, delete, change, resize, copy and move partitions on a hard drive using the dialog-driven interface. fdisk allows you to create a maximum of four primary partitions and the number of logical partition depends on the size of the hard disk you are using. It allows the user: • To Create space for new partitions. • Organizing space for new drives. • Re-organizing old drives. • Copying or Moving data to new disks(partitions).
  • 9. • Syntax : # fdisk [options] device View All Disk Partitions: # fdisk –l View Partition on a Specific Disk: # fdisk –l /dev/sda • To check either disk is detected or not # dmesg | grep sd
  • 10. 1. View all Disk Partitions in Linux The following basic command list all existing disk partition on your system. The ‘-l‘ argument stand for (listing all partitions) is used with fdisk command to view all available partitions on Linux. The partitions are displayed by their device’s names. For example: /dev/sda, /dev/sdb or /dev/sdc.
  • 11. 2. View Specific Disk Partition in Linux • To view all partitions of specific hard disk use the option ‘-l‘ with device name. For example, the following command will display all disk partitions of device /dev/sda. If you’ve different device names, simple write device name as /dev/sdb or /dev/sdc.
  • 12. 3. Check all Available fdisk Commands • If you would like to view all commands which are available for fdisk. Simply use the following command by mentioning the hard disk name such as /dev/sda as shown below. The following command will give you output similar to below.
  • 13. • Type ‘m‘ to see the list of all available commands of fdisk which can be operated on /dev/sda hard disk. After, I enter ‘m‘ on the screen, you will see the all available options for fdisk that you can be used on the /dev/sda device.
  • 14.
  • 15. 4. Print all Partition Table in Linux • To print all partition table of hard disk, you must be on command mode of specific hard disk say /dev/sda. From the command mode, enter ‘p‘ instead of ‘m‘ as we did earlier. As I enter ‘p‘, it will print the specific /dev/sda partition table.
  • 16. 6. Create a New Partition in Linux • If you’ve free space left on one of your device say /dev/sda and would like to create a new partition under it. Then you must be in fdisk command mode of /dev/sda. Type the following command to enter into command mode of specific hard disk. After entering in command mode, now press “n” command to create a new partition under /dev/sda with specific size. This can be demonstrated with the help of following given output.
  • 17. While creating a new partition, it will ask you two options ‘extended‘ or ‘primary‘ partition creation. Press ‘e‘ for extended partition and ‘p‘ for primary partition. Then it will ask you to enter following two inputs. • First cylinder number of the partition to be create. • Last cylinder number of the partition to be created (Last cylinder, +cylinders or +size). You can enter the size of cylinder by adding “+5000M” in last cylinder. Here, ‘+‘ means addition and 5000M means size of new partition (i.e 5000MB). Please keep in mind that after creating a new partition, you should run ‘w‘ command to alter and save new changes to partition table and finally reboot your system to verify newly created partition.
  • 18. 7. How to Check Size of a Partition in Linux • By default, fdisk command shows the boot flag (i.e. ‘*‘) symbol on first partition. If you want to enable or disable boot flag on a specific partition, do the following steps. • Press ‘p‘ command to view the current partition table, you see there is a boot flag (asterisk (*) symbol in orange color) on /dev/sda1 disk as shown below.
  • 19. • Next enter command ‘a‘ to disable boot flag, then enter partition number ‘1‘ as (i.e. /dev/sda1) in my case. This will disable boot flag on the partition /dev/sda1. This will remove the asterisk (*) flag.
  • 20. 6. Delete a Hard Disk Partition To delete a partition for the hard disk and free up space occupied by that partition for example /dev/sdb. Go to the command menu using following: $ sudo fdisk /dev/sda and then type d to go to the delete partition menu. It will prompt the partition number you want to delete(type the number).
  • 22. File System in Linux • Types of file system
  • 23. • To create an ext file system use : # mkfs.ext2 /dev/sdb6 # mkfs.ext3 /dev/sdb6 # mkfs.ext4 /dev/sdb6 • To create xfs file system install package xfsprogs: # yum install xfsprogs # mkfs.xfs /dev/sdb6 • To create jfs file system install package jfsutils : # yum install jfsutils # mkfs.jfs /dev/sdb6 Creating file System on partation
  • 24. Creating swap partition • To create and activate swap partition # mkswap /dev/sdb5 To activate swap partition # swapon /dev/sdb5 To check swap partition is activated or not : # dmesg | tail –n 1 or use # free -m
  • 25. To tune file system • Use tune2fs tool # tune2fs # tune2fs –l /dev/sdb6 # tune2fs [options] <partition name> # tune2fs -c 0 –m 0 /dev/sdb6
  • 26. Mounting a partition: • Create directory under /mnt directory #mkdir /mnt/data • Use mount command to mount partition to a created directory under /mnt # mount /dev/sdb6 /mnt/data • Use following commands to check either partition is mounted or not #df #dmesg # mount
  • 27. Unmounting file system • Use umount command # umount /mnt/data • To check whether any links are open use: # lsof /mnt/data 6
  • 28. Auto mounting a partation • For auto mounting make entry into /etc/fstab file •
  • 29. Traditional disk storage PROBLEMS: • Fixed partitions • Expanding size of the partition • Limitation on size of a file system and a file • Contiguous data requirement • Time and effort required in planning ahead Partition 1 Partition 2 Partition 3 Partition 4 Partition 5
  • 30. Benefits of the LVM(Logical Volumes Management) • Logical volumes solve noncontiguous space problems • Logical volumes can span disks • Logical volume sizes can be dynamically increased • Logical volumes can be mirrored • Physical volumes are easily added to the system • Logical volumes can be relocated • Volume group and logical volume statistics can be collected These tasks can be performed dynamically!
  • 31. Logical volume management • Logical volume management solves the disadvantages of traditional disk storage: – One or more physical volumes (hard disks, partitions) are assigned to a volume group (VG) – All physical volumes (PV) are split into physical extents (PE) of identical size (default 4 MB) – PEs in a VG can be combined into logical volumes (LV), which can be used like any block device • An LV can span multiple disks • To increase the size of an LV, add PEs • To increase the size of a VG, add PVs
  • 32. Logical volume management on Linux PE PE PE PE PE PE PE PE PE PE PE PE PE PE PE PE PE PE volume group physical volume (hard disk or partition) physical volume (hard disk or partition) logical volume
  • 33. LVM has three layers : • Bottom layer : Physical volumes • Middle layer : Volume group • Top layer : Logical volume
  • 34. Commands for Physical Volume & Volume Group: • For Physical Volume : # pvcreate # pvremove # pvdisplay / pvs • For Volume Group : # vgcreate # vgremove # vgextend # vgreduce #vgdisplay / vgs
  • 35. 1. Creating Groups and Volumes 1. Creating Physical volume : # pvcreate /dev/sdb6 • To display all the physical volumes created : # pvs 2. Now create Volume Group : # vgs - to check available groups Create new Volume group : # vgcreate mygrp /dev/sdb6 3. Extend or reduce volume group # vgextend vg_linuxhost /dev/sdb6 # vgreduce vg_linuxhost /dev/sdb6
  • 36. 2. Creating Logical Volume : • Commands : # lvcreate # lvremove # lvextend # lvreduce # lvdisplay / lvs • Create new logical volume : # lvcreate - -name mylv1 - - size 2G mygrp • Expanding logical volume : # lvextend - -size +2G /dev/mygrp/mylv1 • Reducing the size : # lvreduce - - size 2G /dev/mygrp/mylv1
  • 37. LVM implementation overview • Add hard disks and/or create partitions (type 0x8e) on existing hard disks • Initialize physical volumes (disks or partitions) # pvcreate /dev/sda3 # pvcreate /dev/sdb • Create volume group vg00 with physical volumes # vgcreate vg00 /dev/sda3 /dev/sdb • Create logical volume lv00 in volume group # lvcreate -L 50M -n lv00 vg00 • Can now use /dev/vg00/lv00 as block device
  • 38. Recovering from Failure • File system and auto recovering tools • Ext2 ,Ext3, Ext4 -- e2fsck • XFS File system -- xfs_repair • JFS File System -- jfs_fsck