LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Swap file size change in Fedora latest version (https://www.linuxquestions.org/questions/linux-newbie-8/swap-file-size-change-in-fedora-latest-version-4175563513/)

Janning 01-09-2016 03:36 PM

Swap file size change in Fedora latest version
 
hi,

I'm on Fedora 23, dell OptiPlex 745, core 2 duo, 2.13 Ghz, 1066Mhz FSB and 4 gig of RAM, the drive is a Samsung 840 EVO solid state drive.
The Swap file is currently at 4 GIG. How can I change this size? i'd like to go to 8 Gig.

Thanks JAmes

wagscat123 01-09-2016 04:02 PM

Before you mess with your swap partition, run from a root terminal "swapoff /dev/sda?", with ? as your partition number. All of these partitioning commands require a root command line. You have also now received the generic forewarning about backing up your data when messing with your partitioning.

The most intuitive way to go about this would be to use Gparted and shrink a neighbhoring partition (or use unpartitioned space) so you can delete your current swap partition and create an 8 GB one. Gparted has pretty "Add" buttons and partitions can be deleted or resized by right clicking the partitions and clicking on the desired option.

If you want to be savvy and do it the command line way, fire up parted with probably "parted /dev/sda" and type print to get your partition layout, then give us the output of that. If you dish out the "list" command to parted you can get a list of commands and go from there.

Either way, you'll need to set the partition label of the new swap partition to "Linux swap/Solaris" and run "mkswap /dev/sda?" and "swapon /dev/sda?"

Emerson 01-09-2016 05:56 PM

Swap file you said? Create another file of desired size and delete the old one.

wagscat123 01-09-2016 06:08 PM

I possibly erranously assumed you meant swap partition rather than swap file. Making a bigger swap file would be as easy as running:
Code:

# swapoff <location of swapfile>
# dd if=/dev/zero of=<location of swapfile> bs=1024 count=8388608
# mkswap <location of swapfile>
# swapon <location of swapfile>

This unmounts your swapfile, overwrites your old swapfile with a bigger one, initiates the swapfile as a swapfile, and mounts your new swapfile.

Janning 01-09-2016 06:20 PM

Quote:

Originally Posted by Emerson (Post 5475769)
Swap file you said? Create another file of desired size and delete the old one.

hi, can you be more specific....keep in mind I'm new to Linux... as in don't know where to begin when you say "create a new file"?
there has to be more to it? as in location? file name etc

273 01-09-2016 06:50 PM

It really depends upon whether you did create a "swap file" or a swap partition but, anyhow, you could just read the manual. If you created a swap partition then that space is, effectively, lost until you run something like gparted (risking your data) to resize the other partitions to move into that space.

rknichols 01-09-2016 07:08 PM

Keep in mind that you can have more than one swap file or partition. Depending on how your disk is partitioned, it might be easier to add a second swap partition rather than resize the existing one, or you could add a swap file to supplement the existing swap space (file or partition).

Janning 01-10-2016 12:51 AM

1 Attachment(s)
Quote:

Originally Posted by Emerson (Post 5475769)
Swap file you said? Create another file of desired size and delete the old one.

I looked at the "Disks" app on the desktop, it showing a swap volume, (this is a partition I assume?)at: (see attached file swap1a.jpg also at www.aanning.com\ajissues\fedora_swap
volume:
/dev/fedora_localhost/swap

So do I have a swap file? partition or both?
Keep in mind, I'm a very beginner in Linux.
Thanks James

Janning 01-10-2016 12:56 AM

Quote:

Originally Posted by 273 (Post 5475786)
It really depends upon whether you did create a "swap file" or a swap partition but, anyhow, you could just read the manual. If you created a swap partition then that space is, effectively, lost until you run something like gparted (risking your data) to resize the other partitions to move into that space.

I see in the manual it shows how to create one, I already have one (see image swap1a.jpg at www.aanning.com\ajissues\fedora_swap screenshot of the Disks app)
I'm not finding in the manual where to change the existing size? I may need to change the partition size first from 4.2 gig to ..oh? 8.5 gig as to have then
change the swap to 8 gig.

As I've said before, keep in mind I'm a Linux beginner
Thanks James.

Janning 01-10-2016 12:58 AM

Quote:

Originally Posted by rknichols (Post 5475793)
Keep in mind that you can have more than one swap file or partition. Depending on how your disk is partitioned, it might be easier to add a second swap partition rather than resize the existing one, or you could add a swap file to supplement the existing swap space (file or partition).


I think I like this idea, add another partition..say another 4.2 gig, and make a second 4 gig swap there...and it would use them both?
i'm not sure as how to "point it" to both? or even how to create a second partition.
Thanks James

syg00 01-10-2016 01:52 AM

Why do you think you need to change it ?.

Janning 01-10-2016 01:58 AM

Quote:

Originally Posted by syg00 (Post 5475869)
Why do you think you need to change it ?.

System resource shows the RAM is at 80% capacity as well as the swap. It would be good to have a little more breathing room. I'm installing Oracle WEB logic on this box, I'm guess when its up and running those % may go up. This is not a production project by any means..all non critical, more a learning experience.

syg00 01-10-2016 02:21 AM

It's very easy to mis-read (or be misled) with memory stats. Let's see the numbers that have you concerned.
Adding extra swap is no major task, and simply need to be added to /etc/fstab once verified. Let's also see the output from
Code:

lsblk

Janning 01-10-2016 02:30 AM

Quote:

Originally Posted by syg00 (Post 5475877)
It's very easy to mis-read (or be misled) with memory stats. Let's see the numbers that have you concerned.
Adding extra swap is no major task, and simply need to be added to /etc/fstab once verified. Let's also see the output from
Code:

lsblk


[root@localhost ajfd]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 111.8G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 111.3G 0 part
├─fedora_localhost-root 253:0 0 50G 0 lvm /
├─fedora_localhost-swap 253:1 0 3.9G 0 lvm [SWAP]
└─fedora_localhost-home 253:2 0 57.4G 0 lvm /home
sr0 11:0 1 1024M 0 rom

Janning 01-10-2016 03:19 AM

How about this, which has been suggested. Will this work? If so What will this do with my current 4gig swap?
(open terminal, switch to root)

dd if=/dev/zero of=/my8GBswap bs=1M count=8192

chmod 600 /my8GBswap

mkswap /my8GBswap

swapon /my8GBswap

echo "/my8GBswap swap swap defaults 0 0" >> /etc/fstab

verify with swapon -s


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