1

i Use this command in CentOS to create a 4Gb swap file but is uses all disk space!!

dd if=/dev/zero of=/swapfile bs=1024 count=4G

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       20511356 20386444         0 100% /
tmpfs             255388        0    255388   0% /dev/shm

How can fix this?.

Regards

1
  • 1
    If you think that command will only allocate 512MB for the swapfile, you are badly mistaken. In fact you asked it to write 4TB to the swapfile.
    – kasperd
    Apr 28, 2016 at 18:54

3 Answers 3

0

Use rm command:

rm -f /swapfile

rm man page

and then create a smaller swap file:

dd if=/dev/zero of=/swapfile bs=1024 count=4000000
1
  • And if you did swapon /swapfile, then remember to run swapoff /swapfile before you delete it.
    – kasperd
    Apr 28, 2016 at 18:58
3

you created (or tried to create) a 4Tb file so delete it and create a 4Gb file:

rm /swapfile
dd if=/dev/zero of=/swapfile bs=1024 count=4000000

good luck!

0
0

rm /swapfile and create a smaller one?

1
  • Thanks Bob: -bash: Delete: command not found
    – Enecumene
    Apr 28, 2016 at 15:02

You must log in to answer this question.

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