Configure Local Storage Flashcards Preview

Rhcsa > Configure Local Storage > Flashcards

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

/dev

All system devices are located in /dev

2

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

3

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

4

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

5

Example of a swap partition with 2GB

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

6

To set the first partition as bootable in parted

(parted) set 1 boot on

type set 1 boot off to remove the bootable flag

7

parted remove a partition

(parted) rm 2

8

LVM

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)

9

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:
#pvdisplay

- 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

10

To grow a logical volume

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

11

to shrink the logical volume

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

12

to remove a volume from a volume group

# pvremove /dev/sdb1

13

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

# vgextend myvolgroup /dev/sdc

14

to assign a new physical volume to an existing volume

# vgextend myvolgroup /dev/sdd

15

to remove a physical volume from a volume group

#vgreduce myVolGroup /dev/sdc

16

to delete logical volumes

#lvremove /dev/myVolGroup/vol0

17

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

# lvmdiskscan

18

pvscan command

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

19

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

20

to resize a physical volume

you should use the pvresize command

21

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

# vgchange -l 128 /dev/vg00

22

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

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

23

To remove a volume group that contains no logical volumes

# vgremove officeVG

24

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

25

to combine volume groups

# vgmerge -v databases my-vs

26

renaming an existing volume group vg02 to my_volume_group

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

27

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

28

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

29

to create a mirror volume

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

30

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