14

I am dual booting my system with Ubuntu 12.04 and Windows 7. I have created the special swap partition for Ubuntu while installing (as recommended).

Can Windows use this swap area/partition--as its own swap/page file--when I boot from Windows?

3

6 Answers 6

12

It's possible, but probably only as an experiment:

Note: This is a what-if answer and is not recommended, especially if you are using hibernate from Ubuntu!

  • In theory, yes, Windows should be able to use your swap partition for its page (swap) file with some clever scripting on the Linux side.

  • I'm not going to do a step-by-step because I haven't tried it and if you can't figure out how to implement this you shouldn't be trying it either :)

    1. Format the partition as NTFS from within Windows and set up Windows to use that drive exclusively for its swap file (nothing on C:)

    2. Have a startup/upstart script to format the partition as Linux swap on Ubuntu startup and enable swap (swapon).

    3. Have a shutdown script to swapoff and reformat the partition as ntfs.

Alternative (still not recommended) option:

You can create a swap file by following this guide on the NTFS partition, provided the NTFS partition is large enough for both swap files.

However this alternative is not recommended because:

  • Swapping on an NTFS(3G) partition would be extremely CPU-heavy.
  • And to make things worse, since the file can/will be fragmented, that would also cause a performance hit.
6
  • Or use a file as swap on that partition.
    – lgarzo
    Jun 17, 2012 at 14:59
  • @lgarzo I'm aware of that option but don't recommend it because swapping on an NTFS(3G) partition would be extremely CPU-heavy :)
    – ish
    Jun 17, 2012 at 15:00
  • And to make things worse, since a file can/will be fragmented, that would also cause a performance hit.
    – lgarzo
    Jun 17, 2012 at 15:03
  • @lgarzo Absolutely. Perhaps you could edit my answer to add that although this is another option (provided the ntfs partition is large enough for both swap files) its not recommended either for the reasons we discussed? Thanks!
    – ish
    Jun 17, 2012 at 15:06
  • 1
    This method was used as far back as 2002. As of 2011, Windows 7 is reported to work with the swapfs driver. Dec 30, 2012 at 3:56
2

If your goal is to save hard drive space -- not having to waste many GBs for both Linux's swap and Windows's pagefile, then you might consider using dynamic swapfile size on linux via SwapSpace:

1
1

I haven't tried it myself but you can mount a swap partition with swapfs. You can then, in theory, place your pagefile there (there's some good reasons not to, such as minidumps, but its an option).

1

It works great.

Whats needed? Just follow the instruction in the SwapFs-3.0 file.

Also you could find some helpful stuff at How To use Linux Swap Partition as Windows Swap file on Ubuntuforums.org.

At first I tried to format swap space into NTFS but turned out that Linux lost ability to recognize it as an own created.

Then I reformatted it back to classical Linux swap.

Next I changed back fstab. Was:

UUID=4c6a4... none  swap  sw  0  0

Deactivated that and put instead:

/dev/sda7   swap   swap   defaults   0   0

If I remember well, after I booted into Windows it didn't recognized it as RAW or if I could have formatted it as FAT32.

And everything started working.

But a problem appear. Namely my Vista 'attached' an additional letter, thus at last had two drivers but in fact linked with the same partition 'e:\' and established by me as 's:\'.

Fortunately it was enough to get to the registry to place recommended in *.reg file, from 'SwapFs-3.0'. Turned out that the extra additional record 'e:\' should be removed from registry.

Right now enjoying inter-system swap space without problems. Recovered 3.2 GB space.

I would like to mention that using Linux just 4 three months and be able to do such complicated operations, thus you could do this without any enormous effort.

Recapitulating:

  1. It is possible to share Linux swap partition with Windows and exploit it as space to store Windows swap file.
  2. It is very easy thanks SwapFs-3.0.
  3. Could not tell how much it is CPU-heavy.
  4. The partition is not recognized by "manage" command as mounted as well as Partition Apps do not seen it as mounted.
  5. Explorer sees it as a disk.
  6. Indeed it could save a lot of disk space.
0

Things have changed... There used to be an IFS driver that could read Linux Partitions (primarily for EXT3 at the time) IFS by the way means Installable FileSystem - which may have began in MS-DOS 4 (I previously thought it was an element from OS2 that remained in Windows), there were some interesting things you could do with IFS, like create a RAM Drive, and assign it a drive letter. (these days imdisk is probably a better way of doing that) Along with EXT2IFS (and later ext2fsd) was the ability to access Linux Swap Partitions from within windows. So all you needed to do was use the small drive manager utility that came with the filesystem driver to assign a drive letter to the Swap Partition and tell windows to use that for the I think it was the swapfile.sys file, etc... Nowerdays Windows10 since the Anniversary update require Signed Drivers and most IFS drivers currently do not function at least for me, which, sadly, robs me of access to my EXT2 and HFS+ partition data from within Windows. So the answer has essentially become no longer. But for older Versions (such as Win7 or XP) it's quite plausible to do by the method I stated here.

-1

The short answer is: No, it cannot.

Windows does not recognize Linux partitions, although the opposite is possible (linux recongnizes windows partitions).

5
  • 1
    there is nothing as a linux partition. You need to talk of file systems. ext3/4, NTFS, FAT16/32, etc.
    – Mahesh
    Jun 17, 2012 at 14:31
  • true, just wanted to keep it at a low technical level
    – leousa
    Jun 17, 2012 at 14:35
  • 1
    @Mahesh, Linux and Linux Swap are partition types (0x82 and 0x83, IIRC). Check your fdisk -l. I suppose swap is also its own filesystem.
    – ish
    Jun 17, 2012 at 14:36
  • my bad, you are right. thanks @izx and you did recollect/remember correctly. ;)
    – Mahesh
    Jun 17, 2012 at 14:52
  • 2
    The more complicated answer is that it has been be done. Dec 30, 2012 at 3:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .