rh135-day13.pdf

(242 KB) Pobierz
rh135-day13
Written by Razib Shahriar Rubence
Managing Swap Space and partition:
01. Creating a partition of swap space is like creating simple partition except declaring swap
partition type "82" when we use fdisk utility. This can be done by pressing "t" and then "82" for
that partition
02. Unlike Formating the simple partition we need to write special signature on partition using
mkswap
# mkswap /dev/sda12
03. Adding appropriate entry in fstab should be done before activating swap space. the entry
should be like this
UUID="The UUID of swap partition which can be found by blkid command"    swap     swap 
defaults   0  0
04. Activating the swap space with "swapon -a"  . check the swap space with "swapon -s
 
Practice LAB:
Check the current swap areas:
# swapon -s
Creating a Partition for Swap Space
# fdisk -cu /dev/sda
1/9
rh135-day13
Written by Razib Shahriar Rubence
Some questions will be asked after this command. Do the followings:
# p --> print the current partition table
# n --> Create a new partition
# l --> for logical partition
# First Sector --> will be default Sector Number
# Last Sector --> +1GB (This will create a 1 GB Partition)
# p --> print and check the newly created partition (say new partition=sda12)
# t --> for changing the system type to Linux swap / solaris
# Partition Number: 12
# Hex Code: 82
# w --> For write and quit fdisk
2/9
rh135-day13
Written by Razib Shahriar Rubence
Now aware the kernel about new partition
# partprobe /dev/sda
Check kernel is aware about the new partition
# cat /proc/partitions
Initialize the swap partition
# mkswap /dev/sda12
Entry in fstab to identify swap partition
# vim /etc/fstab
/dev/sda12 swap swap defaults 0 0
Alternatively, you can use the UUID instead of partition name in swap space (recommended)
# blkid  (to identify the UUID)
# vim /etc/stab
3/9
rh135-day13
Written by Razib Shahriar Rubence
UUID="UUID for swap partition found from blkid command"       swap     swap   0  0
Active the swap partition
# swapon -a
Check the swap partitions
# swapon -s
 
Implement LVM Storage with Command-line tools:
In Module 01 (RH124) we've learned about LVM implementation in graphical mode. Now we'll
learn how to do this with command line tools.
What is Logical Volume Manager (LVM):
LVM creates a higher-level layer of abstraction that traditional Linux disks and partitions. This
allows for great flexibility in allocating storage. Logical volumes can be resized and moved
between physical devices easily. Physical devices can be added and removed with relative
ease. LVM managed volumes can also have sensible names linke "database" or "home" rather
than the somewhat cryptic "sda" or "hda" device names.
Steps for creating Logical volume:
4/9
rh135-day13
Written by Razib Shahriar Rubence
01. Create new partition. Declare this partition type "8e" when we use fdisk utility. This can be
done by pressing "t" and then "8e" for the patition.
02. Device are designated as Physical Volumes
# pvcreate /dev/sda11
03. One or more physical volumes are used to create volume group
# vgcreate vg0 /dev/sda11
04. Logical Volumes are created on Volume Groups and composed of Physical Extents
# lvcreate -L 256M -n data vg0
05. Filesystem may be created on Logical Volumes (format the logical volume)
# mkfs.ext4 /dev/vg0/data
06. Mounting the logical volume:
Logical volume need to mount to be in use. Mounting is as usal
# mount /logicalvolume /dev/vg0/data
07. Entry in fstab
Fstab entry can be done either by name "/dev/vg0/data"  or by UUID . the UUID can be found
by blkid command
# vim /etc/fstab
/dev/vg0/data      /logicalvolume    ext4   defaults   0
Practice LAB for creating a new Logical Volume
# fdisk -cu /dev/sda
5/9
Zgłoś jeśli naruszono regulamin