Configure Local Storage Flashcards Preview

Rhcsa > Configure Local Storage > Flashcards

Flashcards in Configure Local Storage Deck (44)
Loading flashcards...


All system devices are located in /dev


To create a new partition using fdisk

# fdisk /dev/sdb
- use m -> for help
- use p -> to print
- use n -> to create a partition
- use L -> to view different file system we can use
- use w -> to write changes


partprobe command

If you don't see the partition that was just created, you can reboot the system or use the partprobe command
# partprobe
Which tells the kernel to re-read all partition


Parted command

# parted
(parted) print all or type # parted -l
(parted) select /dev/sdb
(parted) mktable gpt create a gpt partition tables

- to create a primary partition with the ext4 type(from 1 mb to 400GB)
(parted) mkpart primary ext4 1MB 400GB
(parted) rm 2 remove a partition
- to use all the remaining space, use -1 as end position

- If at a later stage, after creating a partition, you want to change the type of partition, don't drop and recreate the partition. Format the partition as you want and parted will normally detect the new type


Example of a swap partition with 2GB

(parted) mkpart primary linux-swap 400GB 402GB


To set the first partition as bootable in parted

(parted) set 1 boot on

type set 1 boot off to remove the bootable flag


parted remove a partition

(parted) rm 2



Logical Volume Manager. It is the default volume management system
- Uses a collection of disks
- a single volue can span multiple disks
- not all disks need to be the same size
- each disk is referred to as a 'Physical Volume' (PV)
- physical volumes are collected in to 'volume groups' (VG)
- A volume group is split into 'logical volumes' (LV)
- logical volumes contain the file systems
- LVM allows for online resizing, reduces system downtime
- PV's and LV's are broken up into chunks of data, called extents
- Logical volumes can be grown or shrunk by either increasing or decreasing the extents used, or by increasing or decreasing the amount of disk space used (MG, GB, etc)
- LVM provides the ability to create volume backups through snapshots(no need for filesystem downtime)
- the /boot partition cannot be on a logical volume, grub cannot real LVM volumes
- Volume groups are located at /dev/mapper command line and GUI tools (System-config-lvm)


Creating Logical volume

First step is to convert any disk or partition into physical volumes
# fdisk /dev/sdb
- press the t key to change the partition's type, then press enter
command(m for help): t
- next type (L) to view the different hex code, then press enter
command(m for help): L
- The one for LVM is 8e, so enter 8e and press enter
hex code(type L to list codes): 8e
-type w to save
command (m for help): w

-step 2 create a physical volume:
# pvcreate /dev/sdb1
- to check on the physical volume:
# pvs
- to view more details:

- step 3 lump volumes into a volume group
# vgcreate vg_new /dev/sdb1 /dev/sdc1
- to check on the volume group
# vgs
# vgdisplay

- step 4 create logical volume
# lvcreate -L 800M -n lv_new vg_new
- to verify
# lvs


To grow a logical volume

#lvresize -L 900 MB /dev/vg_new/lv_new


to shrink the logical volume

# resize2fs /dev/vg_new/lv_new 800MB
# lvresize -L 800MB /dev/vg_new/lv_new


to remove a volume from a volume group

# pvremove /dev/sdb1


if the volume doesn't exist, you can create it and add physical volumes in one shot

# vgextend myvolgroup /dev/sdc


to assign a new physical volume to an existing volume

# vgextend myvolgroup /dev/sdd


to remove a physical volume from a volume group

#vgreduce myVolGroup /dev/sdc


to delete logical volumes

#lvremove /dev/myVolGroup/vol0


you can scan for block devices that can be used as physical volumes

# lvmdiskscan


pvscan command

scans all supported LVM block devices in the system for physical volumes. It shows all physical devices found


The following command disallows the allocation of physical extents on /dev/sdc1

# pvchange -x n /dev/sdc1
you can use the -xy arguments of the pvchange command to allow allocation where it had previously been disallowed


to resize a physical volume

you should use the pvresize command


To change the maximum number of logical volumes of volume group vg00 to 128

# vgchange -l 128 /dev/vg00


The following will deactivate the volume group my-volume-group

# vgchange -a n my-volume-group volume group are activated by default


To remove a volume group that contains no logical volumes

# vgremove officeVG


to split the physical volumes of a volume group and create a new volume group

use vgsplit command. Logical volumes cannot be split between volume groups
# vgsplit bigvg smallvg /dev/ram15


to combine volume groups

# vgmerge -v databases my-vs


renaming an existing volume group vg02 to my_volume_group

# vgrename /dev/vg02 /dev/my_volume_group
# vgrename vg02 my_volume_group


Creating a striped logical volume across 2 physical volumes with a stripe of 64 KB

# lvcreate -L 50G -i2 -I64 -n gfslv vg0 gfslv is the name of LV, while vg0 is the name of the VG


An example where the stripe will use sectors 0-50 of /dev/sda1 and sectors 50-100 of /dev/sdb1

#lvcreate -l 100 -i2 -nstripelv testvg /dev/sda1:0-50 /dev/sdb1:50-100


to create a mirror volume

# lvcreate -L 50G -ml -n mirrorlv vg0


steps to create a snapshot of a logical volume

# mkdir /mnt snapshot directory to mount the snapshot
# lvcreate -L 100M -s -n lvmsnapshot /dev/vg-new/lv-new creates the snapshot
# lvs to view the snapshot created
to restore data from a snapshot, you need to first mount it
# mount -t ext4 /dev/vg-new/lvsnapshot /mnt/snapshot
Then you can copy the data back rom /mnt/snapshot