I created a swap file with root on a running server, using swapfile creation guides which I found on the net (http://blog.serverbuddies.com/adding-additional-swap-space-to-your-linux-server/m Create swap file on a running Linux machine, and http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/)
I made sure that I have plenty of disk space
df -h
showed
[root@host /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md2 1016G 338G 628G 35% /
/dev/md1 496M 116M 356M 25% /boot
/dev/md3 1.7T 169G 1.5T 11% /home
, and after issuing the command
dd if=/dev/zero of=/swapfile bs=1024 count=8290304
The putty terminal became unresponsive, and the server became unresponsive as well (apache and other services crashed, network connections were closed). So, I executed a hardware reset, and everything is back and working fine. I can see the /swapfile
with a zero size, and /var/log/messages
has no info on this event. Is it safe to delete that file and reattempt creating it? Also why would a server crash at all with a dd
command? I had no swap file prior to this config attempt.
UPDATE: Based on symcbean's answer I run the command again with success! The load did go up to 20 while dd was running, so that may have caused issues the last time...
[root@host /]# dd if=/dev/zero of=/swapfile1 bs=1024 count=8290304
8290304+0 records in
8290304+0 records out
8489271296 bytes (8.5 GB) copied, 135.989 s, 62.4 MB/s
Short answer is that writing the swapfile should not have caused the symptoms you describe even if all the space was used up.
There may be something in your logs describing what happenned here. Running an fsck against your root partition might be a good idea.