Storage Management
Learn how to manage storage in RHEL 8.
Last updated
Was this helpful?
Learn how to manage storage in RHEL 8.
Last updated
Was this helpful?
Not going deeply in this lesson. Before starting, make sure to read about MBR ''Master Boot Record" and GPT "GUID Partition Table". Lets go... 1- List of disk device types : -> /dev/sda -> KVM disk device type <----> /dev/nvme0n1 -> SSD device type -> /dev/hda -> IDE disk device type <----> /dev/xvda -> Xen virtual disk driver. 2- How to create a backup for a disk -> dd if=/dev/<device> of=/root/diskfile bs=1M count=1 3-Difference between MBR and GPT : -> MBR : Can't create more than 4 partition, can't partition the disk with +'2TB. -> GPT : +128 partition, can partition the disk +8ZB -> parted -l : To know which one your OS uses. (msdos is MBR). 4-List of storage units :
There is many different ways to create a partition, either using fdisk, gdisk or parted. First you'll need to list all the blocks to know which device is avaible using "lsblk" Lets start using fdisk utility.
to create a partition using fdisk follow my steps : -> fdisk /dev/sda 2- m : to list all the commands 3- n : to create new partition 4- primary : to make it a primary partition, 5- PRESS ENTER to set the first sector 6- specify the partition size, exp +500M 7- p to print the table. 8- w to save. 9- partprobe to informe the kernel that a new device partition is added.
Lets create a partition using gdisk : -> gdisk /dev/sdb 2- ? : to list all the commands 3- n : to create new partition 4-PRESS ENTER : to leave the first sector by default 5- Specify the disk partition size, if you leave it empty the whole disk will partitioned. exp : +500M 6- PRESS ENTER : to leave the partition type at Linux file system. 7- P : to print the partition table. 8- w to save. 9- use partprobe - partx to tell the kernel new partition is added.
You can create a partition using parted, parted support mbr and gtp.
-> parted /dev/sdc
2- mklabel (gpt/msdos)
3- mkpart
3-1 primary
3-2 filesystemtype (xfs-ext4-ext3..)
3-3 starting from : 1MiB --- Assuming we have already a partition with 154MiB, then you will need to start from 155MiB.
3-4 ends in : 257 MiB.
4- set
4-1 Partition Number : 1
4-2 flag to invert : to set the partition type.
4-3 New state? on
5-quit.
You don't know what is file system? A filesystem in this context is a way of arranging, or rather, a system of arranging files on a drive. Just as books can be arranged in a shelve horizontally or vertically, a filesystem is also a system files can be arranged on a device. xfs is the default file system for rhel8, pervious versions, ext(2,3,4) were the default one.
fsck -N <partition> to know the file system of a particular partition. mkfs.<type> /dev/<devicename> to create a file system for a partition. example : mkfs.xfs /dev/sda
⦁ ext: Tune2fs -l /dev/sdx -> showing filesystem properties. Tune2fs -o acl,user_xattr | tune2fs -o ^acl,user_xattr (to switch it off). Tune2fs -L label /dev/sdb -> to create a label for /dev/sdb. ⦁ Xfs: xfs-admin -L label /dev/sdb to create a label for /dev/sda. xfs_admin -l /dev/sdx -> to show xfs properties.
Below, you will find the write steps to mount a file system : -> df -hT to all the drivers and parts mounted on. 1- mkdir /mnt/mymp to create a mountpoint 2- mount /dev/<devicename> <mount point> (You can use LABEL instead of dname) exp : mount /dev/sda /mnt/mymp => to mount the device temporarily 3- echo "/dev/sda /mnt/mytmp xfs defaults 0 0" >> /etc/fstab => to mount it persistently. 4- systemctl daemon-reload 5- mount -a 6- mount => to verify the mounting. 7- umount /mnt/mymp to unmount the device.
swap partition is used to support the memory. below you will find the right steps to make a 200M swap partition :
free -m -> to check kthe memory states. lsblk -> to see what disk is free to work on
fdisk /dev/sdc (n,ENTER,ENTER,200M,t(type),L(list)(search for swap),82,w)
partx; lsblk -> to verify the creation
mkswap /dev/sdc -> to make swap on /dev/sdc
echo "/dev/sdc swap swap defaults 0 0" >> /etc/fstab -> to mount the swap
swapon /dev/sdc to activate the swap
free -m -> to verify.
Hope this was useful, lets advance and learn about lvm and stratis and vdo.