- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- adding different swap files in one swap file
Operating System - Linux
1820645
Members
1999
Online
109626
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2010 03:15 AM
тАО11-26-2010 03:15 AM
adding different swap files in one swap file
i have /tmpswap1 and /tmpswap2 swap files . i want to have one swap file like /tmpswap.
Can anybody suggest how to do it?
Can anybody suggest how to do it?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2010 09:43 PM
тАО11-26-2010 09:43 PM
Re: adding different swap files in one swap file
Are the swap files already in use? That is, do they appear in the output of
cat /proc/swaps
? I'll assume they do.
Is the amount of free disk space on the root partition larger than the sum of the two swap areas? For simplicity, I'm going to assume it is. For the sake of illustration, I'll assume that the two existing files are 2Gbyte, so you want a single swap area of 4Gbyte.
Create the new swap area and make it available:
dd if=/dev/zero of=/tmpswap bs=1M count=4096
mkswap /tmpswap
swapon /tmpswap
Now remove the two old swap files; it may take a while for the kernel to move pages from the old swap area to the new; I'd probably have "top" running in a separate terminal to watch the progress.
swapoff /tmpswap1 # wait for finish
swapoff /tmpswap2 # wait for finish
Once the swap areas are no longer reported in
cat /proc/swaps
you can delete them
rm /tmpswap[12]
Of course, disk partitions are preferable to files for swap areas. I assume you don't have a partition available. One relatively cheap way to add disk, at least temporarily, is with a thumb USB drive - SSD drives are particularly well suited to the random disk access pattern of a swap area. If you don't have enough space for the new and the old files, such a USB addition may be particularly appropriate, even if temporary: determine the name of the USB drive (e.g., /dev/sdb); partition the USB drive
fdisk /dev/sdb
(read the fdisk manual page); set up the partition as swap
mkswap /dev/sdb1
swapon /dev/sdb1
swapoff /tmpswap1
swapoff /tmpswap2
cat /proc/swaps # old swap files are no longer there
rm /tmpswap[12]
at which point, if you don't want to continue using the USB drive, you can create a new swap file as described above.
cat /proc/swaps
? I'll assume they do.
Is the amount of free disk space on the root partition larger than the sum of the two swap areas? For simplicity, I'm going to assume it is. For the sake of illustration, I'll assume that the two existing files are 2Gbyte, so you want a single swap area of 4Gbyte.
Create the new swap area and make it available:
dd if=/dev/zero of=/tmpswap bs=1M count=4096
mkswap /tmpswap
swapon /tmpswap
Now remove the two old swap files; it may take a while for the kernel to move pages from the old swap area to the new; I'd probably have "top" running in a separate terminal to watch the progress.
swapoff /tmpswap1 # wait for finish
swapoff /tmpswap2 # wait for finish
Once the swap areas are no longer reported in
cat /proc/swaps
you can delete them
rm /tmpswap[12]
Of course, disk partitions are preferable to files for swap areas. I assume you don't have a partition available. One relatively cheap way to add disk, at least temporarily, is with a thumb USB drive - SSD drives are particularly well suited to the random disk access pattern of a swap area. If you don't have enough space for the new and the old files, such a USB addition may be particularly appropriate, even if temporary: determine the name of the USB drive (e.g., /dev/sdb); partition the USB drive
fdisk /dev/sdb
(read the fdisk manual page); set up the partition as swap
mkswap /dev/sdb1
swapon /dev/sdb1
swapoff /tmpswap1
swapoff /tmpswap2
cat /proc/swaps # old swap files are no longer there
rm /tmpswap[12]
at which point, if you don't want to continue using the USB drive, you can create a new swap file as described above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2010 04:07 AM
тАО11-28-2010 04:07 AM
Re: adding different swap files in one swap file
Thanks a lot..
it was really good description assuming many things. it is a good solution but i just wanted to know is there any way to add existing swap files or partitions after swapping them off and them turn the resultant file or partition on ?
Here we are creating new swap file/partition and then removing existing partition.
Is there any way to add existing swap file/partition?
it was really good description assuming many things. it is a good solution but i just wanted to know is there any way to add existing swap files or partitions after swapping them off and them turn the resultant file or partition on ?
Here we are creating new swap file/partition and then removing existing partition.
Is there any way to add existing swap file/partition?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP