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.


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

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

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


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
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

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!

  • If it gets as far as a root@craig-PE-T130:~# prompt, then it's booted - at least as far as a root shell. You certainly should be able to recover from there - what is the result of mount | grep '^/'? May 14, 2017 at 20:14
  • If you are at a root prompt, you just need to find out if your root partition is mounted and whether mounted ro or rw. like steeldriver said, if you use that command, you will see what devices are mounted. Your issue comes from your use of spaces in the name without quotes. You have two devices mounting over each other as /media/Seagate (and it is possible that your root partiton is actually /dev/sda1 or /dev/sda2 meaning that you mounted your blank drive over the / partition... May 14, 2017 at 20:20
  • Better to mount with UUIDs and do not use spaces with Linux. If you want extra info use CamelCase, under_score or justonelongname (up to char length which I do not know). Also best to add labels to partitions just to help keep track of them. Post this above and preserve formatting: sudo parted -l and 'sudo blkid -c /dev/null -o list` And always run this before rebooting when editing from inside your system sudo mount -a If you have / (root) mounted you can edit from command line: sudo nano /etc/fstab If not use live installer, mount / somewhere and use that mount to edit.
    – oldfred
    May 14, 2017 at 21:12
  • It is extremely unlikely that the original fstab file had every line starting with a #. May 14, 2017 at 22:17
  • When you get your system back up, replace the spaces in the /etc/fstab mount point with \040, like /dev/sda2 /media/Seagate\040drive\0402 auto,defaults,user,dmask=027,fmask=137 0 0 May 14, 2017 at 22:42

3 Answers 3

  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
  • Any special reason you want him to use nano rather that whatever editor he is familiar with? Not just sadistic are you? ;-) May 14, 2017 at 21:53
  • No special reason. People are free to use whatever they like. May 14, 2017 at 22:15
  • 1
    If you are at command line then nano is available in default installs. If really sadistic we could suggest some of the old school editors like emacs or vi. ( I have never used them, just some do really know & like them.)
    – oldfred
    May 14, 2017 at 23:57
  • @OrganicMarble When trying the answer I ran into the problem as stated in my post edit on 5/20/2017 that: "can't find /dev/sda in /etc/fstab." PLEASE ADVISE. I have also posted another question relating to this at (askubuntu.com/questions/917138/…) May 21, 2017 at 12:42
  • sda is the whole disk. You can't mount that. You need to find the partition, which is a sub-set of the disk, named like sda1, sda2, etc. It was also not clear from your edit if you used a live USB. You must do that, you cannot do it from a regular boot. May 21, 2017 at 13:20

You might find it easiest to boot from a live disk/stick. You probably used one to install Ubuntu to begin with. Still have it around? Then just navigate to /etc/fstab using the file browser as root, rename it something like fstab-that-I-messed-up, then rename the backup you made before editing it fstab and reboot to the hard drive. If you didn't make a backup deliberately when you edited it, there may still be one with a "~" at the end of the file name, depending on what editor you used. If there is no backup, or if the backup itself is corrupted because you edited it more than once and it was ALREADY messed up before you edited the last time, then use a search engine to find a model fstab and study man fstab to edit is as necessary. If you mess up, just to it again until you get it right. If you are sure that messing up fstab is the only thing wrong, it should be pretty easy to fix. I wouldn't do anything else on that system, especially I wouldn't upgrade, until you fix it.

Pay close attention to Steeldriver, btw. He's an old hand, and he really knows his s. . ., um, steel. And I see Oldfred has joined us. He is a real guru.

@steeldriver Hi - I know you from another forum. Hope all is well.

@oldfred Ditto. Nice to see your nic again.

  • 1
    The takeway is: always make a backup before editing key config files. May 14, 2017 at 20:47

UPDATE for 22.04 LTS June 2022:

Referencing this accepted answer from @Organic Marble I encountered issues with locating and editing the fstab file on a more modern system so I took the following steps to locate the file.

  1. Opened Disks as outlined and copied the Partition 2 Contents field (in this case `/media/ubuntu/
  2. cd to the copied directory then cd etc
  3. less fstab to ensure the correct file
  4. sudo nano fstab to edit the file (and remove/edit the offending lines)
  5. Ctrl o to write out the changes and Ctrl x to exit the file
  6. reboot et voila!! the system was back to its previous state 😅

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.