You are not logged in.

#1 2017-02-19 11:21:56

ayushkhanduri
Member
Registered: 2017-02-19
Posts: 6

issue with the swap space

Hello people , i just installed arch linux in my laptop ,
I had reserved space for my swap partition for about 2 Gb but when the os boots i get an error

[FAILED] failed to activate swap /dev/sda1.
see 'systemctl status dev-sda1.swap' for details
[DEPEND] dependency failed for swap.


systemctl status dev-sda1.swap gives

-----------------------------------------------------------------------------------------------------------------------------------------

* dev-sda1.swap - /dev/sda1
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2017-02-19 16:21:10 IST; 27min ago
     What: /dev/sda1
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

-----------------------------------------------------------------------------------------------------------------------------------------

fdisk -l gives me :

---------------------------------------------------------------------------------------------------
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 99C20066-8D44-4C3B-9666-E6F084A4D329

Device       Start       End   Sectors   Size Type
/dev/sda1     2048   4196351   4194304     2G BIOS boot
/dev/sda2  4196352 976773134 972576783 463.8G Linux filesystem

-------------------------------------------------------------------------------------------------

the fstab file in /etc/fstab has

-------------------------------------------------------------------------------------------------
#
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# UUID=d9b260e1-dac6-4c05-9150-1839acdf7974
/dev/sda2               /               ext4            rw,relatime,data=ordere$

# UUID=aa8882d5-1b81-4940-b48d-0b54fb17ebec
/dev/sda1               none            swap            defaults        0 0
--------------------------------------------------------------------------------------------------

I am really confused now

Offline

#2 2017-02-19 11:42:25

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: issue with the swap space

/dev/sda1 is a BIOS boot partition rather than a swap partition.

Delete the sda1 partition and use `gdisk` to create a new one of type 8300 8200 and then use:

# mkswap /dev/sda1
# swapon /dev/sda1

EDIT: if you are booting in non-UEFI ("Legacy") mode then deleting the BIOS boot partition will cause your system to become unbootable, you will have to create a new BIOS boot partiiton (type EF02 in `gdisk`) and re-install the GRUB bootloader to the disk to fix this — I use the "spare" sectors 34-2047 for BIOS boot partitions, they should *not* be formatted.

EDIT2: corrected swap partition code.

Last edited by Head_on_a_Stick (2017-02-19 16:06:33)

Offline

#3 2017-02-19 12:14:42

ayushkhanduri
Member
Registered: 2017-02-19
Posts: 6

Re: issue with the swap space

I have a question , why is the fstab file in /etc/fstab shows that sda1 is a swap partition (posted in the question)
and can't just create a new swap partition without deleting the bios boot partition as i think i am booting in the legacy mode

Offline

#4 2017-02-19 13:39:00

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: issue with the swap space

ayushkhanduri wrote:

why is the fstab file in /etc/fstab shows that sda1 is a swap partition

You must have done it wrong big_smile

But seriously, the `genfstab` script is not infallible and the Installation Guide does advise:

Check the resulting file in /mnt/etc/fstab afterwards, and edit it in case of errors.

ayushkhanduri wrote:

can't just create a new swap partition without deleting the bios boot partition as i think i am booting in the legacy mode

Well, you can if you want to and that would work just fine as long as the swap line in /etc/fstab was either modified or deleted (systemd will automount swap partitions on GPT disks, no fstab entries are required).

However, a BIOS boot partition only needs to be a few hundred KiB in size so using a 2 GiB partition seems rather wasteful — the sectors between 34 & 2047 should be empty if your drive is aligned correctly are empty in your drive and that space is big enough for the GRUB files.

Last edited by Head_on_a_Stick (2017-02-19 13:40:20)

Offline

#5 2017-02-19 14:21:52

ayushkhanduri
Member
Registered: 2017-02-19
Posts: 6

Re: issue with the swap space

well okay , half of it i understood and half of it i didn't (sorry) . Can you please tell what should i exactly do now cause i dont want to mess something now

Offline

#6 2017-02-19 16:00:06

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: issue with the swap space

My advice would be to first remove the swap line from /etc/fstab because you do not need it.

Then change the partition code of /dev/sda1 from ef02 (BIOS boot partition) to 8200 (Linux swap), these are the codes used by the `gdisk` command, I think gparted uses named flags for this instead.

You should also create a new BIOS boot partiton ("ef02") starting at sector 34 and ending at sector 2047, do not format this new partition.

Once this is done, run the `mkswap` command and re-install the GRUB bootloader to the disk.

Offline

#7 2017-02-20 05:30:26

ayushkhanduri
Member
Registered: 2017-02-19
Posts: 6

Re: issue with the swap space

Oh now i completely understand the issue , while installing grub i had an error

------------------------------------------------------------------------------------------------------------------------------------------------------------------
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: error: embedding is not possible, but this is required for cross-disk install.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------

so i searched for the error and found the solution using these commands

-----------------------------------------------------
$ pacman -S parted
$ parted /dev/sda set 1 bios_grub on
$ parted /dev/sda print
-----------------------------------------------------

i guess these commands set my bios boot on sda1 , and maybe thats the reasons there are conflicting results for fdisk -l and fstab file , Now it all makes sense , thank you for sticking around with me , i guess i know the solution now .
So knowing my current scenario , is there anything else do you'd like to add ? and is safe to manipulate my partitions and won't cause any issue if done the correct way ?

Offline

#8 2017-02-20 05:50:01

ayushkhanduri
Member
Registered: 2017-02-19
Posts: 6

Re: issue with the swap space

and i wanted to learn more about efi and legacy mode , can you suggest some articles , because i read that bios is not used now , so would it be better to boot the system in uefi mode.?

Offline

#9 2017-02-20 07:49:29

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: issue with the swap space

ayushkhanduri wrote:

So knowing my current scenario , is there anything else do you'd like to add ? and is safe to manipulate my partitions and won't cause any issue if done the correct way ?

All looks good to me.

Make it so.

big_smile

i wanted to learn more about efi and legacy mode , can you suggest some articles

https://www.happyassassin.net/2014/01/2 … work-then/

Offline

#10 2017-02-20 11:37:42

ayushkhanduri
Member
Registered: 2017-02-19
Posts: 6

Re: issue with the swap space

This is excellent material , thank you !!

Offline

#11 2017-02-20 18:53:34

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: issue with the swap space

You're welcome smile

If the problem is [SOLVED] then please mark the thread so for the benefit of others.

Offline

Board footer

Powered by FluxBB