swap file

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

swap file

Postby Bunz_of_Steel on Sat Feb 23, 2013 11:38 am

I have fresh install Mint 14 with 32G ram and OCZ Vertex 4 SSD(256G), 2TB HDD.
Looking to optimize my system and considering moving swap to HDD not SSD. Gathering not good idea to swapoff -a right? Just not sure how to move swap file. Guessing something like turnswap off and then add it using mkswap? I have used Linux before but I'm no expert either. Would appreciate a little hand holding here as I'm not sure what the steps are or if I am going down the wrong path. Any advice or insight appreciated, thx!


# swapoff /dev/device
Bunz_of_Steel
Level 1
Level 1
 
Posts: 3
Joined: Sat Feb 25, 2012 2:36 am

Linux Mint is funded by ads and donations.
 

Re: swap file

Postby xenopeek on Sat Feb 23, 2013 1:07 pm

First check, do you use swap? With 32 GiB RAM I'd figure the only reason to have swap is so you can hibernate (suspend to disk), if you don't do that you don't need swap at all.

You can easily configure swap not to be used, by editing your /etc/fstab line and commenting out (putting a # in front of) the line for your swap. That disables swap upon reboot. You can indeed disable swap temporarily with swapoff -a. But I'm guessing you have a swap partition, and you want to reclaim the space currently used for swap on your SSD to one of your other partitions there. You can not do that while booted in to your current Linux Mint installation (you can't resize a partition you are using).

So, the steps are:
  1. Edit your /etc/fstab file and comment out the line that has swap on it. To edit this file, run the command:
    Code: Select all
    gksudo gedit /etc/fstab

    The line you want to comment out (by insert a # as the first character of that line) would look similar to:
    Code: Select all
    UUID=cbfe9ae2-e86e-4d3e-89f8-db639633723a   swap    swap   sw   0   0
  2. After saving that file, reboot your computer and boot from your Linux Mint installation ISO. Start GParted from there.
  3. Using GParted, you can delete the swap partition on your SSD. Then resize an existing partition either right before or right after the swap partition, to absorb the freed up disk space. Apply all changes and next step.
  4. Switch GParted to work on your second hard disk, and resize and existing partition there to make room for a swap partition if there isn't free disk space enough. Then create a new partition as type Linux swap. Apply all changes and next step.
  5. Reboot your computer and log in to your current Linux Mint installation.
  6. Run the following command, and copy the UUID value of your swap partition you just created:
    Code: Select all
    sudo blkid
  7. Edit your /etc/fstab file again, uncomment (remove the # from in front of the line) the line you commented out earlier and replace the current UUID value on that line with the one from your command. Save and close the file, then run the following command to enable swap now:
    Code: Select all
    sudo swapon -a
If you get into trouble with GParted, or not sure how to proceed, please share a screenshot so we can see what you see.
Forum Rules | IRC Channel Rules
Image
Arch Linux / 64-bit / Gnome Shell
User avatar
xenopeek
Level 21
Level 21
 
Posts: 13708
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: swap file

Postby bigj231 on Sat Feb 23, 2013 2:14 pm

I agree with xenopeek. You won't need swap with 32GB of RAM. I never suspend to disk, and I don't use more than 4GB of my 6GB, so I don't even have swap on my laptop SSD. If you want to suspend to disk, then make your swap on the HDD, and set the swapiness to something like 5.
Code: Select all
echo "vm/swappiness=5" >> /etc/sysctl.conf

Do that after you finished xenopeek's guide though.
Running on a 4-slot toaster @ 60Hz
User avatar
bigj231
Level 5
Level 5
 
Posts: 793
Joined: Fri Feb 26, 2010 10:16 am
Location: Middle of Nowhere

Re: swap file

Postby catweazel on Sat Feb 23, 2013 6:26 pm

Bunz_of_Steel wrote:I have fresh install Mint 14 with 32G ram and OCZ Vertex 4 SSD(256G), 2TB HDD.
Looking to optimize my system and considering moving swap to HDD not SSD.

Some tips to keep your SSD alive a lot longer...

Turn off ext4 journalling
When installing Mint, before running the installer, open a terminal and turn off journalling, and set the fs to be checked at regular intervals:
Code: Select all
$ sudo mke2fs -t ext4 -O ^has_journal /dev/sda1
$ sudo tune2fs -o journal_data_writeback /dev/sda1
$ sudo tune2fs -m 5 /dev/sda1
$ sudo tune2fs /dev/sda1 -i 7d
$ sudo tune2fs /dev/sda1 -c 15
$ sudo tune2fs -l /dev/sda1

Then run the installer and choose to install to the SSD with / as the mount point, but don't format it. The installer will give you a warning that can be ignored.

When the install is completed, reboot and edit etc/fstab. Change the / mount point options to:
Code: Select all
data=writeback,noatime,discard

Making use of RAM
While you're editing fstab, mount tmp and logs into RAM so they get deleted on every reboot or shutdown:

Code: Select all
tmpfs        /tmp        tmpfs   noatime,nodev,nosuid,noexec,mode=1777   0       0
tmpfs        /var/log    tmpfs   defaults,noatime,mode=0755              0       0

If you use firefox, set it to use memory as for its cache:

Code: Select all
about:config

Add a new string key named:
Code: Select all
browser.cache.disk.parent_directory

set its value to:
Code: Select all
/tmp

The other tips you've received to set swapiness and not have a swap partition can also be applied. However in xenopeeks example, he's using the fact that you've already created the swap partition. Simply don't create one during the next installation you do. That way you don't have to later delete the partition or comment out the entry in fstab. If you get a warning about no swap during the installation, simply ignore it.

When you've added /tmp and /var/logs to fstab, don't use mount -a. You need to delete the contents of /var/log as root then reboot. If you don't do this then /var/log won't mount.

Also, see this thread http://forums.linuxmint.com/viewtopic.php?f=47&t=126397, and read the wiki at the link.
Mint Testing Team & Mint Donor #3606
KDE 4.12.0, custom preemptive kernel 3.12.5,
Intel i7 4770K @ 4.7GHz, 16GB 2666MHz XMP,
4 Samsung 840 PRO 512GB SSDs in RAID0,
6TB HW RAID10, dual 24" Acer X243H,
Gigabyte nVidia GTX 680 Super Overclock
User avatar
catweazel
Level 7
Level 7
 
Posts: 1656
Joined: Fri Oct 12, 2012 9:44 pm

Re: swap file

Postby Bunz_of_Steel on Sun Feb 24, 2013 1:53 am

Thank all for quick responses and advice is right on! I went with a new install as this install is about a day old only and nothing vital on it. Following along with TehGhodTrole and ran the commands to turn off ext4 journaling. Chose to install to / and did NOT format. Did have like two warning that I chose to ignore. Below is a copy of my fstab

cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=522567a9-0f7d-475c-b495-661dc5569599 / ext4 errors=remount-ro 0 1


I believe my next step is to change the /mount point options so I need to add line below to fstab?
/dev/sda1 / ext4 data=writeback,noatime,discard
Bunz_of_Steel
Level 1
Level 1
 
Posts: 3
Joined: Sat Feb 25, 2012 2:36 am

Re: swap file

Postby catweazel on Sun Feb 24, 2013 1:56 am

Bunz_of_Steel wrote:I believe my next step is to change the /mount point options so I need to add line below to fstab?
/dev/sda1 / ext4 data=writeback,noatime,discard

Yes, and well done, btw. Oops. Don't forget the 0 1 at the end. Your fstab line should look like this:
Code: Select all
UUID=522567a9-0f7d-475c-b495-661dc5569599 / ext4  data=writeback,noatime,discard 0 1

You can add the two tmpfs lines I gave you above exactly as they are.

writeback changes the data order. noatime stops the file system from date/timestamping files, and discard controls the SSDs TRIM to fill empty space in the background.
Mint Testing Team & Mint Donor #3606
KDE 4.12.0, custom preemptive kernel 3.12.5,
Intel i7 4770K @ 4.7GHz, 16GB 2666MHz XMP,
4 Samsung 840 PRO 512GB SSDs in RAID0,
6TB HW RAID10, dual 24" Acer X243H,
Gigabyte nVidia GTX 680 Super Overclock
User avatar
catweazel
Level 7
Level 7
 
Posts: 1656
Joined: Fri Oct 12, 2012 9:44 pm

Re: swap file

Postby Bunz_of_Steel on Sun Feb 24, 2013 2:30 am

Done deal-O here now. I added the tmp and logs into ram running fine and no kernal panics :). Thanks for the advice all, really appreciate the expertise. To think folks pay for help like this for M$ and don't get near the accurate or timeliness :P Next step to start looking at the TRIM & scheduler as I think they have an affect on SSD longevity.
Bunz_of_Steel
Level 1
Level 1
 
Posts: 3
Joined: Sat Feb 25, 2012 2:36 am

Re: swap file

Postby catweazel on Sun Feb 24, 2013 2:39 am

Bunz_of_Steel wrote:Thanks for the advice all, really appreciate the expertise.

You're welcome. Funny nic, btw.
Mint Testing Team & Mint Donor #3606
KDE 4.12.0, custom preemptive kernel 3.12.5,
Intel i7 4770K @ 4.7GHz, 16GB 2666MHz XMP,
4 Samsung 840 PRO 512GB SSDs in RAID0,
6TB HW RAID10, dual 24" Acer X243H,
Gigabyte nVidia GTX 680 Super Overclock
User avatar
catweazel
Level 7
Level 7
 
Posts: 1656
Joined: Fri Oct 12, 2012 9:44 pm

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: congamike and 25 guests