You are not logged in.
Pages: 1
I have been unable to procure information on a swap file. I assume its stored on /root? Is there a way to encrypt the swap partition so I can have suspend and hibernate support? If not, can i resume from swapfile on encrypted partition? Help appreciated
Last edited by duke11235 (2009-10-23 00:04:02)
Offline
The swapfile is an extra partition. Take a look at your /etc/fstab.
Offline
I never heard of someone using a swap file on Linux. I don't think it's possible, and it certainly doesn't sound like a good idea. Do you mean swap partition by any chance?
Good ideas do not need lots of lies told about them in order to gain public acceptance.
Offline
You can dedicate a file for swap use. See man mkswap.
But you need to be very careful!
To know or not to know ...
... the questions remain forever.
Offline
I've been using swapfiles ever since using Linux, no problem at all.
For best performance you should create it right after creating the filesystem.
As long as the file doesn't get fragmented it shouldn't be different from using a swap partition.
Example:
dd if=/dev/zero of=/swapfile bs=1M count=512
fstab entry:
/swapfile swap swap defaults 0 0
Last edited by byte (2009-10-23 09:00:40)
1000
Offline
Thanks for the info. I was under the impression that swap had to be on a primary partition. Not sure where that came from.
Good ideas do not need lots of lies told about them in order to gain public acceptance.
Offline
Swap files work just fine but I don't think they can be used for hibernation.
Offline
Tuxonice and possibly uswsusp work with swap files, in-kernel hibernation doesn't.
Last edited by lucke (2009-10-23 09:37:15)
Offline
As long as the file doesn't get fragmented it shouldn't be different from using a swap partition.
I had a swap partition when I first used linux. As I got more memory and realised it didn't get used I changed to a swap file for a bit, then didn't bother.
http://bbs.archlinux.org/viewtopic.php? … 54#p212254
Using a fragmented swapfile should be slower going in and out of hibernate. Is swap needed at all going in and out of suspend? While in use, I can't see how a fragmented swap file would be any slower than a swap partition as disk reads are being done all over the place. In fact if you have a separate swap partition but are accessing other partitions then a swap partition is forcing disk heads to move out of the /root partition (or other partitions you are using anyway) so a swap file will probably be faster.
Offline
Tuxonice and possibly uswsusp work with swap files, in-kernel hibernation doesn't.
Maybe with this tutorial it also works with kernel hibernation
http://ubuntuforums.org/showthread.php?t=1042946
Last edited by miau (2009-10-23 11:10:53)
Offline
This is nice but I m still wondering if encrypting a swap partition with a fixed key stored in /etc on an encrypted root partition will solve my problem just as well. Where would a swapfile be stored? On /root? The advantage for the swap file was having it inside a encrypted partition.
Offline
This is nice but I m still wondering if encrypting a swap partition with a fixed key stored in /etc on an encrypted root partition will solve my problem just as well. Where would a swapfile be stored? On /root? The advantage for the swap file was having it inside a encrypted partition.
You can put the swap file anywhere you like.
Offline
On the Arch wiki here
http://wiki.archlinux.org/index.php/Sys … r_dm-crypt
It says I can create a swap partition with a fixed key in /etc
dd if=/dev/urandom bs=1 count=512 of=/etc/keys/swap.key
But then it says it stored it in the unencrypted boot image.
Then create the hook setup in /lib/initcpio/install containing (THIS APPEARS TO BE DANGEROUS AND INSECURE SINCE IT INCLUDES THE KEY IN THE UNENCRYPTED BOOT IMAGE, DON'T DO IT, GET THE KEY FROM SOMEWHERE ELSE!):
# vim: set ft=sh:
install ()
{
MODULES=""
BINARIES=""
add_file "/etc/keys/swap.key"
FILES=""
SCRIPT="openswap"
}
help ()
{
cat<<HELPEOF
This opens the swap encrypted partition /dev/<device> in /dev/mapper/swapDevice
HELPEOF
}
Is this true, or is it only secured it /etc?
Last edited by duke11235 (2009-10-24 01:50:48)
Offline
Hello,
I am trying to make hybernate work with a swap-file as in the Ubuntu-guide.
However, I need the first sector. It appears that filefrag does not output this anymore?!
Here is a sample output:
╰─[13:05:47]> sudo filefrag -v /swap
Password:
Filesystem type is: 3153464a
File size of /swap is 541065216 (132096 blocks, blocksize 4096)
Discontinuity: Block 25 is at 8231 (was 8230)
...
/swap: 241 extents found
Also, can I somehow make a continuous swap-file, i.e. a non-fragged swap file?
Thanks,
Rasmus
Arch x64 on Thinkpad X200s/W530
Offline
I know how to create a contiguos logical volume in a lvm group......
lvcreate -C y -L 4G archvol -n lvolswap
Offline
I know this is redundant, but still. The sheer confidence in some of those replies is flabbergasting - all the more because they're either blatantly wrong or testimony of horrible desinformation.
The swapfile is an extra partition. Take a look at your /etc/fstab.
No, you see - a swap partition is a partition. A swap file is, well, a file!
Isn't Linux full of surprises?
I never heard of someone using a swap file on Linux. I don't think it's possible, and it certainly doesn't sound like a good idea. Do you mean swap partition by any chance?
Do you know how long the belief that earth was flat held firm? Check the mkswap manual, and turn yourself into a believer .
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Can someone tell me if this stores it in the unencrypted boot image, i thought it was in /etc. It's the last barrier to continuing arch install
hen create the hook setup in /lib/initcpio/install containing (THIS APPEARS TO BE DANGEROUS AND INSECURE SINCE IT INCLUDES THE KEY IN THE UNENCRYPTED BOOT IMAGE, DON'T DO IT, GET THE KEY FROM SOMEWHERE ELSE!):
# vim: set ft=sh:
install ()
{
MODULES=""
BINARIES=""
add_file "/etc/keys/swap.key"
FILES=""
SCRIPT="openswap"
}
help ()
{
cat<<HELPEOF
This opens the swap encrypted partition /dev/<device> in /dev/mapper/swapDevice
HELPEOF
}
Offline
The benefit of a swap file is more dynamic resizing... the benefit of a swap partition is less fragmentation, which is important when talking about swap. Both less fragmentation for your swap and for the partition your swapfile would be stored on.
Offline
Pages: 1