Linux : swapon: /dev/sda5: Invalid argument

Today I have resize all Linux partition and find that my swap is not mounted. I have make swap again and its working fine.

Before resize of partition :

alienvault:/var/log# df -h
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda1     ext3     95G   74G   16G  83% /
tmpfs        tmpfs   1008M     0 1008M   0% /lib/init/rw
udev         tmpfs     10M  616K  9.4M   7% /dev
tmpfs        tmpfs   1008M     0 1008M   0% /dev/shm
You have new mail in /var/mail/root
alienvault:/var/log# fdisk -l

Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de769

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       12518   100550803+  83  Linux
/dev/sda2           12519       13054     4305420    5  Extended
/dev/sda5           12519       13054     4305388+  82  Linux swap / Solaris

alienvault:/var/log# free -m
total       used       free     shared    buffers     cached
Mem:          2014       1998         16          0          5        708
-/+ buffers/cache:       1284        729
Swap:         4204       1226       2978
alienvault:/var/log#
login as: root
root@10.1.50.115’s password:
Linux alienvault 2.6.31.6 #3 SMP Tue Jul 13 06:50:17 EDT 2010 x86_64
Profiles: Server Sensor Framework Database
=========================================================================
=========================================================================
==             _   _                                        _   _      ==
==      __ _  | | (_)   ___   _ __  __   __  __ _   _   _  | | | |_    ==
==     / _` | | | | |  / _ | ‘_ / / / _` | | | | | | | | __|   ==
==    | (_| | | | | | |  __/ | | | | V / | (_| | | |_| | | | | |_    ==
==     __,_| |_| |_|  ___| |_| |_|  _/   __,_|  __,_| |_|  __|   ==
==                                                                     ==
=========================================================================
===================== http://www.alienvault.com  ========================
=========================================================================
You have new mail.
Last login: Fri Apr  6 11:51:04 2012
alienvault:~#
alienvault:~#
alienvault:~# df -h
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda1     ext3     95G   53G   38G  59% /
tmpfs        tmpfs   1008M     0 1008M   0% /lib/init/rw
udev         tmpfs     10M  616K  9.4M   7% /dev
tmpfs        tmpfs   1008M     0 1008M   0% /dev/shm

After resize of partition:

alienvault:~# fdisk -l

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de769

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       25036   201101638+  83  Linux
/dev/sda2           25037       26108     8610840    5  Extended
/dev/sda5           25037       26108     8610808+  82  Linux swap / Solaris
alienvault:~# resize2fs /dev/sda1
resize2fs 1.41.3 (12-Oct-2008)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old desc_blocks = 6, new_desc_blocks = 12
Performing an on-line resize of /dev/sda1 to 50275409 (4k) blocks.
The filesystem on /dev/sda1 is now 50275409 blocks long.

alienvault:~# fdisk -l

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de769

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       25036   201101638+  83  Linux
/dev/sda2           25037       26108     8610840    5  Extended
/dev/sda5           25037       26108     8610808+  82  Linux swap / Solaris
alienvault:~# df -h
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda1     ext3    189G   53G  127G  30% /
tmpfs        tmpfs   1008M     0 1008M   0% /lib/init/rw
udev         tmpfs     10M  616K  9.4M   7% /dev
tmpfs        tmpfs   1008M     0 1008M   0% /dev/shm
alienvault:~# free -m
total       used       free     shared    buffers     cached
Mem:          2014       1995         18          0        784        197
-/+ buffers/cache:       1013       1001
Swap:            0          0          0

alienvault:~# swapoff -a

alienvault:~# swapon -a
swapon: /dev/sda5: Invalid argument

alienvault:~# mkswap /dev/sda5

Setting up swapspace version 1, size = 8817463 kB
no label, UUID=cc1ce0ea-364b-4acc-8f58-b54f91ff6349
alienvault:~#
alienvault:~# swapon -a
alienvault:~# df -h
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda1     ext3    189G   53G  127G  30% /
tmpfs        tmpfs   1008M     0 1008M   0% /lib/init/rw
udev         tmpfs     10M  616K  9.4M   7% /dev
tmpfs        tmpfs   1008M     0 1008M   0% /dev/shm
alienvault:~# free -m
total       used       free     shared    buffers     cached
Mem:          2014       1969         44          0        673        271
-/+ buffers/cache:       1024        989
Swap:         8408          0       8408
alienvault:~#

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top