Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: adding swap partition after install

  1. #1
    Join Date
    Apr 2010
    Beans
    210

    adding swap partition after install

    I made a mistake and didn't add a swap partition when I installed. When I do it from a live cd, is there anything else that I will need to do to get ubuntu to know that it has a swap to use? or will it just autodetect?

    thanks for the help
    beelzebufo

  2. #2
    Join Date
    Apr 2007
    Location
    Out in Left Field
    Beans
    1,086
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: adding swap partition after install

    You can create a Swap partition in GParted . You need to specify the file type when use use the format command as linux-swap

    https://help.ubuntu.com/community/SwapFaq
    Last edited by SuperFreak; February 20th, 2014 at 04:16 AM.
    MB: Asrock Extreme4-M CPU: Intel(R) Core(TM) i7-3770K CPU @3.50GHz Memory: Corsair Low Profile Vengeance 16.00 GB. GC On CPU HD4000 Platform: x86_64 Distribution: Dual Boot -Ubuntu 16.04 Xenial Xerus with Cinnamon DE and Linux Mint 18 Sarah Cinnamon

  3. #3
    Join Date
    Feb 2008
    Location
    Funky Town, AUS
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: adding swap partition after install

    It is actually as easy as creating a /swap partition with Gparted (or using the Live install media) and then adding it to your /etc/fstab.

    1/ Create the partition, right click it and 'swapon' so it is active;

    2/ Open a terminal and:

    Code:
    sudo blkid
    There, you should see an entry something like this, probably last line. The important part is it ends with "swap"

    Code:
    /dev/zram0: UUID="e197b72d-b267-4572-82f2-1c259f4ab79c" TYPE="swap"
    Take note of the UUID number (in bold above, yours will be different). Now, open the /etc/fstab file:
    Code:
    sudo nano /etc/fstab
    ... and add this at the very end:

    Code:
    UUID=e197b72d-b267-4572-82f2-1c259f4ab79c       none    swap    sw      0       0
    ... replacing the UUID with the UUID number you found for "swap" in the 'sudo blkid' command. But the number ONLY. Don't included the " at either end like 'sudo blkid' output does.

    Reboot and you have a swap partition. 2Gb /swap is fine or same as your installed RAM if you hibernate. Good luck.
    Last edited by Bucky Ball; February 20th, 2014 at 06:49 AM.

  4. #4
    Join Date
    Aug 2013
    Beans
    3,100

    Re: adding swap partition after install

    Aside from fstab there is another file you should check.
    Code:
    gksudo gedit /etc/initramfs-tools/conf.d/resume
    It may be empty or in it there is a single line like "RESUME=UUID=XXXXXXXX"
    make sure the xxxxxx matches the uuid for swap in fstab and blkid, if it already has something but doesn't match the uuid in fstab swap will not be on after reboot.
    Last edited by monkeybrain20122; February 20th, 2014 at 05:33 AM.

  5. #5
    Join Date
    Apr 2010
    Beans
    210

    Re: adding swap partition after install

    great, thank you all so much, getting the project started right now, hopefully all will end well, although I am prepared for a long, arduous journey.

  6. #6
    Join Date
    Feb 2008
    Location
    Funky Town, AUS
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: adding swap partition after install

    I did this not less that a week ago (moved the /swap to another drive entirely, actually) and didn't take long at all. Follow those instructions I gave and shouldn't take you too long either.

    PS: Before tweaking your /etc/fstab file, might be an idea to back it up:

    Code:
    sudo cp /etc/fstab /etc/fstab.backup
    To copy back the original if things go pear-shaped:

    Code:
    sudo mv /etc/fstab.backup /etc/fstab
    Should have mentioned that earlier, sorry.
    Last edited by Bucky Ball; February 20th, 2014 at 06:51 AM.

  7. #7
    Join Date
    Apr 2010
    Beans
    210

    Re: adding swap partition after install

    thank you so much bucky ball and monkybrain, however, I did what both of you said, and after a reboot, my open system monitor is saying 0.0 kb swap, not sure what went wrong, but I followed both of your statements to a tee, using my own output from "sudo blkid" I don't have much load on my system as I test now, but it seems like my swap should have some load on it even as it sits idle... The reason I am so concerned is that I know that linux needs swap to function properly, I have run into this problem before. Anyway, any new ideas would be greatly appreciated.

    thanks again
    beelze

  8. #8
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: adding swap partition after install

    Please post the output of the command

    Code:
    swapon -s

  9. #9
    Join Date
    Apr 2010
    Beans
    210

    Re: adding swap partition after install

    here ya go, looks like it recognizes the swap, but it's not being used, maybe I am just being paranoid.

    Code:
    wreckingball@wreckingball-pc:~$ swapon -s Filename                Type        Size    Used    Priority
    /dev/mapper/cryptswap1                  partition    8103932    0    -1
    the code didn't go right, but you can see that the partition is 810k and used is 0.. not sure what's a happinin.
    Last edited by beelzebufo; February 20th, 2014 at 11:39 AM.

  10. #10
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: adding swap partition after install

    You have 8 GB cryptswap but don't use any of it (yet)

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •