EX200 Exam QuestionsBrowse all questions from this exam

EX200 Exam - Question 48


SIMULATION -

Make a swap partition having 100MB. Make Automatically Usable at System Boot Time.

Show Answer
Correct Answer:

To create a swap partition of 100MB and make it automatically usable at system boot time, follow these steps: First, use 'fdisk /dev/sdX' (replace 'X' with the appropriate device letter) to create a new partition. Type 'n' for a new partition and choose 'l' for logical. Accept the default starting cylinder by pressing Enter, and specify the size as +100M. Press 'p' to print the partition table and note the new partition name (likely /dev/sdX?). Next, change the partition type to swap by typing 't’, entering the partition number, and then typing '82' for Linux swap. Write the changes with 'w' and exit. Refresh the partition table with 'partprobe'. Format the swap partition using 'mkswap /dev/sdX?’ and activate it with 'swapon /dev/sdX?'. To make it persistent across reboots, add the entry to /etc/fstab using either the device name or preferably the UUID. To use the UUID, get it with 'blkid /dev/sdX?' and add UUID=your-uuid swap swap defaults 0 0 to /etc/fstab. Finally, reload the fstab file with 'systemctl daemon-reload' and verify the swap with 'swapon --show'.

Discussion

4 comments
Sign in to comment
cytron
Nov 11, 2020

In RHEL8 for fstab configuration is not more recommended to use absolute patch to the device like /dev/sda7. The recommendation is to use the UUID identifier instead. To get the swap or any other filesystem's UUID use the command blkid. This will show you all filesystems UUIDs in example: /dev/sda7: UUID="361ed5b5-872a-4e49-ba70-91efb28b2bb4" TYPE="swap" PARTUUID="caa5e8f6-01" Copy the section UUID="361ed5b5-872a-4e49-ba70-91efb28b2bb4" and use it in fstab as follows. UUID="361ed5b5-872a-4e49-ba70-91efb28b2bb4" swap swap defaults 0 0 reboot and verify swap is on free -m

kitkat
Jun 21, 2022

We will need to create 100MB partition. Those steps are missing.

kitkat
Jun 21, 2022

However what you mentioned is correct that we should use UUID in fstab.

kenkct
Mar 7, 2022

$sudo su #lsblk -psf #fdisk /dev/sd[x] #n #t #82 #mkswap /dev/sd[x] #swapon /dev/sd[x] #echo '/dev/sd[v] swap swap defaults 0 0' >> /etc/fstab #systemctl daemon-reload #mount -a #lsblk -psf

nickoftime
Apr 28, 2021

parted /dev/sdx mklabel msdos parted /dev/sdx mkpart linux-swap 1MiB 100Mib udevadm settle mkswap /dev/sdx1 (UUID checked) fstab add UUID=XXX swap swap defaults 0 0 systemctl daemon-reload swapon -a swapon --show

noobmaster96
Nov 25, 2021

my problem with parted is that if i do 1MiB to 100Mib, will that be just 99MiB? Are they particular with that area?

ANI_04
Oct 8, 2021

$ fdisk /dev/sda # change the partition type to swap $ partprobe $ echo " /dev/sdb1 swap swap defaults 0 0 " >> /etc/fstab $ mkswap /dev/sdb1 $ swapon -a