Powered by Blogger.

Wednesday, June 14, 2017

Tag: , ,

Share SWAP Partition on dual boot different Linux

SWAP parter of RAM


In Linux operating system the most common system partitions are 'root' partition and 'swap' partition. This 'swap' partition is like a misty for new Linux users. First of all there will be questions that how much of space is needed for 'swap' partition, is it really necessary, what benefit will be provided etc. But for now we will be discuss how to use single swap on multiple Linux system.

First things first, at beginning check your 'swap' is working or not. For that use 'free' command on terminal.[see on image<check swap>]. If 'Total' of 'Swap' is not 0 then you have working 'swap' partition. If not than your swap is not working.
Check Swap is working or not


I want to clear something now. If you did not create different swap for different Linux OS and selected same partition over and over then your latest install OS will have the working swap. For other OS's system cannot find the 'swap' partition because you change the UUID every time you install another OS.
Now, if you find 'Total' of 'Swap' with 'free' command for every OS you installed, then either you deleted 'swap' partition after install system or UUID is changed. This is no Problem. You just have to do an extra step. If you have a working 'swap' on any OS, boot into that system and go to step 2.

Step 1: Make a swap
Open your terminal. Type 'sudo fdisk -l'. This will show all the partitions the device has. You can use 'sudo fdisk -l | grep swap' to show only swap partition information.  Write down the partition Name/Device listed with swap. Example- '/dev/sda6' [see on image<swap info>].

swap info


Now Type this command on terminal 'sudo mkswap /devs/da6' It will make the swap partition usable and give you a UUID. Write down the UUID.

For make the swap working for the system, we need to change the fstab file. So, type 'sudo nano /etc/fstab'. Here you will see your corresponding system partitions. If there is any line like this 'UUID=842b4ddb-ee76-4e21-b3f3-8a2480144168 none            swap    sw              0       0', just change the UUID with your swap partition's written UUID. If there is no line with swap then
create a line at the end like way before.[No need to change other informations. Just the UUID]. [see on image <add swap>].

add swap



Save the file by pressing Ctrl+O and Enter. Now press Ctrl+X. Reboot the system and check if 'swap' is working or not by 'free' command.



Step 2: Use the swap for other system
At this point I'll assume that you have a working 'swap' partition for any OS and you booted into that OS.

There is two way to add the 'swap' partition on other OS. One is to boot on every OS and change the 'fstab' file. Second way is by changing 'fstab' file from current OS. I'll vote for second one. It is tricky but easy and no need to boot different time. I'll show second method.

Suppose, You have three OS - Ubuntu, Mint, Debian. Working 'swap' is with Ubuntu and you booted into Ubuntu. Type the command on terminal, 'sudo nano /etc/fstab', Copy the whole line with type 'swap'. Example, 'UUID=842b4ddb-ee76-4e21-b3f3-8a2480144168 none            swap    sw              0       0'. You can open a new document and save it for later use.

Now mount you other OS's drive by simply clicking on drive like '40 GB Volume'. This drive should mount on either /mnt or /media/user. Find where mounted and go there. Open terminal here and execute this command 'sudo nano /etc/fstab'. If there is any line contain swap type then delete it and paste the copied line. Save and exit by pressing Ctrl+O & Enter & Ctrl+X.

Do this for other OS.

Boot into other OS's and check if 'swap' is working or not by 'free' command.



Thank You for reading. I am open for any suggestion.

About Jahirul Islam

Hi, My Name is Jahirul Islam...

0 comments:

Post a Comment