The following is what parted print outputs:

(parted) print                                                            

Model: VMware Virtual disk (scsi)
Disk /dev/sda: 26.8GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  271MB   271MB   primary  ext2         boot 
 2      271MB   1349MB  1078MB  primary  linux-swap        
 3      1349MB  26.8GB  25.5GB  primary               lvm  

The volume group created on /dev/sda3 looks like the following:

  --- Volume group ---
  VG Name               rootvg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                7
  Open LV               7
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               23.62 GB
  PE Size               128.00 MB
  Total PE              189
  Alloc PE / Size       162 / 20.25 GB
  Free  PE / Size       27 / 3.38 GB
  VG UUID               1Wzcpj-bNMD-cIYr-pOwA-1jdP-f9wE-wiEitV

That means there is 3.38GB unused space.

I want to resize my swap partition /dev/sda2 to use 1GB out of the above space. How can I achieve that?

link|improve this question

80% accept rate
feedback

2 Answers

up vote 2 down vote accepted

Just go ahead and use GParted.

No real reason to muck about on the CLI when you could achieve the same thing faster with a GUI.


If you're forced to use a CLI, then you should check out cfdisk. It's a little nicer program for partition editing.

link|improve this answer
Just figured that installing Gparted is a bit difficult. – ring bearer Jun 8 '11 at 19:33
@ring How so? What distro are you running? – new123456 Jun 9 '11 at 18:39
RHEL 5.3 can't pull it through yum – ring bearer Jun 10 '11 at 13:50
feedback

If you want to do this online, you could add a new swap partition of 1 GB. It can be done with 'lvcreate', 'fdisk', 'mkswap' and 'swapon'.

If you do not want 2 swaps fs, you could create a new 2 GB swap, disable the old swap with 'swapoff' and delete the old lv.

More info here.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.