Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new swap partition without re-install 1

Status
Not open for further replies.

wmg

Technical User
Sep 13, 2001
216
NZ
Hello tek-tippers!

I'm about to replace the drive that my swap partition is on.

I'm wondering if there is a way to create a new swap partition on the new drive without having to reinstall linux.

If there is, could someone please advise?

regards
wmg
 
Yes, you can do this without reinstalling if the drive that the rest of the linux installation is on will remain in the box. It's even easier if you can leave the old drive in (to use the old swap partition) while you create the new partition.

If you can't leave the old drive in, I would first comment out all references to the old drive that you are removing in /etc/fstab, including the line that mounts the current swap partition.

Then shutdown, remove the old drive, install the newdrive and startup. disclaimer: I have never started linux without a swap partition mounted so i don't know if it will complain when you boot up. I would suggest booting into 'single' mode to minimize the services that you start (and minimize memory usage) while you partition the new drive.

Use cfdisk to partition the drive and create a 'linux swap' partition. note the partition name that the swap will reside on (something like hdb2).

After partitioning, run
> mkswap /dev/hdb2
(or whatever the partition name is) You can use the -c flag with mkswap and it will check the partition for bad blocks first.

Then edit fstab and replace the old partition name with the new /dev/hdb2 and uncomment the line.

then run
> swapon -a

you can do
> cat /proc/meminfo
to check that the new swap partition is recognized.

Good Luck.
jaa
 
Wow! Thanks for that jaa - excellent information. Looks like it won't be that hard either! ;-)

I was actually thinking of unplugging my CD-RW drive and put the new drive on that controller *temporarily* while I configure things like the swap partition - and also copy across the data that's on the old drive.

Once I've done that, I'll unplug the new drive and connect the CD-RW again, remove the old drive and put the new one in it's place, then boot again.

Due to the fact that the drive will change controllers after swap partition creation and beginning to actually use it, that it's designation may change from, say /dev/hdc2 to /dev/hdb2 or something. I'm assuming I can just run a disk tool to see what the designation is once it's in its final place and modify /etc/fstab accordingly - yeah?

BTW, does 'fstab' mean 'file system table'?

Thanks again!!
wmg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top