Skip to content

Instantly share code, notes, and snippets.

@25b3nk
Last active February 12, 2019 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 25b3nk/6b38ce3ce2a5cfd1a2756b56e13bc1cb to your computer and use it in GitHub Desktop.
Save 25b3nk/6b38ce3ce2a5cfd1a2756b56e13bc1cb to your computer and use it in GitHub Desktop.
Mounting new SSD and creating swap

Creating the disk

$ sudo fdisk /dev/sda

After the above step you will get output which requires user inputs

Follow this link for more help: Link

$ sudo mkfs -t ext4 /dev/sda1
$ sudo mount /dev/sda1 /media/SSD_120/
$ sudo blkid | grep /dev/sda1 # To get the UUID of the disk

Edit the fstab file to mount this permanently

$ sudo vi /etc/fstab

Add UUID and other details at the end of file to make the mount permanent

Ex: UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e /media/SSD_120 ext4 defaults,nofail 1 2

Creating swap area

$ sudo fallocate -l 8G /media/SSD_120/swapfile  # Create swap file for 8GB
$ sudo chmod 600 /media/SSD_120/swapfile  # Permissions

Make the swap file into swap area

$ sudo mkswap /media/SSD_120/swapfile
$ sudo swapon /media/SSD_120/swapfile

Edit the fstab file to add this permanently

$ sudo vi /etc/fstab

Add the following line

/media/SSD_120/swapfile swap swap defaults 0 0

Reboot

$ sudo reboot now

Links used:

  1. Attaching new disk
  2. Creating swap area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment