I want to have a look inside the swap partition of an external linux drive.

How can I mount it as a regular file system directory?

I tried mounting it via

mount -o loop,offset=35556433920 -t linux-swap /mnt/GentooBackup/disk.img /mnt/another/

but got

mount: unknown filesystem type 'linux-swap'

what is the proper way so to have look at the page files?


As explained before, the swap partition does not contain a filesystem and does not contain what we would consider files. Additionally, a swap (if active) gets completely wiped at boot, meaning it will be filled with zeros.

So, but how can you look inside a swap partition then? The answer is rather easy, and a disappointing one I fear...if you have started from another system which has not utilized the swap partition (a live system for example) it is possible to simply access the swap partition via it's partition entry in /dev.

To figure that out where the swap partition resides, run fdisk -l as root, this will print the partition tables of all harddisks, like this one:

Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
Units = cylinders of 4032 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hdb1   *         1       196    395104+  83  Linux
/dev/hdb2           197       262    133056   82  Linux swap
/dev/hdb3           263       458    395136   83  Linux
/dev/hdb4           459       621    328608   83  Linux

Here we see that the swap partition is under /dev/hdb2. So, how to read contents from it? With a hex editor, f.e.. If you're just curios you can also dump the contents and run it through strings:

cat /dev/hdb2 | strings

Be warned that this will run your whole swap partition through the strings command, which will print all printable characters it finds...that's most likely lots of it.

| improve this answer | |

You can't because it is not a regular file system. See the answer to this question. There are no actual files inside the swap, it's just a big block of memory.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.