LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 08-16-2011, 02:27 PM   #1
g4ur4v
LQ Newbie
 
Registered: Aug 2011
Posts: 1

Rep: Reputation: Disabled
Smile How to create a partition for swap from existing partition


Im pasting my present partition details...


[root@gaurav ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sun Aug 14 23:00:54 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=3175289b-1554-4b5e-a519-066d48075c83 / ext4 defaults 1 1
UUID=4c83f32a-704c-4338-965a-9e5992546723 /home ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
[root@gaurav ~]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
rootfs 7186 4176 2937 59% /
udev 1488 0 1488 0% /dev
tmpfs 1496 3 1493 1% /dev/shm
tmpfs 1496 1 1495 1% /run
/dev/sda5 7186 4176 2937 59% /
tmpfs 1496 0 1496 0% /sys/fs/cgroup
tmpfs 1496 0 1496 0% /media
/dev/sda6 6890 588 5953 9% /home
/dev/sda5 7186 4176 2937 59% /tmp
/dev/sda5 7186 4176 2937 59% /var/tmp
/dev/sda6 6890 588 5953 9% /home
[root@gaurav ~]# fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x98000000

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 307202047 153600000 7 HPFS/NTFS/exFAT
/dev/sda2 307202048 336500735 14649344 5 Extended
/dev/sda3 336500736 409602047 36550656 7 HPFS/NTFS/exFAT
/dev/sda4 409602048 625139711 107768832 7 HPFS/NTFS/exFAT
/dev/sda5 307206144 322160639 7477248 83 Linux
/dev/sda6 322162688 336498687 7168000 83 Linux


.............................................................................
.............................................................................

1)I want to create a new partition for swap out of /dev/sda5 .
2)The new partition thus created should be of around 2GB .(Also i would like to have a separate name for new partition ...eg./dev/sda7)
3)And finally i should be able to use that 2 GB for swap .


(With my small research , i found out that this could be done by using fdisk to create a partition,and then using mkswap,swapon commands..)

Plz guide me through the above procedure....(im new to linux )

I ignored creating a swap space while installing fedora 15 kde 4.6.2...
so plz help..

Last edited by g4ur4v; 08-16-2011 at 02:29 PM.
 
Old 08-16-2011, 03:22 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello g4ur4v, welcome to LQ,

delete the line
Code:
/dev/sda5 7186 4176 2937 59% /tmp
in your /etc/fstab.
then execute
Code:
umount /tmp
then execute the fdisk command
Code:
fdisk /dev/sda
then delete the partition /dev/sda5 (d and then you'll be asked for the paritionnumber).
Afterwards you can within fdisk creat a new partition, n for new partition, the size is made with +2G
be sure to give it the partition-id 82. Create another new partition on the rest of the formerly sda5-partition. Exit fdisk with w. Reboot.
Then edit /etc/fstab again. Insert a line
Code:
/dev/sda?   swap     swap   defaults         0   0
execute "fdisk -l" to check which partitionnumber your new swappartition has.
Execute
Code:
mkswap /dev/sda?
swapon /dev/sda?
be sure to insert the correct number instead of the ?
At next reboot the swappartition will be used automatically.

Note that this all is very dangerous for people who are not experienced with Linux! You may loose all your data when you do something wrong with fdisk.

Markus
 
Old 08-16-2011, 04:02 PM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
I may be reading this wrong but it looks to me like this could be problematic since your / is on sda5.

Quote:
/dev/sda5 7186 4176 2937 59% /
/dev/sda5 7186 4176 2937 59% /tmp
Also, if you delete sda5, sda6 will become sda5
Why not shrink sda6 and create the swap on a new partition, sda7? sda6 is only 9% used while sda5 is 59%.

I would also second the warning by markush that you back up any valuable data before beginning anything as it is very easy to destroy data.

Last edited by yancek; 08-16-2011 at 04:07 PM.
 
1 members found this post helpful.
Old 08-16-2011, 04:06 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
I may be reading this wrong but it looks to me like this could be problematic since your / is on sda5.
That was what I forgot to write the fstab seems to be messed up since there are several partitions with double entries and different mountmpoints.

@g4ur4v: could you please tell us more about your Linux-system? how did you install it? is it new? you may consider a clean installation.

Markus
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to increase the size of existing swap partition ? gautamnarayan Linux - Newbie 5 12-10-2010 11:24 AM
Hard Drive Partition Management - Mandriva Double Partition with Swap File partition moshebagelfresser Linux - Hardware 2 05-23-2008 10:46 AM
Create a partition on existing lvm cghcgh Linux - Enterprise 12 04-14-2008 01:34 AM
changing the size of an existing swap partition toolmania1 Linux - Newbie 5 06-16-2005 07:20 PM
Specify existing swap partition at boot when reinstall? GeirG Linux - General 2 09-11-2004 07:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration