Disk Partitioning
Disk Partitioning
3 – DISK
PARTITIO
1
NING
BASIC PARTITIONING
Working with disks is an important part of maintaining storage
space
Partitions determine how your storage space is carved out for
use later by the system and its users.
2
BASIC PARTITIONING
The /proc file system is created by the kernel when the system boots and
holds current information about the system.
To view information about the current partition layout, use the following
command:
# cat /proc/partitions | grep sd
The first two letters represent whether the disk is a SCSI (sd) or
IDE (hd) disk.
The third letter represents which disk it actually is.
If there is a number after the three letters, it is the number of
the partition.
3
FDISK COMMAND
Syntax: fdisk [options] [device]
Options
-b Specifies the sector size of the disk
-h Specifies the number of heads on the disk
-l Lists current partition tables
4
PARTED COMMANDS
Syntax: parted [options] [device [command]]
Options
-l Lists all partition tables detected
-s Never prompts for interaction (useful for scripting)
5
CREATING A PARTITION
Step 1. Choose the disk:
# fdisk /dev/sdb
Step 2. View all the options available to you:
Command (m for help): m
6
CREATING A PARTITION
Step 4: Create a new partition:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default
1044): +4294M
7
CREATING SECOND
PARTITION
Step 5: Create a new partition:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default
1044): +4294M
8
CREATING A PARTITION
Step 6. Verify your newly created partitions:
Command (m for help): p
9
INFORMATION TO KERNEL
To make sure that it recognizes all disks and partitions correctly.
To do this, you use the partprobe command.
Syntax: partprobe [OPTIONS] [DEVICE]
Options:
-d Does not actually inform the operating system
-s Prints a summary of contents
Step 8. Call the partprobe command:
# partprobe /dev/sdb
This command has no output to it.
Step 9. Verify the partition creation one last time:
# fdisk -l
10
PARTED COMMAND
Step 1. Start the parted utility the same way you used fdisk:
# parted /dev/sdc
13
LVM COMMANDS
pvs Displays physical volumes
vgs Displays volume groups
lvs Displays logical volumes
pvdisplay Displays detailed information on physical volumes
vgdisplay Displays detailed information on volume groups
lvdisplay Displays detailed information on logical volumes
pvcreate Creates a new physical volume
vgcreate Creates a new volume group
lvcreate Creates a new logical volume
vgextend Extends an existing volume group
14
LVM COMMANDS
lvextend Extends a logical volume
lvresize Resizes a logical volume
lvreduce Reduces a logical volume
lvrename Renames a logical volume
pvmove Moves/migrates data from one physical volume to
another
vgreduce Reduces a volume group
pvremove Removes a physical volume
vgremove Removes a volume group
lvremove Removes a logical volume
15
LVM INSTALLATION
Step 1. Install the required packages:
# yum install -y lvm2
lvm2-libs-2.02.72-8.el6.x86_64
lvm2-2.02.72-8.el6.x86_64
16
LVM LAYERS
/etc/lvm (directory)
contains all the information about each layer of the LVM
structure
Physical extents
Dealing with volume groups
Logical extents
Dealing with logical volumes. The logical
extents always map back to a physical extent
17
CREATING AN LVM
PARTITION
Step 1. To initialize the disk, use the pvcreate command:
# pvcreate /dev/sdb
18
Badblock -ws /dev/sda
MBR
GPT (GUI Partition Tabel ) up to 128 partition
partprob command
Cat proc/partition
19