I am 100% new to Linux as of yesterday and I seem to have done something wrong. I had the system up and running last night with no obvious issues but today when I try to boot up I get an error and the whole thing fails.
Some background: My computer has a 500 GB SSD which is what Ubuntu (version 20.04.1) was installed onto and a 2TB HDD which I formatted for use last night. I suspect that my issue is related to that fact, because I was able to restart the system multiple times without issue before I formatted it. Unfortunately I do not know enough about Ubuntu to even know where to start, and I could not seem to find any help for my specific situation online.
On startup I'm presented with 3 options
- Ubuntu
- Advanced options for ubuntu
- UEFI Firmware Settings
Here's the specific output I'm getting after selecting Ubuntu:
[Failed] Failed to activate swap /swapfile [Depend] Dependency failed for SwapLet me know if there's any other information that's relevant to the issue or if there's anything I should try. All advice is appreciated.
Here is the output from running the recommended commands in the root access:
grep -i swap /etc/fstab /swapfile none swap sw 0 0 ls -al /swapfile -rw------- 1 root root 2147483648 Sep 24 03:41 /swapfile 4 3 Answers
That all looks normal, but let's recreate the /swapfile.
Boot to Recovery Mode like you just did, and do this...
Note: Incorrect use of the dd command can cause data loss. Suggest copy/paste.
In the terminal (or root # prompt)...
sudo swapoff -a # turn off swap
sudo rm -i /swapfile # remove old /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile # set proper file protections
sudo mkswap /swapfile # init /swapfile
sudo swapon /swapfile # turn on swap
free -h # confirm nnG RAM and 4G swapConfirm this /swapfile line at the end of /etc/fstab... and confirm no other “swap” lines...
To edit, use sudo -H gedit /etc/fstab or sudo pico /etc/fstab
/swapfile none swap sw 0 0reboot # reboot and verify operationUpdate #1:
/etc/fstab was messed up and causing the file system to be read-only. Only had 1 hour on freshly installed Ubuntu, so I recommended to reinstall Ubuntu again.
UUID="fae3ba3a-abaf-4eca-8139-40d5328d017c" /srv ext4 errors=remount-ro 0 15 I've actually had a similar issue. The downside is that I completed a copy from a failed hard drive then Ubuntu decided to complete a small change to my swap. Since my config was not setup properly, everything just broke with the exact same problem.
I solved it in a different way.
So, I followed the same steps as from Heynnema and worked wonders but, in my issue, that wasn't the root problem.
In fstab, I had an issue that my root drive wasn't setup (as per normal Ubuntu installation, can be explained later). So, when I added my main hard drive to fstab as /, I was able to boot with no issue.
Here's an example of my fstab:
$ cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=fa1b78f3-9d98-42e3-9a72-a9716000d8f9 / ext4 defaults 0 0
/swapfile none swap sw 0 0
UUID=b31e2ef4-6240-47d6-8ef9-2b98622603a8 /1tb ext4 defaults 0 0
UUID=e37a2ae4-74c8-4bd1-b3ad-36ba5904a680 /500gb ext4 defaults 0 0So, my line 3 didn't exist before and caused issues since the swap couldn't find / when it was initializing after the update.
But, when I loaded into the recovery system, I was unable to edit fstab since it was in readonly. Simply use the command mount -o remount / and the system will automatically remove the readonly for you to update the /etc/fstab using your preferred text editor.
If your system is having issues or locked you out due to the readonly issue, I would suggest a livecd system to modify your /etc/fstab, then boot normally.
I had the same problem and solved it successfully.
The biggest problem is Read-only file system. As you have mentioned that /etc/fstab was messed up and causing the file system to be read-only. I think you mount the default disk device(which the file system is installed on) wrongly in /etc/fstab.
As a solution, you only need to remount the default disk manually using uuid label in recovery mode. Here is the command:
sudo mount -o remount UUID=the-uuid-of-your-default-disk /
The last / means the root node.
After that, your file system is writable. And you should revise the /etc/fstab correctly before you reboot your system.