managing the swap space size on fedora

Dario Lesca d.lesca at solinos.it
Sat Jun 13 18:28:03 UTC 2015


Il giorno sab, 13/06/2015 alle 17.01 +0300, Angelo Moreschini ha
scritto:
> Hi,
> I need to adjust the swap space of my computer, and using the 
> commands lsblk e swapon -s :
> I got the following output
> - =-=-=-=-=-=-
> [angelo_dev at localhost ~]$ sudo lsblk
> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
> sda 8:0 0 931.5G 0 disk
> ├─sda1 8:1 0 500M 0 part /boot
> └─sda2 8:2 0 931G 0 part
> ├─fedora_localhost-swap 253:0 0 7.8G 0 lvm [SWAP]
> ├─fedora_localhost-root 253:1 0 50G 0 lvm /
> └─fedora_localhost-home 253:2 0 873.2G 0 lvm /home
> sr0 11:0 1 1024M 0 rom
> [angelo_dev at localhost ~]$ swapon -s
> Filename	 Type	 Size	Used	Priority
> /dev/dm-0 partition	8126460	0	-1
> - =-=-=-=-=-=-
> 
> This makes me think that the swap space on my computer resides on the 
> partition / dev / dm-0, which is 'managed by LVM, and' of about 8 GB.
> The RAM of the computer and 'GB, and I would initially try to bring 
> the swap space to 16 GB (after I might try other values ....).
> 
> Since the swap partition and 'managed by LVM should not be hard to 
> change its size, but it is still fairly inexperienced I would get a 
> little help to do this.

Your swap partition is /dev/fedora_localhost-swap

take a look at how much free space you have in LVM

> sudo pvscan
>   PV /dev/mapper/luks-04cb7d3f-fb60-42ca-9dbe-1ae18433f62d   VG vg_dododell   lvm2 [196,28 GiB / 7,72 GiB free]
>   Total: 1 [196,28 GiB] / in use: 1 [196,28 GiB] / in no VG: 0 [0   ]

In my case 7,72 GiB free.
If you have sufficient free space in LVM you can extend swap partition
with:

> sudo pvresize --size +6G /dev/fedora_localhost-swap

If you do not have sufficient LVM space free, you can shrink some other
partition, like /home, you can do that in single user mode, or logging
in with root from CTRL+Alt+F2 and without other active users, umount
/home, restrict filesystem (example 11Gb) , restrict partition (example
10 Gb), extend filesystem to max partition.

At this point you can extend the swap LVM partition.

When you have extend the swap partition, you must extend the swap area
with this command:

> swapoff /dev/fedora_localhost-swap
> mkswap /dev/fedora_localhost-swap
> swapon /dev/fedora_localhost-swap

Hope this help

Ciao

-- 
Dario Lesca
(inviato dal mio Linux Fedora 22 con Gnome 3.16)


More information about the users mailing list