Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
1  
sorry pal, windows is not that clever/flexible. it uses paging, and creates files on disks, and uses them as swap, in a sense. –  Mahesh Jun 17 '12 at 14:26

4 Answers 4

up vote 10 down vote accepted

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.
share|improve this answer
    
Or use a file as swap on that partition. –  lgarzo Jun 17 '12 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 :) –  izx Jun 17 '12 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 '12 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! –  izx Jun 17 '12 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. –  Dan Dascalescu Dec 30 '12 at 3:56

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.
share|improve this answer

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).

share|improve this answer

The short answer is: No, it cannot.

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

share|improve this answer
1  
there is nothing as a linux partition. You need to talk of file systems. ext3/4, NTFS, FAT16/32, etc. –  Mahesh Jun 17 '12 at 14:31
    
true, just wanted to keep it at a low technical level –  leousa Jun 17 '12 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. –  izx Jun 17 '12 at 14:36
    
my bad, you are right. thanks @izx and you did recollect/remember correctly. ;) –  Mahesh Jun 17 '12 at 14:52
1  
The more complicated answer is that it has been be done. –  Dan Dascalescu Dec 30 '12 at 3:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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