[CentOS] Adding another swap

Robert kerplop at sbcglobal.net
Wed Nov 5 05:32:51 UTC 2008


Indunil Jayasooriya wrote:
> Hi ALL,
>
> I have a harddisk with 3 primary partitions and one extended
> partitions. Under extented partions , there are 15 partions.
>
> Whole hard disk has been partitioned in a standard way, (i.e NOT LVM)
>
> It has 2GB ram. swap is also 2GB.
>
> Now I want to extend this swap to 4 GB.
>
> If I use dd coomand and create a file with 2GB, Will I be able to
> extend the swap witn swapon commnad?
>
> How can I achive this?
>
> Hope to hear form you,
>   
I just now shelled into a newly-loaded FC8 box and expanded the swap 
with a swap file:


[rj at mavis ~]$ ssh beau
rj at beau's password:
Last login: Tue Nov  4 11:31:13 2008
[rj at beauregard ~]$ su -
Password:
# Create the file:
[root at beauregard ~]# dd if=/dev/zero of=/root/swapfile bs=1G count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 119.248 s, 9.0 MB/s
#Make the swap fs on the file:
[root at beauregard ~]# mkswap -c /root/swapfile
Setting up swapspace version 1, size = 1073737 kB
no label, UUID=c75b5eaa-b483-44c8-9e4c-c895b16b045c
# Create an entry in fstab:
[root at beauregard ~]# echo "/root/swapfile          
swap                    swap    defaults        0 0" >> /etc/fstab
# Activate the new swap area:
[root at beauregard ~]# swapon -a
# Sure enough, it is in use:
[root at beauregard ~]# cat /proc/swaps
Filename                                Type            Size    Used    
Priority
/dev/sda5                               partition       1534168 75304   -1
/root/swapfile                          file            1048568 0       -2
[root at beauregard ~]#   

                                                        




More information about the CentOS mailing list