[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

can't swapon second partition after swapoff, overwrite /dev/urandom, swapon



I tried googling and checking docs but couldn't find anything relevant.
I have 2 swap partitions, /dev/sda6, /dev/sda7.  1 GB of Ram
I wanted to wipe my swap partitions, so I did swapoff /dev/sda7, then
dd if=/dev/urandom of=/dev/sda7, then mkswap /dev/sda7, then swapon /dev/sda7
With swapon /dev/sda7, I get the following error message:
# swapon /dev/sda
swapon: /dev/sda7: Invalid argument

I noticed afterward that mkswap made a swap that was considerably smaller than the 1 GB allotted to each of the two swap partitions, it was only about 200-250 MB in size, it should have been 996 MB (just under 1 GB formatted) or so in size.  Don't have the error message available.  The only google item I found for this was old info on old pre 2.2 or 2.0 kernels with older version of swap vs. newer version of swap, with mkswap now defaulting to the new version so this shouldn't be an issue.

I added the swapfile (/swapfile0) after I had problems with swapon /dev/sda7

I also did a dd if=/dev/zero of=/dev/sda7 to try the whole procedure again and swapon /dev/sda7 still fails with the same error message.  But the /dev/sda7 partition is now showing the correct size, ie: 1 GB after dd if=/dev/urandom of=/dev/sda7 or dd if=/dev/zero of=/dev/sda7 is run. 

I haven't rebooted yet (I have a lot of apps I don't want to close yet and the laptop is temporarily serving some web sites). So I don't know if that will fix things, but I also modified the swapon start up script so it encrypts the swap partitions with cryptsetup, so I may not be able to diagnose the problem by rebooting unless I change everything back.
--------------------

Any ideas for what I can do without rebooting would be appreciated, why is swapon failing with no error messages in /var/log/messages? (or kern.log)
Any help is appreciated.
Diane.

--------------------
I tried fdisk -l and cfdisk
both were segfaulting yesterday, but cfdisk /dev/sda just gave me this:
GNU cfdisk 1.0

                           ATA Hitachi HTS54161
 Disk: /dev/sda   Disk type: msdos    Size: 160041885695B, 160042MB
                Heads: 255   Sectors per track: 63   Cylinders: 19457

   Number   Flags      Part Type   Filesystem        Label              Size
 ------------------------------------------------------------------------------------------
                       None        Free space                                        1.02MB
      1                Primary     ntfs                                                  1573MB
      2     Bootable   Primary     ntfs                                          75000MB
                       None        Free space                                         3.44MB
      3                Primary     reiserfs                                          28994MB
      4                Extended                                                         53497MB
      5                Logical     reiserfs                                            24997MB
      6                Logical     linux-swap                                         1003MB
      7                Logical     linux-swap                                         1003MB
      8                Logical     [Linux]                                              17997MB
      9                Logical     fat32                                                   8497MB
                       None        Free space                                            971MB
------------------------------------------------------------------------------------------
fdisk is still segfaulting:
# fdisk -l /dev/sda

Disk /dev/sda: 160 GB, 160039272960 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
Segmentation fault

---------------------------
Debian Etch,
2.6.22-4-amd64 #1 SMP Tue Feb 12 10:29:27 UTC 2008 x86_64 GNU/Linux
Toshiba A215-S7422 laptop
---------------------------

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/sda1       /vistaback      ntfs                    0       0
/dev/sda2       /vista          ntfs                    0       0
/dev/sda3       /               reiserfs notail,noatime  0       1
/dev/sda9       /fat32windows   vfat    defaults        0       0
/dev/sda5       /home           reiserfs notail,noatime  0       2
/dev/sda6       none            swap    sw              0       0
/dev/sda7       none            swap    sw              0       0
/dev/hda        /media/cdrom0   udf,iso9660 user,noauto     0       0
/swapfile0      swap            swap    defaults        0       0
----------------------------
# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda6                               partition       979924  711140  -1
/swapfile0                              file            1048568 0       -4
------------------------------------------------------------------------------
# free
             total       used       free     shared    buffers     cached
Mem:        899024     888660      10364          0      53996     138940
-/+ buffers/cache:     695724     203300
Swap:      2028492     711140    1317352


Any other info needed?

Reply to: