Ubuntu – Fstab edit crashed system

bootfstabmount

I really need some help, I am new to Ubuntu and I think I really messed things up.

I am running Ubuntu Desktop 16.04.2 LTS, and I wanted to mount two additional hard drives at boot.

I edited the /etc/fstab file as root to include the two drives.

The /etc/fstab file had every line starting with # sign so I believe that it was just the example file. I followed the instructions on several different community sites and added two lines something like this:

/dev/sda1 /media/Seagate drive 1 auto,defaults,user,dmask=027,fmask=137 0 0
/dev/sda2 /media/Seagate drive 2 auto,defaults,user,dmask=027,fmask=137 0 0

I know that is not exactly what I added, but I can not get the correct information to add to this post because I saved all of the information on the machine that now will not boot. DUMB I know!

Then I rebooted.

Now my system will not boot up to desktop, and instead now stops at root@craig-PE-T130:~#

Is there a way I can edit the /etc/fstab file from root@craig-PE-T130:~# removing the lines I added, so that my system boots bake up to the desktop?

I would sincerely appreciate any help you can offer.


Edit Update 5/17/2017

I was able to boot from the install cd using the try Ubuntu. I then found the /etc/fstab file I had edited as shown below:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro    0       1
# /boot was on /dev/sda1 during installation
UUID=99ee9dc0-671d-4a5c-a563-7dacaa7ebffb /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

/dev/sdc2 /media/harddrives/seagate1  auto   user,fmask=0111,dmask=0000   0   0
/dev/sdd2 /media/harddrives/seagate2  auto   user,fmask=0111,dmask=0000   0   0

As you can see the two lines I added to the fstab file were not as I had previously stated above, as I was adding to this post from my memory which is not that good.

I now have the following questions:

  1. Can it be determined from the addition of the two lines I added to
    the fstab file if that would cause my system to now stop at
    root@craig-PE-T130:~# during boot up?

  2. Next, since I am only able to open Ubuntu desktop in the try mode, I
    can not edit and save the /etc/fstab file as I do not have
    privilege. How can change my privileges to allow me to edit the
    file while in the try Ubuntu?

When I try to open the /etc/fstab file with gedit in the try mode, this is the header information that I see:

*fstab [Read-Only] (491 GB Volume /media/ubuntu/0823c4f5-e42b-45ee-97b8-ad5d424b8b8d/etc) -gedit  

I really appreciate all of the help you all have offered so far, and I am sure I will get this problem corrected with just a little more advice from all you good folks.

THANK YOU!


EDIT UPDATE 5/20/2017

Below is the answer to steeldriver's question – what is the result of mount | grep '^/'?

root@ubuntu:~# mount | grep '^/'

/dev/sr0 on /cdrom type iso9660 (ro,noatime)
/dev/loop0 on /rofs type squashfs (ro,noatime)
/cow on / type overlay (rw,relatime,lowerdir=//filesystem.squashfs,upperdir=/cow/upper,workdir=/cow/work)
/dev/mapper/ubuntu--vg-root on /media/ubuntu/0823c4f5-e42b-45ee-97b8-ad5d424b8b8d type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sda1 on /media/ubuntu/99ee9dc0-671d-4a5c-a563-7dacaa7ebffb type ext2 (rw,nosuid,nodev,relatime,block_validity,barrier,user_xattr,acl,stripe=4,uhelper=udisks2)
/dev/sdc2 on /media/ubuntu/Seagate D1 type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sdd2 on /media/ubuntu/Seagate D2 type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)

Next, I tried the fix which Organic Marble left in answer to my question (Thank you Organic Marble), but I ran into a problem.

First I ran $ sudo lshw -C disk

*-disk                  
description: ATA Disk
product: TOSHIBA DT01ACA0
vendor: Toshiba
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: A810
serial: Y6CR9KSKS
size: 465GiB (500GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=4096 signature=319f2eb8

This I believe confirms that I need to mount /dev/sda, and that is where I run into the problem as seen below.

ubuntu@ubuntu:~$ sudo mount /dev/sda
mount: can't find /dev/sda in /etc/fstab
ubuntu@ubuntu:~$ 

Well I guess I should have seen that /dev/sda was not in the /etc/fstab file as listed in my edit yesterday. I believe this answered my first question which I posted on 5/17/2017:

  1. Can it be determined from the addition of the two lines I added to
    the fstab file if that would cause my system to now stop at
    root@craig-PE-T130:~# during boot up?

    ANSWER ?: I think my system is now stopping at root@craig-PE-T130:~# during boot up since /dev/sda is not included in the /etc/fstab file?

So now I am left with question number 2:

  1. Since /dev/sda is not included in the /etc/fstab file, and I am only able to open Ubuntu desktop in the try mode, I
    can not edit and save the /etc/fstab file as I do not have
    privilege. How can change my privileges to allow me to edit the
    file while in the try Ubuntu?

Again, thank you all for the help so far, however, I need an answer as to how I can change my privileges to allow me to edit the file while in the try Ubuntu mode?

I think that if I can figure out how to change my privileges, and then add /dev/sda in the /etc/fstab file it should fix the boot issue?

Can anyone please tell me how to change my privileges to allow me to edit the /etc/fstab file while in root after booting from a live disk/stick?


EDIT UPDATE 5/22/2017

PROBLEM SOLVED

I was finally able to edit and save the /etc/fstab file by mounting the partition with
sudo mount /dev/mapper/ubuntu–vg-root /mnt

root@ubuntu:~# sudo lsblk -o model,size,name,fstype,label,mountpoint
MODEL     SIZE NAME   FSTYPE  LABEL                    MOUNTPOINT
TOSHIBA 465.8G sda                                     
  487M ├─sda1 ext2                             /media/ubuntu/99ee9dc0-67
    1K ├─sda2                                  
465.3G └─sda5 LVM2_me                          
457.3G   ├─ubuntu--vg-root
         │    ext4                             /media/ubuntu/0823c4f5-e4
    8G   └─ubuntu--vg-swap_1
              swap            

This allowed me to boot up as normal. I still need to correctly edit the /etc/fstab file to mount two additional hard drives at boot, but I will address that in a different question if I need more assistance.

Thank you all so much for your help!

Best Answer

  1. Boot your system using a live USB
  2. Use Disks to determine the name of your system partition (probably sda1)
  3. Open a terminal window
  4. Mount the system partition by typing the command sudo mount /dev/sd__ /mnt where sd___ is sda1 or whatever the system partition is
  5. Fix fstab using the nano editor sudo nano /mnt/etc/fstab. Probably just delete the lines you added, or do whatever you need to reverse your changes
  6. Reboot
Related Question