This discussion is archived
1 Reply Latest reply: Apr 7, 2013 10:01 PM by Dude! RSS

commands to resize swap

GlennD. Newbie
Currently Being Moderated
Hello,
Questions.
1. How can the swap partition be increased [1] . Using oracle linux 6.4, What commands can do this?
2. The partition next to it will need t be shrunk/moved somehow. What commands can do this?

The reason I am asking this is so Oracle Database software 11gr2 can install , it checks the swap size, and the install wont proceed unless swap is set to a minimum limit.
Thanks Glenn

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 9.6G 38G 21% /
tmpfs 1.8G 84K 1.8G 1% /dev/shm
/dev/sda1 485M 124M 336M 27% /boot
/dev/mapper/VolGroup-lv_home
65G 19G 43G 31% /home

[1]
Disk /dev/mapper/VolGroup-lv_swap: 3388 MB, 3388997632 bytes
255 heads, 63 sectors/track, 412 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

# fdisk -l

Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007b80b

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 15567 124521472 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 3388 MB, 3388997632 bytes
255 heads, 63 sectors/track, 412 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_home: 70.4 GB, 70430752768 bytes
255 heads, 63 sectors/track, 8562 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

# uname -a
Linux unknown20cf3028fda2 2.6.32-358.2.1.el6.x86_64 #1 SMP Tue Mar 12 12:10:36 PDT 2013 x86_64 x86_64 x86_64 GNU/Linux
  • 1. Re: commands to resize swap
    Dude! Guru
    Currently Being Moderated
    You cannot reduce an active or open LVM volume without the risk of loosing data. You will need to start the system from DVD into single user mode and perform several actions. It is too complex to explain this from scratch. If you really want to know, I suggest to search for some tutorial on the Internet.

    If this is in an early installation stage, I suggest to reinstall the system. Does your system have less then 4 GB of RAM? In this case you should create a swap partition that is at least 8 GB.

    Alternatively, create and use a swapfile to extend your swap space.
    su - root
    dd if=/dev/zero of=/swapfile bs=1024 count=4M
    chown root:root /swapfile
    chmod 0600 /swapfile
    mkswap /swapfile
    swapon /swapfile
    cp /etc/fstab /etc/fstab.orig
    echo '/swapfile swap swap defaults 0 0' >> /etc/fstab

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points