1

This is my current partition setup:

sda           111.8G
├─sda1 ext4     190M /boot
├─sda2            1K
└─sda5 ext4   111.6G /
sdb           465.8G
└─sdb1 swap    14.9G [SWAP]

Disk /dev/sda: 120GB
Number  Start   End    Size   Type      File system  Flags
 1      1049kB  200MB  199MB  primary   ext4         boot
 2      201MB   120GB  120GB  extended
 5      201MB   120GB  120GB  logical   ext4

Disk /dev/sdb: 500GB
Number  Start   End     Size    Type     File system     Flags
 1      1049kB  16.0GB  16.0GB  primary  linux-swap(v1)

I'd like to move swap from sdb (SATA) to sda (SSD) because I want faster swap. How to delete the existing swap, and how to create a new one on sda - should it be sda3, sda4, or sda6? Would it be safe to resize sda5 where Ubuntu is already installed so that there's enough space for the new swap partition? How do you recommend I do that?

(I'm planning to use a single partition for all of sdb as sdb1 for backups and symlinked storage.)

Thanks.

sTripey
  • 11

2 Answers2

2

Notice to other users: This answer is specific for this particular question (this OP). You have to modify the partitions etc for other cases.


Edit: The solution in this case was to use a swap file instead of a swap partition.


In this case you can treat the SSD just like an HDD (and be prepared to replace the SSD when it fails).

  • Backup the whole SSD (to have a current version, if something would go wrong).

  • Boot a live session from another drive, for example an Ubuntu desktop USB drive.

  • Swapoff all partitions that are used, and unmount the ext4 partition

    sudo swapoff -a
    sudo umount /dev/sda5
    
  • Start gparted and use it to edit the partition table of the SSD (/dev/sda).

  • Shrink the ext4 partition /dev/sda5 to create space for the swap partition. (This might take long time.)

  • Use the unallocated space to create a swap partition.

  • Perform the actions by clicking on the check icon.

  • Start a terminal window

  • Run the following command to find the UUID of the swap partition

    sudo blkid
    

    You probably see something like the following line for your new swap partition

    /dev/sda6: UUID="03bed9e9-e39b-6307-8ce5-c2612af9a6aa" TYPE="swap" PARTUUID="731f415c-05"
    
  • Edit the file fstab of your installed system. Mount the partition where it is first,

    sudo mount /dev/sda5 /mnt
    sudo nano /mnt/etc/fstab
    

    and modify the line pointing to the current swap partition, so that it will point to the new swap partition.

    UUID=03bed9e9-e39b-6307-8ce5-c2612af9a6aa none  swap  sw  0  0
    

    Use the UUID from blkid without quotes.

  • Reboot

I hope I remembered all important steps. Anyway, you can remove the old swap partition now, and use that drive space for data storage.


The following link might help you, if you need help to get started with gparted,

GrowIt.pdf

But in this case you will 'ShrinkIt' ;-)

sudodus
  • 47,684
0

Having swap on a SSD is not recommended as it shortens its lifespan.

Refer to this question for more information.

steeef
  • 129
  • 1
  • 2
  • 11