[SOLVED] /dev/sda2 root swap partition deleted accidentally while increasing the partition space of /dev/mapper/rhel-root space
Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/dev/sda2 root swap partition deleted accidentally while increasing the partition space of /dev/mapper/rhel-root space
On my Oracle virtualbox 6.1 i have installed RHEL 7.9
i have created /dev/sda1 - 210mb for boot, 2. /dev/sda2 - 4gb for root swap and 3. /dev/mapper/rhel-root for the root space. my root space vdi was around 16 gb and total vdi space was 20GB. when i try to create more space in rhel-root through fdisk by accidentlly /dev/sda2 deleted.
Now when i power start from oracle virtualbox it is lending to dracut# prompt and issue warning /dev/sda2 root swap and /dev/mapper/rhel-root space missing.
now can anyone help me, how to recover the /dev/sda2 root swap and to resolve this issue ?
At the dracut prompt, edit /etc/fstab and either remove or comment the line that contains the swap definition. Before you do that, you may have to remount the root filesystem to make it writable. For example:
Code:
mount -o remount,rw /
sed -i.bak /swap/d /etc/fstab
This removes all lines that contain the string swap from /etc/fstab, and creates a file /etc/fstab.bak that has the original content.
After that, you should be able to boot, albeit without swap space. Most likely, you don't need swap space; if you do, the easiest solution is to add another VDI disk and swap to it.
At the dracut prompt, edit /etc/fstab and either remove or comment the line that contains the swap definition. Before you do that, you may have to remount the root filesystem to make it writable. For example:
Code:
mount -o remount,rw /
sed -i.bak /swap/d /etc/fstab
This removes all lines that contain the string swap from /etc/fstab, and creates a file /etc/fstab.bak that has the original content.
After that, you should be able to boot, albeit without swap space. Most likely, you don't need swap space; if you do, the easiest solution is to add another VDI disk and swap to it.
Reply on 25-11-2020, still it gives warning - /dev/mapper/rhel-root & /dev/rhel/root does not Exist actully during use of fdisk by mistake /dev/sda2 is deleted, therefore this 2 logical partition belongs to that. also does not shows.
2. now i am trying to recover /dev/sda2 using Gparted partition recovery to recover /dev/sda2. i do make changes in /etc/fstab. one more issue from dracut# with LS cmd i do not see /boot dir i want to access grub.conf how do i do it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.