0

I was trying to increase the swap size of my Ubuntu. I, naïve, followed the steps of this answer:

Check the swap that is in use:

sudo swapon -s

If swap partition(s) are found:

sudo swapoff -a sudo nano -Bw /etc/fstab

Add # before the UUID of the swap partition(s):

UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none swap sw 0 0

Add a line for the swapfile, if one does not exist:

swapfile none swap sw 0 0

Create the swapfile:

sudo fallocate -l XG /swapfile*

where X is swapfile's size in GB:

sudo mkswap /swapfile sudo chmod 0600 /swapfile sudo swapon /swapfile

Reboot:

sudo reboot

After that, my computer only starts in recovery mode.

I tried to follow this anwser. But the error unable to resolve host my-laptop-name: Temporary failure in name resolution appears and make the process to fail.

I tried to fix it following another answer that says that the name of the host in /etc/hostname and /etc/hosts must be the same. It was wrong in /etc/hosts. But the file is read-only and I can't write on it, even with sudo.

I checked /etc/fstab and notice that I, dumb, put # to the UUID to the the boot disk, not only to the swap thing. I tried to erase the #. But that file is read-only too. I want to kill myself right now :).

If it's not clear after all this, I don't know much about Linux.

Edit 1:

My version of Ubuntu is Desktop 22.04.3 LTS

When I do sudo sudo nano /etc/fstab to erase # from boot line, [ File '/etc/fstab' is unwritable. The same happens with /etc/hosts.

Edit 2:

I edited the boot option in the GRUB and it worked to edit both /etc/fstab and /hosts.

Now I am struggling because when I try to boot normally the system raises an error about swap. This the error:

[0.219748] ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PC00.DGPV],
AE_NOT_FOUND (20230331/psargs-330)
[0.219765 ACPI Error: Aborting method \SB.PC00.PEG0.PCRP._OFF due to previous error (AE_NOT_FOUND) (20230331/psparse-596)

/dev/nvme0n1p2: clean, 848739/15597568 files, 29875721/62383360 blocks

[2.251365] systemd[1]: Failed to activate swap /swapfile. [FAILED] Failed to activate swap /swapfile. [DEPEND] Dependency failed for Swaps.

[3.057060] iwlwifi <ipv6> BIOS contains WGDS but no WRDS

I tried to recreate swap file like in this answer. These are the commands I run to do so:

swapoff -a
rm /swapfile 
dd if=/dev/zero of=/swapfile bs=1M count=4096
chmod 600 /swapfile

mkswap /swapfile #anwer to this line is:

setting up swapspace version 1, size 4 GiB

no label, UUID=<long UUID>

swapon /swapfile

Then I review /etc/fstab. At the end there's the line /swapfile none swap sw 0 0. There's the line with UUID with the boot partion too. But there's no line with the UUID that mkswap /swapfile returned. And the error when trying to boot still happens.

Simón
  • 11
  • The file /etc/fstab or the file-system table for your system required elevated privileges to edit, ie. did you include a sudo command at the start of your edit command? (ie. to elevate your privileges so you had access to WRITE to the file??) – guiverc Feb 05 '24 at 01:00
  • Thanks. I just edited the question. Let me know if more details will be helpful. – Simón Feb 05 '24 at 01:24
  • 1
    If the file-system itself is read-only, that is mostly likely because of either it was mounted that way; or more likely if it was mounted RW (read-write) it'll only switch to RO (read-only) on detection of error(s) with problems appearing in system logs as to why. Best action in that case varies on why (ie. reading logs (dmesg, journactl etc) to see why); then it maybe reboot using live and perform file-system checks OR checking drive health or for hardware issues.. You've added 22.04 or the release; not which product (Server? Desktop? etc) as they have different defaults – guiverc Feb 05 '24 at 01:26
  • Please provide the relevant logs (journalctl, dmesg) at the time when you failed to activate the swapfile. You can also run blkid /swapfile to check the file itself. – mcendu Feb 05 '24 at 07:47
  • Oh, and I've seen you asked a new question on this. Maybe just reverse the second edit so that the answers here can help others. – mcendu Feb 05 '24 at 07:54
  • @mcendu yees, I make the other question. Let's follow the topic there. I will resolve this question for you helped me to make /etc/hosts and /etc/fstab editable. – Simón Feb 05 '24 at 11:32

2 Answers2

2

You can fix this! When I was starting with Ubuntu I broke my systems with fstab so many times I wrote down a procedure for how to fix them. Here ya go:

  1. Boot the computer to an Ubuntu live USB and select "try Ubuntu"
  2. Open a terminal and issue a sudo blkid , this will list the drives and partitions with UUIDs and labels. Identify the system partition.
  3. In the terminal issue a sudo mount /dev/sd__ /mnt where sd__ is the system partition you determined in step 2, probably sda1. Notice the space before /mnt
  4. Edit fstab and fix the problem with a sudo nano /mnt/etc/fstab Be sure to save your work.
  5. Reboot into your fixed system! Remember to remove the live USB.
Organic Marble
  • 23,641
  • 15
  • 70
  • 122
  • 1
    Thanks for the answer. I didn't have a Live USB nor another computer to make it. So I preferred the other solution. – Simón Feb 05 '24 at 11:34
0

The default Linux command line mounts root as read-only on boot (more precisely, just after initramfs).

The safest way is to do the following:

  • Reboot to GRUB; if you are greeted with a blank screen, hit Esc.
  • Select Ubuntu's boot entry. Don't hit Enter; instead, edit the boot entry. The bottom of the GRUB menu tells you what you can do.
  • There is a line starting with linux. Remove all ro parameters from that line. Go to the end of that line and add the parameter rw.
  • Boot. Refer to the bottom of the screen for instructions.
mcendu
  • 307
  • Thanks for answering. I tried to modify/etc/fstab and /etc/hosts with sudo nano. But the alert [ File '/etc/fstab' is unwritable] appears and the changes can't be saved because of the error Read-only file system. – Simón Feb 05 '24 at 01:23
  • @Simón In this case the filesystem is mounted ro. I've attempted a new solution for this. – mcendu Feb 05 '24 at 01:41
  • let me know if I am understanding well. In that boot option edit interface, the line that start with linux is this one: linux /boot/vmlinuz-6.5.0-15-generic root=UUID=<long UUID> ro quiet splash $vt-handoff. When you say "remove all ro parameters" you mean to delete all that follows "ro" in that line, and "ro" itself? – Simón Feb 05 '24 at 02:21
  • Delete just ro itself; replace that with rw. – mcendu Feb 05 '24 at 03:01
  • it workeeed. I could edit both /etc/hosts and /etc/fstab, big win. Now I'm struggling with the swap. I wrote the details in the edit 2 of the question. – Simón Feb 05 '24 at 04:32