Accidentally deleted /etc/fstab file
You have to recreate a new fstab
file inside /etc
directory and add an entry for your root partition, so that your Ubuntu os will boot.
Method 1:
Recreating /etc/fstab file via Recovery mode
Boot into Recovery mode and then drop to root shell.
-
Run
sudo blkid
command to know the UUID of your/
(root) partition.It will show something like this,/dev/sda1: UUID="52e062e0-716c-4828-9bf1-05b93fdaef93" TYPE="ext4" /dev/sda1: UUID="2F4DAFCF02D7EBEB" TYPE="ntfs" /dev/sda3: UUID="039E0CF305398945" TYPE="ntfs" /dev/sda5: UUID="C68C57908C5779BF" TYPE="ntfs"
From the
sudo blkid
output, identify your root ext4 partition and note down its corresponding UUID.-
Now mount your
/
partition in Read Write Mode by running the below command.Please note that the simplemount /
command for mounting your root partition won't work because of the deletion of/etc/fstab
. So, if your/
was/dev/sda1
, run this command:mount -t ext4 -o rw,remount /dev/sda1 /
-
The above command will mount your
/
partition in read write mode.Run the below command to create a newfstab
file inside/etc
with the appropriate line to mount your/
. In the example above, my/
hasUUID=52e062e0-716c-4828-9bf1-05b93fdaef93
, so I would run:echo "UUID=52e062e0-716c-4828-9bf1-05b93fdaef93 / ext4 errors=remount-ro 0 1" > /etc/fstab
Exit from the root shell and boot your Ubuntu OS, it will surely bootup.
Method 2
Recreating /etc/fstab file via Ubuntu live disk
Boot ubuntu live disk.
Run
sudo blkid
command and note the installed Ubuntu partition's device id and the UUID.-
Mount your root partition,
sudo mkdir /media/ubuntu sudo mount /dev/sdaX /media/ubuntu
Now go into the
/media/ubuntu
via nautilus and create afstab
file inside/etc
.-
On that fstab file, add an entry for your root partition like below.
UUID=52e062e0-716c-4828-9bf1-05b93fdaef93 / ext4 errors=remount-ro 0 1
Save that file.And boot into your installed Ubuntu.
Note: My root partition's UUID was given above.Please give your's.After booting into your installed Ubuntu OS, don't forget to add fstab
entry for your swap partition.