Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-15-2007, 08:27 PM
|
#1
|
LQ Newbie
Registered: Oct 2007
Posts: 6
Rep:
|
swap file instead of swap disk "dd" error
Hi all,
I recently just got finished with a Triple boot install on my MacBook of 10.5, 4.0r1 (etch), and XP SP2. Everything (almost) went alright with all my installs, even got thru the wireless on the MacBook using the madwifi under one battery charge.
The problem I am having though, is with this particular setup I am unable to have a swap partition for Linux. So I had to use the instructions I found for creating a swapfile instead of using a swap disk (partition). What happened though is when I used the "dd if=/dev/zero of=/swap bs=1024 count=1048576", I substituted 1024 and 1048576 with 3072 and 3145728 respectively because I have 3 GB of RAM installed and issued the command and then it kinda took a long time instead of returning a prompt. I knew it kinda would take a little time so I waited then I couldn't take it I ^c'ed and canceled out. But then the system told me the process did 7.8 GB of transfer or something (as I recall). So I checked the swap file in / to see how big it was. It wasn't any bigger than normal, but unfortunately out of a 20 GB partition for install all that remained was 9.2 or so GBs. Which is like 7.8 GB for some file (possible swap size, but like I said whe I did ls it didn't size up right) and 3.0 GB for the Linux install.
My question is how can I get this damn swap file removed and create a swapfile the proper size. Can I rename the swap file "swapfile.old" then create a new swap file (but need help with that cause the dd command never quits) then use:
mkswap /swap
swapon /swap
chmod 600 /swap
and then restart then delete the swap.old file?
Thanks for any help I can get...
oh one note, what does the dd command do anyway or stand for... ta
|
|
|
12-15-2007, 10:30 PM
|
#2
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
You can simply delete the first file. Remember that the size is the block size times the count. A 3 GB swap size sounds excessive. You probably only need a large swap if it is used for suspending. 500MB or 1GB should be more than plenty for normal usage.
Read the man page for the dd command. You can use the offset option to only write the last block.
for example:
Code:
dd if=/dev/zero of=testfile bs=256 count=1 seek=$((1024*1024-1))
1+0 records in
1+0 records out
256 bytes (256 B) copied, 6.8723e-05 s, 3.7 MB/s
jschiwal@hpamd64:~> ls -l testfile
-rw-r--r-- 1 jschiwal jschiwal 268435456 Dec 15 21:28 testfile
Simply subtract 1 from your old count value and use it for seek instead, and use a "count=1". The command will be almost instant.
It would only be worthwhile zero'ing out a partition (before installing, when reusing a drive) if you plan to perform an image backup later after the initial install. ( you wouldn't backup swap of course ) Doing so, you can compress the backup through gzip or bzip2 before saving it.
Last edited by jschiwal; 12-15-2007 at 10:37 PM.
|
|
|
12-15-2007, 10:43 PM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,334
|
Mmmm - 3 Gig; why the hell are you worried about swap ???. 9 Gig ???.
Standard x86 Linux won't use anymore than 2 Gig of a swap extent. And it'll quite happily run without swap at all. Delete the file and start again. Try half a Gig unless you hit problems, then just add more.
You are aware this can be a logical partition - doesn't need to be primary.
|
|
|
12-15-2007, 10:57 PM
|
#4
|
Member
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835
Rep:
|
3072 * 3145728 = 9GB, not 3GB
Instead, if you are set on a 3GB swap (very large) instead, use:
dd if=/dev/zero of=/swap bs=1M count=3072
dd moves MBs a lot faster than KBs. This will still take some time, but nowhere near what you spent on it last time.
You can remove the old file immediately (assuming you haven't formatted it as swap, and mounted it) using:
rm /swap
So, just delete the huge file, run the dd command, mkswap, and swapon. Then edit your /etc/fstab file to make it permanent.
|
|
|
12-16-2007, 12:30 AM
|
#5
|
LQ Newbie
Registered: Oct 2007
Posts: 6
Original Poster
Rep:
|
Thanks all of you guys, this completely answered my questions. I thought this was the primary swap, cause I have 1.5 GB ram on a Mac OS X system and the swap size gets to be 12.5 GB, but I guess I am getting confused to how the mac using swap vs how linux does. Cause I thought that if the system was running threads (processes) that the swap would get up there like my mac does. But the statement "You are aware this can be a logical partition - doesn't need to be primary", kinda confuses me a little. Cause this is how I always thought swap worked... nah forget that  , Merry Xmas...
I fixed it the way it should be...
|
|
|
12-16-2007, 01:34 AM
|
#6
|
Member
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835
Rep:
|
Historically on a Windows box swap is done to a file. Historically on a Linux box, swap is done to a dedicated partition. It CAN be done to a file though. On Windows (and presumably on a Mac) the system will automatically adjust the file size to suit need. This is not the case on Linux. If need be, though, you can have more than one swap file, and use swapon and swapoff to enable and disable them.
|
|
|
All times are GMT -5. The time now is 03:38 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|