Ask Your Question
1

Feodra fails to load after accidental swap remove

asked 2016-08-11 07:56:24 -0600

During a process were I was trying to deactivate a swap portion of a LiveUSB Fedora drive I accidental did a swapoff and lvremove on the swap drive for my system and not the USB stick like I intended.

Since i can't boot into the machine I can't access the command I used. I believe I first did

swapoff /dev/fedora/swap

and then

lvremove /dev/fedora/swap

I restarted my machine and after that it hangs on the Fedora loading screen and than goes into a command prompt following errors notifying me the swap is missing.

It was obvious to me when I got the error after restarting the machine that I had worked on the wrong volume. I belived since the name of the usb was fedora this was the right volume.

I tried reading up on how to create the swap partition again but not sure I understand it right. I booted with the LiveUSB and tried to follow these instructions https://docs.fedoraproject.org/en-US/...

I tried doing 'mkswap -v /dev/sda9' and 'swapon -v /dev/sd9a' but get error messages "swapon: /dev/sda9: read swap header failed" and "mkswap: cannot open /dev/sda9: Device or resource busy" respectively.

/dev/sda9 is the partition that the Fedora system on my laptop is on.

Is there a easy way to recreate the swap partition? Let me know in the comments if you need more details from me and I will try to provide them as soon as possible.

edit retag flag offensive close merge delete

Comments

1

Did you also remove the line in /etc/fstab when you removed the swap?

baggypants gravatar imagebaggypants ( 2016-08-11 09:14:03 -0600 )edit
3

If you deleted the swap partition with lvremove, then you'll have to create the partition (logical volume, "lv") again. Try a search about the command lvcreate.

jtlinux gravatar imagejtlinux ( 2016-08-11 09:20:39 -0600 )edit

can you also show the output of lsblk?

baggypants gravatar imagebaggypants ( 2016-08-11 09:20:59 -0600 )edit

@baggypants No, I never planned to remove the swap so I did not know about the /etc/fstab, I'm not very familiar with dealing with this. I only wanted to effect the USB stick. Clumsy oversight.

@jtlinux Looking into lvcreate I was able to figure out how to fix the problem. Thank you. I have posted my solution as a answer. It might not be the best solution but as far as I could get with my lack of experience on this issue.

Einar Ólafsson gravatar imageEinar Ólafsson ( 2016-08-11 11:16:56 -0600 )edit

3 Answers

Sort by » oldest newest most voted
2

answered 2016-08-11 11:10:23 -0600

I managed to figure it out with information provided in the comments to my questios as I looked into using lvcreate as mentioned by @jtlinux

Booting into the machine using a LiveUSB I followed the instructions in the CentOS documentations 5.2.2. Creating an LVM2 Logical Volume for Swap

I used lvscan to get the name of my lv group which was fedora and using lvdisplay I got the information that there was 7.75 GB of free space on the volume.

With that in mind I did the following

Create the LVM2 logical volume of size 7750 MB:

lvm lvcreate fedora -n swap -L 7750M

Format the new swap space:

mkswap /dev/fedora/swap

In my case I skipped editing the fstab on my drive but the line there unchanged is the following

/dev/mapper/fedora-swap swap swap defaults 0 0

Enable the extended logical volume:

swapon -va

Test that the logical volume has been extended properly:

cat /proc/swaps # free

The last part displayed a empty table, but after rebooting the machine I was able to boot into fedora and login and can't see any issues.

edit flag offensive delete link more
3

answered 2016-08-11 10:13:33 -0600

aeperezt gravatar image

Since you did not remove the swap partition from you fstab it will not load, what you need to do is start Fedora in rescue mode load your root partition edit /etc/fstab and comment out the swap partition there, save the file an reboot. After that when it boot you can create the swap partition again and add it to fstab.

To enter in rescue mode follow this: https://docs.fedoraproject.org/en-US/...

edit flag offensive delete link more

Comments

Thank you for your solution. I managed to get around editing the /etc/fstab by booting my machine with a LiveUSB and creating the swap partition again. You can see what I did in my answer to my own question.

Einar Ólafsson gravatar imageEinar Ólafsson ( 2016-08-11 11:18:42 -0600 )edit
0

answered 2016-08-11 15:33:54 -0600

sideburns gravatar image

Now that you've got your system working again, it might be a Good Idea to use e2label to rename your LiveUSB, e.g., sudo e2label /dev/XXX LiveUSB substituting the proper location for XXX, of course. That way, you won't get your Live system and your regular one mixed up as easily. (I always rename my flash drives so that the label reminds me of what it's for.)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-11 07:56:24 -0600

Seen: 134 times

Last updated: Aug 11 '16