Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, 23 January 2023

Add additional space to ext4 filesystem in RHEL

 To add additional space to an ext4 filesystem on a Red Hat Enterprise Linux (RHEL) system, you can use the following steps:

  1. Use the command df -h to check the current usage and available space on the filesystem.
  2. Use the command fdisk -l to check the available disk space on the system.
  3. If there is free space on the disk, you can use the command fdisk /dev/sda (replacing /dev/sda with the appropriate device name) to create a new partition with the free space.
  4. Use the command mkfs.ext4 /dev/sdaX (replacing /dev/sdaX with the appropriate device name) to create a new ext4 filesystem on the new partition.
  5. Use the command mount /dev/sdaX /mnt (replacing /dev/sdaX and /mnt with the appropriate device name and mount point) to mount the new filesystem.
  6. Use the command df -h again to check the new available space on the filesystem.
  7. If you want to mount this filesystem automatically during boot, you should add an entry in the /etc/fstab file.

Please, be aware that this is a dangerous operation, if any mistake happens, it can cause data lost. It's strongly recommended to backup your data before doing this operation.




Tuesday, 3 January 2023

Remove an Old or New kernel in Fedora

To remove a kernel in Fedora, follow these steps:

Identify the kernel you want to remove using the uname -r command. This will display the currently running kernel version.

Use the rpm -qa | grep ^kernel command to list all of the installed kernel packages on your system. Look for the kernel package that you want to remove. It will be named kernel-version, where version is the version number of the kernel you want to remove.

Example:

rpm -qa | grep ^kernel

proves the kernel 6.0.11 is still present:

kernel-core-6.0.11-300.fc37.x86_64
kernel-modules-6.0.11-300.fc37.x86_64
kernel-devel-6.0.11-300.fc37.x86_64
kernel-6.0.11-300.fc37.x86_64
kernel-core-6.0.12-300.fc37.x86_64
kernel-modules-6.0.12-300.fc37.x86_64
kernel-devel-6.0.12-300.fc37.x86_64
kernel-6.0.12-300.fc37.x86_64

to remove older kernel the below command will have to be used.

sudo dnf remove kernel-headers-6.0.5-300.fc37.x86_64
sudo dnf remove kernel-core-6.0.11-300.fc37.x86_6
sudo dnf remove kernel-modules-6.0.11-300.fc37.x86_64
sudo dnf remove kernel-6.0.11-300.fc37.x86_64

you can follow the below step too.

sudo dnf remove $(rpm -qa | grep ^kernel | grep 6\.0.11)

After uninstalling the kernel, you will need to update the GRUB boot menu so that the removed kernel is no longer listed as an option. To do this, run the grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg command. This will regenerate the GRUB configuration file with the updated list of kernels.

Reboot your system to apply the changes. The removed kernel will no longer be listed in the boot menu.

Note: Keep in mind that you should not remove the kernel that is currently running. If you do, you will not be able to boot your system. It is recommended to always have at least two kernels installed so that you have a fallback in case something goes wrong.


Monday, 2 January 2023

Resize the Redhat XFS LVM partition

To resize a Redhat XFS LVM partition, you will need to follow these steps:

Backup your data to a safe location. Resizing a partition always carries the risk of data loss, so it is important to have a backup before proceeding.

Check if the partition is mounted. You cannot resize a mounted partition, so you will need to unmount it first. To do this, run the following command:

umount /path/to/partition

Check if the partition is part of an LVM. If it is, you will need to deactivate the volume group (VG) before you can resize the partition. To do this, run the following command:

vgchange -an /dev/vg_name

Use the fdisk command to delete the existing partition and recreate it with the new size. Make sure to specify the correct device name for your partition (e.g. /dev/sda1).

Create a new physical volume (PV) on the resized partition:

pvcreate /dev/sda1

Add the PV to the VG:

vgextend /dev/vg_name /dev/sda1

Use the lvextend command to extend the logical volume (LV) to the desired size:

lvextend -L +size /dev/vg_name/lv_name

Finally, resize the XFS filesystem on the LV to fill the new space:

xfs_growfs /path/to/lv

That's it! You have successfully resized your Redhat XFS LVM partition.