0% found this document useful (0 votes)
12 views8 pages

Day7 Partition 2 LVM

The document provides commands for viewing and managing disk information, including checking free space, assigning labels, and creating swap partitions. It also details the Logical Volume Manager (LVM) for managing disk space through logical volumes and includes commands for creating, resizing, and removing logical volumes. Additionally, it covers mounting partitions and removable devices, as well as configuring the fstab file for permanent mounts.

Uploaded by

Douglas Kamga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Day7 Partition 2 LVM

The document provides commands for viewing and managing disk information, including checking free space, assigning labels, and creating swap partitions. It also details the Logical Volume Manager (LVM) for managing disk space through logical volumes and includes commands for creating, resizing, and removing logical volumes. Additionally, it covers mounting partitions and removable devices, as well as configuring the fstab file for permanent mounts.

Uploaded by

Douglas Kamga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

View Disk Information

To view available free space of a disk


[root@comp1 ~]# hwbrowser &

To view the free space in a partition


[root@comp1 ~]# df -h

To view the total amount of used space in a partition / directory


[root@comp1 ~]# du -sh

View Disk Information

To know the block size of a partition


[root@comp1 ~]# blockdev --getbsz <partition>
Label

To assign a label to a partition


[root@comp1 ~]# e2label <partition> <label name>

To view the existing labels


[root@comp1 ~]# e2label <partition>

To see a mounted partition with its label


[root@comp1 ~]# mount -l

How Swap Works

Process D

Process C Swap Partition

Process B hda3

Process A hda2

Operating hda1
System

RAM Hard Disk

Creating a Swap Partition

Create a new partition


[root@comp1 ~]# fdisk <device>

Format the partition as swap


[root@comp1 ~]# mkswap <partition>

Turn on swap
[root@comp1 ~]# swapon <partition>
Swap Partition

Check the status of swap used


[root@comp1 ~]# swapon -s <partition>

Turn off swap


[root@comp1 ~]# swapoff <partition>

Mounting a Partition Permanently

To mount a partition permanently


[root@comp1 ~]# vi /etc/fstab

Disk Management

# This file is edited by fstab-sync - see 'man fstab-sync' for details


LABEL=/1 / ext3 defaults 00
/dev/hda1 /boot ext3 defaults 12
LABEL=/home1 /home ext3 defaults 00
none /proc proc defaults 00
none /sys sysfs defaults 00
/dev/hda2 /usr ext3 defaults 00
LABEL=/var1 /var ext3 defaults 12
LABEL=SWAP-hda7 swap swap defaults 00
/dev/hdd /media/cdrom auto pamconsole,noauto,managed 00

/dev/hda10 /mnt ext3 defaults 00


Mounting Removable Devices

To mount cdrom drive


[root@comp1 ~]# mount /dev/cdrom /mnt

To mount a pen drive


[root@comp1 ~]# mount /dev/sda1 /mnt

Logical Volume Manager (LVM)

• LVM is a method of allocating hard drive space into logical volumes


that can be easily resized.

• With LVM, the hard drive or set of hard drives is allocated to one or
more physical volumes.

• The physical volumes are then combined into volume groups.

• Each volume group is divided into logical volumes, which are


formatted with a file system like ext3 and are then mounted.
Logical Volumes

Physical Physical Physical


Volume Volume Volume
9 GB 9 GB 9 GB

Volume Group
9+9+9 = 27 GB

Logical Volumes

Physical Physical Physical


Volume Volume Volume
9 GB 9 GB 9 GB

Volume Group
9+9+9 = 27 GB

Logical Volumes

Logical Logical Logical


Volume Volume Volume
/home / Free Space
20 GB 2 GB 5 GB

Volume Group
9+9+9 = 27 GB
Creating Partitions

Make multiple partitions


[root@comp1 ~]# fdisk <device>

Update the partition table


[root@comp1 ~]# partprobe <device>

Physical Volume

Create a physical volume from the previously created partitions


[root@comp1 ~]# pvcreate <partition1> <partition2>
<partition3>

To see the physical volume details


[root@comp1 ~]# pvdisplay |less

Volume Group

Create a volume group


[root@comp1 ~]# vgcreate <volume group name> <physical
volume1> <physical volume 2>

To see the volume group details


[root@comp1 ~]# vgdisplay <volume group name>
Logical Volume

Create logical volume


[root@comp1 ~]# lvcreate -L <size> <volume group name> –n
<volume name>

Format the logical volume


[root@comp1 ~]# mkfs.ext3 <volume name>

Logical Volume

Create a mount point


[root@comp1 ~]# mkdir <directory name>

Mounting a logical volume


[root@comp1 ~]# mount <volume name> <mount point>

Logical Volume

Resizing a logical volume


[root@comp1 ~]# lvresize -L <+sizeM> <logical volume
name>

To update the resized logical volume


[root@comp1 ~]# resize2fs <logical volume name>

Removing logical volume


[root@comp1 ~]# lvremove <logical volume name>
Logical Volume

Extending the size of a volume group


[root@comp1 ~]# vgextend <volume group name> <physical
volume name>

You might also like