LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2024, 02:18 AM   #1
kotte
LQ Newbie
 
Registered: Feb 2024
Posts: 4

Rep: Reputation: 0
Hangs on boot after deleting swap


Ubuntu 22.04

Definitely a newb at linux, pretty much just here for gaming, python, and blender.

I have 128 GB of RAM and didn't see the point in having a swap, so I deleted it with Gparted. Booted up with my live usb in recovery mode, and from there had it boot normally. Haven't yet tried rebooting without the live usb.

1. What should I have read before I did this?
2. What terminal commands should I enter to provide more information to you?
 
Old 02-15-2024, 02:40 AM   #2
beachboy2
Senior Member
 
Registered: Jan 2007
Location: Wild West Wales, UK
Distribution: Linux Mint 21 MATE, EndeavourOS, antiX, MX Linux
Posts: 3,972
Blog Entries: 32

Rep: Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465Reputation: 1465
kotte,

Welcome to LQ forums.

You need to edit the /etc/fstab file, plus update both initramfs and grub.

Detailed info here:
https://unix.stackexchange.com/quest...-debian-jessie
 
Old 02-15-2024, 03:38 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,130

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Hopefully not too detailed - note those file references (e.g. fstab) are to the on-disk system, not the liveUSB equivalents. Are you able to provide listings of them ?.
Quote:
Originally Posted by kotte View Post
I have 128 GB of RAM and didn't see the point in having a swap, so I deleted it ...
Obligatory reference to an excellent rebuff from one of the kernel devs here.
 
Old 02-15-2024, 04:40 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,721

Rep: Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914
Welcome to LinuxQuestions.

As far as I know Ubuntu creates a swap file by default now not a partition anymore unless you manually created the partitions for the installation. Can you delete a swap file from gparted?
 
Old 02-15-2024, 06:52 AM   #5
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,526

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
Ubuntu has been using a swap file for several years rather than a swap partition. So is Ubuntu the only OS installed? Did you create the swap partition yourself? Was it created/used for another Linux OS? I'd follow the suggestion above to comment out or delete the entry for swap in the /etc/fstab file. The expected entry in the fstab file for Ubuntu would start with; /swapfile
 
Old 02-15-2024, 07:07 AM   #6
kotte
LQ Newbie
 
Registered: Feb 2024
Posts: 4

Original Poster
Rep: Reputation: 0
Hello all, and thank you for the welcome. Especially beachboy2 for that solution.

I first read the link syg00 provided to understand why I should want a swap. I decided to make a similarly sized swap as I first made to see if it would work, at least to start. I did so with Gparted.

After that, I read beachboy2's link

Looking at /etc/fstab and reading that stackexchange explanation I realized I needed to get the UUID for the new swap partition, and replace the old UUID with the new one in /etc/fstab. I did so by running:
ls -l /dev/disk/by-uuid/

I identified each partition by name and UUID by comparing the /dev/[filename] of each partition in /etc/fstab to the partition names in GParted, then noting the UUID of each. Then I replaced the old with the new as above.

Following along in the stackexchange link, I made sure that the swap partition's UUID existed, was updated, was correctly formatted as per the link, and was not commented out in /etc/initramfs-tools/conf.d/resume.

Then I turned the swap on in gparted, verified it was running in the system monitor, and ran:
update-initramfs -u -k all
update-grub

The swap works, it boots in less than 10 seconds, so all's good!

I may resize the swap partition later to between 2 and 4 gigabytes, and resize my ext4 partition to use the freed space, but first I want to make sure nothing bad will happen, back up my files, and make a restore point (which I should've done before).

Thank you all very much for the help!

Last edited by kotte; 02-15-2024 at 07:09 AM.
 
Old 02-15-2024, 04:30 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,130

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Good for you.

Next time make life easy(er) on yourself by using the same UUID on the regenerated swap - see the manpage. Simply swapoff, delete the partition, remake it at the "end" of the disk so you only need to do it once, and remake it with the UUID. Swapon, all done.
KISS.
 
Old 02-15-2024, 11:56 PM   #8
kotte
LQ Newbie
 
Registered: Feb 2024
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Next time make life easy(er) on yourself by using the same UUID on the regenerated swap - see the manpage. Simply swapoff, delete the partition, remake it at the "end" of the disk so you only need to do it once, and remake it with the UUID. Swapon, all done.
The manpage of which program?

Also if I were to shrink the swap to ~ 2 GiB, and grow the / ext4 partition to reclaim the unused space leftover by the smaller swap partition, I'd have to do the latter in a live USB, correct?
 
Old 02-16-2024, 01:00 AM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,130

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
"man mkswap".

All of this can be done whilst the system is running, but I wouldn't recommend it for a self confessed "newb at linux". LiveUSB is always a good option. Also note my sigline - especially when messing with partitions.
 
Old 02-16-2024, 06:35 AM   #10
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,526

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
Your problem could have been avoided entirely if you (or whoever installed Ubuntu) had not decided to create a swap partition when the default behavior with newer Ubuntu releases is to use a swap file. Curious as to why you did that. On the other hand, this was a good learning experience.
 
Old 02-17-2024, 04:26 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,130

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by yancek View Post
Your problem could have been avoided entirely if you (or whoever installed Ubuntu) had not decided to create a swap partition when the default behavior with newer Ubuntu releases is to use a swap file.
How so ?.

Anyone inclined to delete a swap partition to reclaim what they see as "wasted space" would likely be just as motivated to delete a swap file.
Similar result.
 
Old 02-17-2024, 06:22 AM   #12
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,526

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
True enough, a good reason to investigate the consequences of an action before making a change. The OP did ask about consequences in the initial post but not until after the swap was deleted. Would have been better off accepting the defaults until after investigating which is the point I was making, investigate before you act.

Last edited by yancek; 02-17-2024 at 06:29 AM.
 
  


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
Boot problems after deleting dual boot Ubuntu 16.04.2 LTS with windows 10 abdcode Linux - Newbie 15 03-28-2017 07:33 AM
Power failure - boot hangs (after enabling /etc/fstab swap [OK]) workaholicbe Linux - Software 5 01-17-2013 10:31 AM
deleting duplicate lines without deleting first instance of the duplicated line jkeertir Linux - Newbie 2 02-07-2011 06:55 AM
Fedora 3 boot hangs after "Enabling swap space: [OK]" Voroojack Fedora 2 11-29-2005 09:21 AM
after Enabling swap space Fedora hangs on boot ejbest Linux - Newbie 11 10-07-2004 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:21 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