LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 11-23-2020, 01:57 AM   #1
bomabay123
LQ Newbie
 
Registered: Oct 2020
Posts: 11

Rep: Reputation: Disabled
Post /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 ?

thread issue date 23/11/2020
 
Old 11-23-2020, 04:00 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
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.
 
Old 11-25-2020, 02:36 AM   #3
bomabay123
LQ Newbie
 
Registered: Oct 2020
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
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.
 
Old 11-25-2020, 04:43 AM   #4
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
base on this
Quote:
i have created /dev/sda1 - 210mb for boot
Code:
mount -o remount,rw /
mount /dev/sda1 /boot
ls /boot
or from live iso
Code:
sudo mount /dev/sda1 /mnt
ls /mnt

Last edited by colorpurple21859; 11-25-2020 at 04:49 AM.
 
Old 12-05-2020, 11:26 PM   #5
bomabay123
LQ Newbie
 
Registered: Oct 2020
Posts: 11

Original Poster
Rep: Reputation: Disabled
/dev/sda2 root file delted

Quote:
Originally Posted by colorpurple21859 View Post
base on this
Code:
mount -o remount,rw /
mount /dev/sda1 /boot
ls /boot
or from live iso
Code:
sudo mount /dev/sda1 /mnt
ls /mnt

i have recreated the partition of same size, with GPARTED now it is working ..
 
Old 12-05-2020, 11:28 PM   #6
bomabay123
LQ Newbie
 
Registered: Oct 2020
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks

Quote:
Originally Posted by colorpurple21859 View Post
base on this
Code:
mount -o remount,rw /
mount /dev/sda1 /boot
ls /boot
or from live iso
Code:
sudo mount /dev/sda1 /mnt
ls /mnt

Thanks for your reply..i will try your option also..
thanks for your all help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I had accidentally deleted my partition table while trying to install Phoenix OS...need help to recover it... 5HR33H4R Linux - Newbie 11 07-26-2018 07:28 PM
[SOLVED] swapon: /dev/sda2: read swap header failed: Invalid argument ted_chou12 Linux - Newbie 2 09-29-2012 09:36 PM
Readjust disk space between /dev/sda2 and /dev/sda5 born2bdesi Linux - Newbie 23 12-20-2010 11:40 PM
accidentally deleted the swap : linux won't start nkd Linux - Newbie 6 11-20-2010 10:16 AM
/sbin/e2fsck: No such file or directory while trying to open /dev/sda2 Yalla-One Slackware 2 03-10-2010 12:48 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 12:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration