LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-08-2019, 07:45 PM   #1
zaivala
Member
 
Registered: Mar 2008
Location: Blaine TN USA
Distribution: Linux Mint 20.1 Bodhi 6, OpenMandriva Lx 4.2, others
Posts: 264
Blog Entries: 52

Rep: Reputation: 51
Help Me Use My Swap


My system has multiple partitions, with a swap partition and 4 other partitions. The 4 other partitions each have a distro of Linux on them, and some of them change from time to time. The older two distros have lost the location of the swap partition == they display the name of a partition but says it isn't there. I think they have the name right, but don't know enough to be certain.

W: initramfs-tools configuration sets RESUME=UUID=1b0b9f28-4745-40e7-9bad-5cc3ff41e862
W: but no matching swap device is available.


So. I have a swap partition. I need my distros to use the swap partition. What is the easiest way of telling them each where it is (and, if necessary, how to access it)?

The system is a Lenovo ThinkPad T430 with a 500 Gb hard drive and 8 Gb RAM (formerly 4 Gb), all Intel chips.

Last edited by zaivala; 09-08-2019 at 07:48 PM.
 
Old 09-08-2019, 07:48 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,124

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Run these and post the output from one of the linux systems.
Code:
swapon -s
grep -i swap /etc/fstab
lsblk -f
 
Old 09-08-2019, 08:54 PM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Code:
/sbin/blkid
that will tell you which partitions are swap and the UUID of them

Edit: ah, I see lsblk -f above now
that is easier

Last edited by Firerat; 09-08-2019 at 08:56 PM.
 
Old 09-09-2019, 06:29 AM   #4
zaivala
Member
 
Registered: Mar 2008
Location: Blaine TN USA
Distribution: Linux Mint 20.1 Bodhi 6, OpenMandriva Lx 4.2, others
Posts: 264

Original Poster
Blog Entries: 52

Rep: Reputation: 51
Thank you. Ill try this.

zaivala@zaivala-ThinkPad-T430:~$ swapon -s
zaivala@zaivala-ThinkPad-T430:~$ grep -i swap /etc/fstab
zaivala@zaivala-ThinkPad-T430:~$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 swap 49cd4adc-6576-46c9-b8bf-d290d9ae6903
├─sda2 ext4 0e300f04-2fdf-4ad8-ab34-45ce3d0a7dc1 /
├─sda3
├─sda4 ext4 f243d2a0-bbfc-4917-a06d-04fc714a5d3d
├─sda5 ext4 c607b095-9897-440e-9fa3-040d30fb9dd5
└─sda6 ext4 32b6ae30-511f-4c01-a146-a9d56cc9c62d
sr0
zaivala@zaivala-ThinkPad-T430:~$

Now what? Other than the fact that I'm pretty sure the swap file is a completely different address than the one I posted LOL
 
Old 09-09-2019, 07:10 AM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by zaivala View Post

Now what? Other than the fact that I'm pretty sure the swap file is a completely different address than the one I posted LOL
yes, it is "hard coded" in a configuration file

the UUID changes if you use mkswap ( recreating the swap filesystem )
you will need to find the file initramfs-tools uses and correct the UUID

you mentioned other distros
you can share a swap partition , BUT you will not be able to use resume
if you want resume they each need their own swap partition

you could go the swapfile ( use a file like a blockdevice ) but that will complicate things

how tied to your existing setup are you?
you could start from scratch.
but instead of using traditional partitions a more flexible approach would be to use lvm2

as example
I have a VM that I'm playing with
Code:
parted /dev/sda print
<edit snip remove scroll>
Number  Start   End     Size    File system  Name  Flags
 1      1049kB  6291kB  5243kB                     bios_grub
 3      6291kB  1075MB  1068MB
 2      1075MB  21.5GB  20.4GB                     lvm
ignore partition 3 it is not important

Code:
lsblk   
NAME                     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                        8:0    0    20G  0 disk 
|-sda1                     8:1    0     5M  0 part  
|-sda2                     8:2    0    19G  0 part 
| |-vg_slackware-lv_swap 252:0    0     1G  0 lvm  [SWAP]
| |-vg_slackware-lv_root 252:1    0    10G  0 lvm  /
| `-vg_slackware-lv_temp 252:2    0     1G  0 lvm  
`-sda3                     8:3    0  1019M  0 part

instead of vg_slackware,

Code:
vg_distos
├─lv_boot
├─lv_distro1_swap
├─lv_distro1_root
├─lv_distro2_swap
├─lv_distro2_root
├─lv_distro3_swap
├─lv_distro.... you get the idea
some info here
https://en.wikipedia.org/wiki/Logica...Manager_(Linux)

Last edited by Firerat; 09-09-2019 at 07:13 AM. Reason: snip parted output so part2 is not hidden
 
Old 09-09-2019, 12:49 PM   #6
zaivala
Member
 
Registered: Mar 2008
Location: Blaine TN USA
Distribution: Linux Mint 20.1 Bodhi 6, OpenMandriva Lx 4.2, others
Posts: 264

Original Poster
Blog Entries: 52

Rep: Reputation: 51
I got different results on my other laptop... I need to take some time reading your last entry.

zaivala@zaivala-Lenovo-ideapad-110-15ACL:~$ swapon -s
Filename Type Size Used Priority
/swapfile file 2097148 0 -2
zaivala@zaivala-Lenovo-ideapad-110-15ACL:~$ grep -i swap /etc/fstab
/swapfile none swap sw 0 0
zaivala@zaivala-Lenovo-ideapad-110-15ACL:~$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 ext4 50a7a97c-a532-4bfb-870b-eeddfa04d097 /
├─sda2 ext4 12b3b2b8-4daa-4718-860c-f493e675ccf9
├─sda3 ext4 7fff0921-fb3a-42a5-a015-dc71505996f0
└─sda4 swap d51f2cbd-474c-4818-9fc4-d6844f1f4ed1
sr0
zaivala@zaivala-Lenovo-ideapad-110-15ACL:~$

So, why does each partition need its own swap file? Isn't the swap partition wiped and ready for use when you boot down? (Remember, you keep saying there are no stupid questions LOL)
 
Old 09-09-2019, 01:30 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
To elaborate on the other posts, filesystems including swap are assigned a unique number called a UUID (sda4 UUID=d51f2cbd-474c-4818-9fc4-d6844f1f4ed1 ) when they are created. One minor problem with today's hardware/operating systems is the same physical hard drive may not be automatically assigned the same device ID i.e. sda,sdb etc.

At boot time the operating system uses the /etc/fstab file to mount the filesystems and one method to identify them is by their UUID. When you installed each operating system you assigned the same swap partition but you had it formatted which as stated created a new UUID so the previous operating systems /etc/fstab file did not match any more.

As stated you can go back and change each /etc/fstab to match the current swap UUID but if you suspend/sleep any of your systems, then boot another operating system you might corrupt the suspended system since it could save its memory in swap and be overwritten by the other. For that reason it might be better if each operating system had their own swap file/partition.

Last edited by michaelk; 09-09-2019 at 01:34 PM. Reason: clarification
 
Old 09-09-2019, 01:38 PM   #8
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by zaivala View Post
So, why does each partition need its own swap file? Isn't the swap partition wiped and ready for use when you boot down? (Remember, you keep saying there are no stupid questions LOL)
you can use the same swap partition for each disto
However, you can't if you want to use the resume feature

When you suspend, the stuff in ram is saved to the swap partition
When you resume it is moved from the swap back to ram

so what happens if you boot another distro ?
Confusion.

If you are *not* going to hibernate, you should *not* use UUID in fstab for your swap
instead use PARTUUID or by-id , by-path
see output of
Code:
ls /dev/disk/*
the reason being each disto may re mkswap which changes the UUID
( That is what happened to bring you here )


typically I don't use swap
the only reason that slackware has some is due to it being a virtualMachine and I have not given it much ram

tl;dr
give each distro its own swap partition
use lvm2 for easier life in the long run
 
Old 09-09-2019, 05:55 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,124

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
And just to prove Linux is about choice - I always use swap, and I always use device designations (/dev/sda1), and I share that swap partition.
You need to be careful when hibernating as mentioned, but the setup and maintainence is easier. The stampede to UUID a few years was more for the convenience of the packagers of distros than end users. Especially those of us that do this. And no, I'm not going to debate it.

The swap is specified in your /etc/fstab for each system (as per your swapfile system) - you can simply update each one in need. If you wish to use swap immediately on a system, simply issue "swapon /dev/sda1".
 
1 members found this post helpful.
Old 09-10-2019, 06:31 AM   #10
zaivala
Member
 
Registered: Mar 2008
Location: Blaine TN USA
Distribution: Linux Mint 20.1 Bodhi 6, OpenMandriva Lx 4.2, others
Posts: 264

Original Poster
Blog Entries: 52

Rep: Reputation: 51
I never use suspend/sleep/hibernate functions, so I guess I'm OK. Thanks for all the information.
 
Old 09-10-2019, 06:59 AM   #11
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,613

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Quote:
Originally Posted by syg00 View Post
And just to prove Linux is about choice - I always use swap, and I always use device designations (/dev/sda1), and I share that swap partition.
You need to be careful when hibernating as mentioned, but the setup and maintainence is easier. The stampede to UUID a few years was more for the convenience of the packagers of distros than end users. Especially those of us that do this. And no, I'm not going to debate it.

The swap is specified in your /etc/fstab for each system (as per your swapfile system) - you can simply update each one in need. If you wish to use swap immediately on a system, simply issue "swapon /dev/sda1".
I always use swap, and always more than the amount of RAM. I never, however, use device designations unless the device is virtual. UUID, MD, LVM, or RAID designations I MIGHT use, but I prefer to use labels. I have had device designation change and found labels, uuid, MD, RAID, and LVM names far more reliable.
 
Old 09-13-2019, 09:24 PM   #12
zaivala
Member
 
Registered: Mar 2008
Location: Blaine TN USA
Distribution: Linux Mint 20.1 Bodhi 6, OpenMandriva Lx 4.2, others
Posts: 264

Original Poster
Blog Entries: 52

Rep: Reputation: 51
zaivala@zaivala-ThinkPad-T430:~$ ls /dev/disk/*
/dev/disk/by-id:
ata-HGST_HTS725050A7E630_TF755BWH0U669S wwn-0x5000cca77ecb7490
ata-HGST_HTS725050A7E630_TF755BWH0U669S-part1 wwn-0x5000cca77ecb7490-part1
ata-HGST_HTS725050A7E630_TF755BWH0U669S-part2 wwn-0x5000cca77ecb7490-part2
ata-HGST_HTS725050A7E630_TF755BWH0U669S-part3 wwn-0x5000cca77ecb7490-part3
ata-HGST_HTS725050A7E630_TF755BWH0U669S-part4 wwn-0x5000cca77ecb7490-part4
ata-HGST_HTS725050A7E630_TF755BWH0U669S-part5 wwn-0x5000cca77ecb7490-part5
ata-HGST_HTS725050A7E630_TF755BWH0U669S-part6 wwn-0x5000cca77ecb7490-part6
ata-MATSHITADVD-RAM_UJ8C0_HP13_214906

/dev/disk/by-partuuid:
efbd59c9-01 efbd59c9-02 efbd59c9-03 efbd59c9-04 efbd59c9-05 efbd59c9-06

/dev/disk/by-path:
pci-0000:00:1f.2-ata-1 pci-0000:00:1f.2-ata-1-part4
pci-0000:00:1f.2-ata-1-part1 pci-0000:00:1f.2-ata-1-part5
pci-0000:00:1f.2-ata-1-part2 pci-0000:00:1f.2-ata-1-part6
pci-0000:00:1f.2-ata-1-part3 pci-0000:00:1f.2-ata-2

/dev/disk/by-uuid:
0e300f04-2fdf-4ad8-ab34-45ce3d0a7dc1 c607b095-9897-440e-9fa3-040d30fb9dd5
49cd4adc-6576-46c9-b8bf-d290d9ae6903 f243d2a0-bbfc-4917-a06d-04fc714a5d3d
b9c5f0e0-5d1a-4751-b342-06bccca847ea
zaivala@zaivala-ThinkPad-T430:~$
 
Old 09-14-2019, 06:55 AM   #13
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
To keep from getting this error
Quote:
W: initramfs-tools configuration sets RESUME=UUID=1b0b9f28-4745-40e7-9bad-5cc3ff41e862
W: but no matching swap device is available.
and because you don't use resume, as root delete the file etc/initramfs-tools/conf.d/resume

Quote:
I got different results on my other laptop... I need to take some time reading your last entry.
The reason for the different results is that your swap partition is on the first partition /dev/sda1 and on the other system the fourth partition /dev/sda4. The UUID(Universally Unique IDentifier) will always be different. When installing a new system using the same swap will reformat the swap partition change the UUID.

One work around for this is to edit your fstab and change the swap line uuid=<some number> to /dev/sda? where the ? will be the number parition swap.
 
  


Reply

Tags
linux boot, swap



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
LXer: How To Use A Swap File Instead Of A Swap Partition On Linux LXer Syndicated Linux News 0 08-29-2018 03:14 PM
How to swap out (to swap area) page frames a process use? entertainyou Linux - Kernel 3 03-23-2011 09:52 PM
Use Windows pagefile.sys (swap) as Linux swap? bluesword1969 Linux - General 3 02-19-2010 02:35 PM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

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

All times are GMT -5. The time now is 02:54 AM.

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