Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

can I resize swap partition?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
adamlogan
Posts: 5
Joined: 2010-01-15 09:22

can I resize swap partition?

#1 Post by adamlogan »

I recently got an ibm thinkpad model t42. I have had a macbook pro (generation 1) for awhile now and have become interested in the FOSS movement, and the countless amazing and incredibly powerful applications available on *nix operating systems. So I've been learning basic cli commands and such. This ibm is basically my first opportunity to really experience the Linux OS, so far I have been checking out various linux distros via virtual box my favorite VM program.

Anyways, to get to the point. I was able to get the Debian testing installer onto my flash drive via virtual box with ubuntu as guest and snow leopard as host. I booted and installed debian testing from the usb onto the ibm two days ago or so. I was unable to do guided partitioning for some reason, so I just did it manually selecting 10 GB for swap lol; I don't know what I was thinking, and the remainder 50 GB for root enabling boot option.

Is there any way I can resize the swap partition without re-installing? It's not a big deal if I have to re-install. I'm only really using this laptop for internet use at the moment. I'm not familiar enough with Linux OS's to have made many changes other than power management and the installation of a few graphics programs via apt-get..

Just looking around on this forum I've already learned a few things. Debian looks like an awesome distro to start out on. Gentoo/Slackware was way over my head. So glad that I checked things out in virtual machines beforehand.
Last edited by adamlogan on 2010-01-17 03:55, edited 1 time in total.

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

Re: can I resize swap partition?

#2 Post by bugsbunny »

Sure - that should be fairly simple. Check the man pages for all these commands to learn more.
First tell the system to stop using all swap partitions.

Code: Select all

# swapoff -a
Now you can easily re-size the partition using gparted. You should find that in System|Administration. (In lenny it may have been under System Tools - I don't remember for sure. And it should be named either "gparted" or possibly "partition manager" (I think I've seen that name used someplace)). If it's not there simply install it using aptitude, or whatever.
Once you've re-sized it turn the swap partitions back on:

Code: Select all

# swapon -a
The other command you may want to get familiar with while we're playing with swap files is: mkswap

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: can I resize swap partition?

#3 Post by nadir »

assuming that he wants to add the freed space of swap to either root- or home-partition, wouldn't it be better to do it from a live-cd?
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

adamlogan
Posts: 5
Joined: 2010-01-15 09:22

Re: can I resize swap partition?

#4 Post by adamlogan »

Yeah, I don't want 10 precious Gigabytes out of a 60 GB hard drive to go to waste. Thanks for mentioning the commands for turning swap on/off. Took a look at the mkswap man page.

Wouldn't fdisk be able to restore swap space to the root partition? Sounds like I'd be better off just re-installing as I don't want to have to use a live cd. Debian installer is still on my usb.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

#5 Post by llivv »

'
Last edited by llivv on 2019-02-20 23:11, edited 1 time in total.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

adamlogan
Posts: 5
Joined: 2010-01-15 09:22

Re: can I resize swap partition?

#6 Post by adamlogan »

Output of df -hlT:
Filesystem Type Size Used Avail Use% Mounted on
/dev/hda1 ext3 46G 5.0G 39G 12% /
tmpfs tmpfs 506M 0 506M 0% /lib/init/rw
udev tmpfs 10M 288K 9.8M 3% /dev
tmpfs tmpfs 506M 0 506M 0% /dev/shm

When I do fdisk -l I get the error "command not found". Tried doing fdisk -l /dev/hda1, same error. Why is fdisk still around if it's so out of date and limited?

User avatar
bluesdog
Posts: 2077
Joined: 2006-02-01 09:02
Location: Similkameen, British Columbia, Canada
Been thanked: 1 time

Re: can I resize swap partition?

#7 Post by bluesdog »

The fdisk command must be issued as root user, or by means of sudo if it's configured
su
password:<root password>
fdisk -l /dev/hda1
Linux fdisk is different from that used in OS X. Try fdisk -l w/o specifying the device, for example.
Tips & Tricks

Something more to read while waiting

If you obviously have not read THIS, don't expect too much...




*winter bluesdog....*

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: can I resize swap partition?

#8 Post by dbbolton »

Once I was dual booting Debian alongside FreeBSD. When I later installed the latter, I let it format and claim my soul swap partition. The next time I booted Debian, I didn't even get a complaint from the system about the disappearing swap partition (I removed it from fstab). I never really missed it either.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
bluesdog
Posts: 2077
Joined: 2006-02-01 09:02
Location: Similkameen, British Columbia, Canada
Been thanked: 1 time

Re: can I resize swap partition?

#9 Post by bluesdog »

my soul swap partition
Dig it, man!

8)
Tips & Tricks

Something more to read while waiting

If you obviously have not read THIS, don't expect too much...




*winter bluesdog....*

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

#10 Post by llivv »

'
Last edited by llivv on 2019-02-20 23:11, edited 1 time in total.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: can I resize swap partition?

#11 Post by dbbolton »

bluesdog wrote:
my soul swap partition
Dig it, man!

8)
As long as my gross language handicaps amuse somebody, I am ok with them 8)

You should watch me type, or even write, if you want real amusement.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

adamlogan
Posts: 5
Joined: 2010-01-15 09:22

Re: can I resize swap partition?

#12 Post by adamlogan »

@ bluesdog
Thanks, I can't believe I didn't think to sudo. Anyways here's the results of df -hlT & fdisk -l. Appended output of fdisk -l to the output of df =). Laughing at myself for being such a noob and feeling a mild sense of accomplishment for something so simple.

Filesystem Type Size Used Avail Use% Mounted on
/dev/hda1 ext3 46G 5.0G 39G 12% /
tmpfs tmpfs 506M 0 506M 0% /lib/init/rw
udev tmpfs 10M 288K 9.8M 3% /dev
tmpfs tmpfs 506M 0 506M 0% /dev/shm

Disk /dev/hda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6a192d5b

Device Boot Start End Blocks Id System
/dev/hda1 * 1 6079 48829536 83 Linux
/dev/hda2 6080 7296 9775552+ 82 Linux swap / Solaris

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: can I resize swap partition?

#13 Post by nadir »

my question above was in fact a question. i don't resize my partitions very often, if so i usually do it from a live-cd.

have you had a look at gparted, like bugsbunny proposed? that should be the most easy way (either from install with swapoff or from a live-cd). its self-explanatory.

just for the fun i tried resizing for a (very few) times with fdisk. its the contrary of self-explanatory and ended in a disaster. of course there would also be cfdisk.

as dbbolton has said: with a not so old pc a swap is pretty unused. i would go for 512, if at all.

to sum it up: check for gparted (or partition manager, or however it is called). its good.
not sure what is wrong about a live-cd, but its your choice.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

adamlogan
Posts: 5
Joined: 2010-01-15 09:22

Re: can I resize swap partition?

#14 Post by adamlogan »

I'm assuming that it would be better doing this from a live cd. I just don't like physical cd media. You can think of it like this, I view cdrs like paper plates, and flash drives/hard drives are like plastic/glass plates respectively. I don't like disposable things, especially in the case of something like linux distros since they update so often. I would love it if I had 1 4gb sized cdrw, but cdrws are always sold in packs which I'm not willing to buy. I do have a single 700mb cdrw though, can probably just use that. Failing that I'll still have the usb installer from before.

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: can I resize swap partition?

#15 Post by nadir »

adamlogan wrote:I'm assuming that it would be better doing this from a live cd. I just don't like physical cd media. You can think of it like this, I view cdrs like paper plates, and flash drives/hard drives are like plastic/glass plates respectively. I don't like disposable things, especially in the case of something like linux distros since they update so often. I would love it if I had 1 4gb sized cdrw, but cdrws are always sold in packs which I'm not willing to buy. I do have a single 700mb cdrw though, can probably just use that. Failing that I'll still have the usb installer from before.
i can understand. dual-boot or usb-stick-install/live would/could be a solution (dual-boot: "repair" one system from the other. thats how i do it). of course there should be more solutions.

btw: i often install test-installs in vbox. if you want to install a simple rescue-system, without environment but, say, fluxbox or icewm, you are fine with 3- max5GB, perhaps even less. With 5 you might even install an environment. that way you still gained about 5GB of the useless swap you got now (+you always got one running system)
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

fsmithred
Posts: 1873
Joined: 2008-01-02 14:52

Re: can I resize swap partition?

#16 Post by fsmithred »

Well, it's Sunday morning here, and I read it differently...
dbbolton wrote: FreeBSD...I let it format and claim my soul
Watch out for that little devil!

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: can I resize swap partition?

#17 Post by dbbolton »

fsmithred wrote:Well, it's Sunday morning here, and I read it differently...
dbbolton wrote: FreeBSD...I let it format and claim my soul
Watch out for that little devil!
And the lulz continue!!
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

Post Reply