LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 12-06-2015, 11:48 PM   #1
Kevin Williams
LQ Newbie
 
Registered: Dec 2015
Location: Earth
Distribution: Linux Lite 2.4
Posts: 10

Rep: Reputation: Disabled
Need help creating mount points for my external hard drive in fstab file.


Hi there;

Ok, here's my problem I connected my external hard drive to my modified chrome-box with Linux Lite 2.4 installed on a single partition.

I then went to see if the external hard drive got registered in /etc/fstab and it didn't. What I'd like to do is write two entries in fstab for the two partitions that are in the external hard drive so that every time I connect this device it mounts where it should without messing up the system. The reason I want to do this is because for a good while the external hard drive was hooked to the chrome-box and every time I turned on the chrome-box with the external hard drive connect it would boot. What happened then ? Well the minute I turned on the chrome-box without the external hard drive connected to it the system would hang at boot. I wasn't aware of that at that time and so I was trying to find out why it was doing that why ? As a result I posted two threads on the Linux lite forum about two different errors I was getting behind the scenes on my system when it hanged at boot time by pressing f4 on the keyboard and got little to no help in that forum. In the end however, I discovered that the reason my system was doing this was because my external hard drive wasn't connected to the chrome-box at bootup.

The fstab file in my system had some how become corrupt. Well after cleaning up my fstab tab file of the wrong external hard drive entries, I created new ones [with the help of this guide - https://help.ubuntu.com/community/Fstab] so that this device mounts correctly to the chromebox at boot time if present. These are my new entries:


#Entry for /dev/sdb1 :
UUID=7345E4783A2909A2 /media/Samsung__1 ntfs-3g defaults,nobootwait 0 0

#Entry for /dev/sdb2 :
UUID=7471EC285F95A650 /media/Samsung__2 ntfs-3g defaults,nobootwait 0 0

How do they look ? Are those entries correct ? I'm half way there so what must I do ? First create the mount points for my external hard drive in fstab like this : sudo mkdir /media/el-junior/Samsung 1/ & then sudo mkdir /media/el-junior/Samsung 2/ ? Right ? Then how should I mount both partitions : sudo mount /dev/sdb1 /media/el-junior/Samsung 1 ? then : sudo mount /dev/sdb1 /media/el-junior/Samsung 2/ ? Then what should I do after that ?

Here's my fstab file as it now stands :

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>

proc /proc proc nodev,noexec,nosuid 0 0
#Entry for /dev/sda1 :
UUID=5bb7792e-918d-423a-a7b9-b5245092cf2c / ext4 errors=remount-ro 0 0
#Entry for sda5 :
UUID=5a11b4dc-7100-4d43-8257-2ec8b09fb291 none swap sw 0 0


Any help will be gratefully appreciated and thanks in advance to whomever helps me out with this. : )

Last edited by Kevin Williams; 12-10-2015 at 07:38 AM.
 
Old 12-07-2015, 03:51 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
If you dont connect the external USB drive permanetly to the computer, the option "nobootwait" is not nessecary -in my opinion.
 
Old 12-07-2015, 04:02 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
you can also add noauto and user to the options
in that case you only need to execute (as regular user): mount /media/<whatever>
you only need to mkdir only once, but not in fstab (before you try to mount those drives).
 
Old 12-07-2015, 11:54 PM   #4
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by Kevin Williams View Post
First create the mount points for my external hard drive in fstab like this : sudo mkdir /media/el-junior/Samsung 1/ & then sudo mkdir /media/el-junior/Samsung 2/ ? Right ?
No - that mkdir command will not work.
sudo mkdir /media/el-junior/Samsung 2 will create a directory named Samsung, and a second directory named 2.
It will not create a directory named Samsung 2
It is better to eliminate the space - sudo mkdir /media/el-junior/Samsung2
If you absolutely have to have "Samsung 2" the command would be:
sudo mkdir /media/el-junior/"Samsung 2"

Last edited by TxLonghorn; 12-07-2015 at 11:56 PM.
 
Old 12-08-2015, 02:58 AM   #5
Kevin Williams
LQ Newbie
 
Registered: Dec 2015
Location: Earth
Distribution: Linux Lite 2.4
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thanks for this LongHorn much appreciated however....

Quote:
Originally Posted by TxLonghorn View Post
No - that mkdir command will not work.
sudo mkdir /media/el-junior/Samsung 2 will create a directory named Samsung, and a second directory named 2.
It will not create a directory named Samsung 2
It is better to eliminate the space - sudo mkdir /media/el-junior/Samsung2
If you absolutely have to have "Samsung 2" the command would be:
sudo mkdir /media/el-junior/"Samsung 2"
Thanks for this LongHorn much appreciated and yes sudo mkdir /media/el-junior/Samsung 2 neither did sudo mkdir /media/el-junior/Samsung 2. So I used sudo mkdir /media/Samsung__1 & sudo mkdir /media/Samsung__2. I also edited my fstab file to look like I showed you and the others in my previous post with the external hard drive entries included. However this resulted in double mount points these being media/el-junior/ Samsung 1 & /media/el-junior/Samsung 2 & /media Samsung__1 & /media/ Samsung__2.
To make myself clear what I wanted to do initially, was register /media/el-junior/Samsung 1 & /media/el-junior/Samsung 2 and have these show up in /etc/fstab each with their respective permissions and such. That is the problem I wanted to solve to prevent the external hard drive from auto writing it's own entries in /etc/fstab and prevent the system from booting up. That is the problem that I had previously after booting my pc continously with the external hard drive connedcted to it. However, little did I know that registering those two external hard drive partitions incorrectly in /etc/fstab would lead to the same boot problem I had previously with my system.

Okay, so I rebooted the pc with the external hard drive connected and it booted ok but upon booting the pc without the external hard drive connected to it, that caused it to freeze on bootup. I couldn't even power off my pc, I had to switch off the circuit protector it's connected to than power it back on. I knew what I had to do next so I booted up my linux live cd, mounted the internal hard drive and removed /media/Samsung__1 & /media/Samsung__2 with the sudo rmdir command. However when I mounted my internal hard drive with the command sudo mount -a and viewed my fstab file using the cat /etc/fstab terminal command, I saw an almost empty fstab file as a result. So what did I do next ? I went to /etc in my internal hard drive only to find a backup fstab file. I therefore opened that file copied the contents of that file, erased the contents of my messed up fstab file file and replaced those with the contents of my backed up fstab file. I then saved my new fstab file, rebooted my pc, which then booted into grub 2 but then when I booted from grub it now hangs at "Starting Bridge file events into upstart." I googled this phrase and came up with this: https://bugs.launchpad.net/ubuntu/+s...p/+bug/1024475

Apparently, there is a bug in Ubuntu 14.04 which they left in Ubuntu 14.04.2 which is the distro or code base Linux Lite 2.4 is based upon. The "Current workaround is changing the existing script /etc/init.d/libnss-ldap to include:

[...]

case "$1" in
start)
cp -f /etc/nsswitch.conf.ldap /etc/nsswitch.conf
;;
stop)
cp -f /etc/nsswitch.conf.local /etc/nsswitch.conf
;;

[...]

This will get you nss ldap working and no problems during reboot".

Excerpt as taken from post # 2 in that thread. There are several workarounds in that thread but I think maybe what Jcat-l (jcat-l) wrote on 2014-09-11 will work :
#! /bin/sh -e

### BEGIN INIT INFO
# Provides: libnss-ldap
# Required-Start:
# Required-Stop: mountall.sh
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Updates /etc/ldap.conf
# Description: Updates nss_initgroups_ignoreusers based on
# nss_initgroups_minimum_uid
### END INIT INFO

PATH="/sbin:/bin:/usr/sbin:/usr/bin"
. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Removing nssldap-update-ignoreusers changes"
if sed -i "/^nss_initgroups_ignoreusers/d" /etc/ldap.conf ; then
log_action_end_msg 0
else
log_action_end_msg 1
exit 1
fi
;;
restart|force-reload|stop)
log_action_begin_msg "Running nssldap-update-ignoreusers"
if nssldap-update-ignoreusers ; then
log_action_end_msg 0
else
log_action_end_msg 1
exit 1
fi
;;
*)
echo "Usage: $0 {start|restart|force-reload|stop}"
exit 1
;;
esac
exit 0

Or maybe what Anaxim (anaxim) wrote on 2014-09-17:

I found a solution on following the page : http://backdrift.org/how-to-get-pam-...orking-is-down and changed /etc/ldap.conf file and add following lines before nss_initgroups_ignoreusers:
nss_reconnect_tries 2
nss_reconnect_sleeptime 1
nss_reconnect_maxsleeptime 1
nss_reconnect_maxconntries 1

After this modification the system was able to boot normally and I could directly log in with ldap user". I don't know if I can do this in recovery mode but when I go there nothing works it just hangs so what now ? Maybe none of the above workarounds is the answer can I maybe bin bash my way into recovery mode from the grub 2 commandline to see the actual error on my machine ? If so what commands do I need to enter please point me in the right direction. Be as specific as possible so that I can actually do this. I remember doing this last time my system couldn't boot, but forgot how to do it. Thanks in advance anyway..

Last edited by Kevin Williams; 12-08-2015 at 06:07 AM. Reason: I had alot of things to say.
 
Old 12-08-2015, 08:12 AM   #6
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Blog Entries: 1

Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by TxLonghorn View Post
No - that mkdir command will not work.
sudo mkdir /media/el-junior/Samsung 2 will create a directory named Samsung, and a second directory named 2.
It will not create a directory named Samsung 2
It is better to eliminate the space - sudo mkdir /media/el-junior/Samsung2
If you absolutely have to have "Samsung 2" the command would be:
sudo mkdir /media/el-junior/"Samsung 2"
Another workaround is to escape the space like so;
Code:
sudo mkdir /media/el-junior/Samsung\ 2
However, This only works if /media/el-junior/ already exists. mkdir throws up a 'No such file or directory' error unless everything in the path except the final directory already exists.
 
Old 12-08-2015, 09:16 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
If you include spaces in the directory name, you have to deal with how to represent that in /etc/fstab. It needs to be represented by its octal encoding, "\040", and since the next character is a digit you have to hope that the decoder is smart enought to stop after three octal digits. It's best not to use spaces in names that have to appear in /etc/fstab.

You also want either the "noauto" or "nofail" option so that you can boot without the drive connected, and probably the "user" or "users" option so that you can manually mount the drive without needing "sudo". The "user" option allows only the user who mounted the drive (or root, of course) to unmount it; "users" allows any user to unmount the drive.
 
Old 12-08-2015, 10:14 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
I do not really understand how it is related to libnss-ldap at all. Connecting an external hdd will not cause any modification on /etc/fstab.
mkdir and rmdir are not related to mounts at all, the exising mount point was a prerequisite, but for automounters they can be created on demand too.
So fstab is used to predefine how mount will occur. That's why you need to configure it properly (and also mkdir the mount point - that should be done only once)
Code:
#Entry for /dev/sdb1 :
UUID=7345E4783A2909A2 /media/Samsung__1 ntfs-3g defaults,nobootwait 0 0

#Entry for /dev/sdb2 :
UUID=7471EC285F95A650 /media/Samsung__2 ntfs-3g defaults,nobootwait 0 0
the bold parts are the mount options, you need to add noauto to it. That will cause the system to boot even if the external hdd was not connected. I suggest you to avoid spaces in those directory names. Also adding the option user will allow to mount/umount it as regular user, do not need to sudo. (your system was frozen because it tried to mount a missing drive). This is explained very well on the page you posted (https://help.ubuntu.com/community/Fstab).
So finally your entry in fstab should look like:
Code:
#Entry for /dev/sdb1 :
UUID=7345E4783A2909A2 /media/Samsung__1 ntfs-3g defaults,nobootwait,noauto,user 0 0
but obviously you can use another options too. And also don't forget to create the mount point before you connect that drive.
 
Old 12-09-2015, 11:20 PM   #9
Kevin Williams
LQ Newbie
 
Registered: Dec 2015
Location: Earth
Distribution: Linux Lite 2.4
Posts: 10

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by qlue View Post
Another workaround is to escape the space like so;
Code:
sudo mkdir /media/el-junior/Samsung\ 2
However, This only works if /media/el-junior/ already exists. mkdir throws up a 'No such file or directory' error unless everything in the path except the final directory already exists.
When I connect the external hard drive to the system it shows up in th media/el-junior folder with the folders Samsung 1 and Samsung 2 folder inside it. How would I mount the external drive then ? First chroot in as root then sudo mount media/el-junior Samsung 1 then sudo mount media/el-junior Samsung 2, then sudo nano -Bw /etc/fstab to edit the fstab file directly, then add the additional two lines for the external hard drive, then, exit, then reboot. Is that how it's done ?

Last edited by Kevin Williams; 12-09-2015 at 11:33 PM.
 
Old 12-09-2015, 11:35 PM   #10
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by Kevin Williams View Post
But why is that why can't I just recreate the directory as it already exists when I mount the external drive to the system so that it registers correctly in fstab ? Why did it throw out the error 'No such file or directory' error, if I tried sudo mkdir /media/el-junior Samsung 1 ? I tried that initially but got the error ? why ? Could someone explain?
That question reminds me of when I started out with linux, and banged my head against the wall trying to make linux conform to the way I thought it should work, instead of learning the "rules of the game".
Fortunately, you have several knowledgeable people telling you how it works here. You should listen.
 
Old 12-10-2015, 12:14 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
Quote:
Originally Posted by Kevin Williams View Post
When I connect the external hard drive to the system it shows up in th media/el-junior folder with the folders Samsung 1 and Samsung 2 folder inside it. How would I mount the external drive then ? First chroot in as root then sudo mount media/el-junior Samsung 1 then sudo mount media/el-junior Samsung 2, then sudo nano -Bw /etc/fstab to edit the fstab file directly, then add the additional two lines for the external hard drive, then, exit, then reboot. Is that how it's done ?
If they appear automatically that means they are mounted automatically an you do not need to do anything
 
Old 12-10-2015, 03:58 AM   #12
Kevin Williams
LQ Newbie
 
Registered: Dec 2015
Location: Earth
Distribution: Linux Lite 2.4
Posts: 10

Original Poster
Rep: Reputation: Disabled
I'am listening LongHorn

Quote:
Originally Posted by TxLonghorn View Post
That question reminds me of when I started out with linux, and banged my head against the wall trying to make linux conform to the way I thought it should work, instead of learning the "rules of the game".
Fortunately, you have several knowledgeable people telling you how it works here. You should listen.
I'am listening LongHorn and no I'm not banging my head over this lol I just want to know why is that the reason. Perhaps that reason is too complicated for you or anyone on here to give me in a short post.

Anyway, thanks for all your replies guys. Update: After doing I series of things to my system I'm now able to boot my pc properly with my fstab file back to it's default condtion. Pan64, with respect to your comment yes I know I can connect the external hard drive to the system and it will mount automatically allowing me to browse files and copy new data into it's partitions and such. However, I'm afraid that if I don't write in those two fstab entries message #8 then my system will once again mess up and not boot.

Let me explain, previously in the past I would seldonm use my external hard drive; well as I used it more and more I thought to myself one day, well why not leave the
external hard drive to the pc all the time no harm done, right ? Wrong !!! What happened was my system couldn't boot and I was trying to find out why it couldn't boot. So I booted the system by pressing F4 to see where it hanged and I got "starting enable remaining boot time encrypted block device" which is were the system was hanging. So I
googled for a solution for this error and I would read this thread then that thread and read and read. Then I found a very helpful post in the Linux Mint launchpad.net bugs site regarding the issue where I discovered that the major reason my system hanged at boot was because there was something wrong with my fstab file and that I had to go into
recovery mode two edit out the offending line9(s). Well, when I went to recovery mode I couldn't enter into a root shell as root, I couldn't repair packages I could do anything and I didn't know why. Little did I know that I could edit the /etc/fstab file from live usb; Look guys, you can't even imagine what pain this caused me the first time.

I don't know the reason why my fstab tab file got corrupted after booting my pc with the external hard drive connected for several weeks. I just don't know ! Maybe there's a bug in this distro. I'm using Linux Lite 2.4 b.t.w which is based on Ubuntu 14.04.2. All I'm trying to do is try to prevent this from ever happening again.

Last edited by Kevin Williams; 12-10-2015 at 08:32 AM.
 
Old 12-10-2015, 05:11 AM   #13
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
I believe my "You should listen" comment was due to misinterpreting exactly what you were saying, so I appologize for sounding harsh.

"why can't I just recreate the directory as it already exists"
It already exists with the Label "Samsung 2" so I think you are asking why the mount point cannot be created as "Samsung 2", right?
You can, but you have to use the tip provided by rknichols - "If you include spaces in the directory name, you have to deal with how to represent that in /etc/fstab. It needs to be represented by its octal encoding, "\040", and since the next character is a digit you have to hope that the decoder is smart enought to stop after three octal digits. It's best not to use spaces in names that have to appear in /etc/fstab."
So in fstab the entry would be:
#Entry for /dev/sdb2 :
UUID=7471EC285F95A650 /media/Samsung\0402 ntfs-3g defaults,nobootwait 0 0
But rknichols did note that "since the next character is a digit you have to hope that the decoder is smart enought to stop after three octal digits".
 
Old 12-10-2015, 05:56 AM   #14
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
you may enter the following char (2) as octal too. But actually if some automounter is in use you must not alter fstab to do the same thing again. You need to configure your automounter first.
 
Old 12-10-2015, 06:06 AM   #15
Kevin Williams
LQ Newbie
 
Registered: Dec 2015
Location: Earth
Distribution: Linux Lite 2.4
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TxLonghorn View Post
I believe my "You should listen" comment was due to misinterpreting exactly what you were saying, so I appologize for sounding harsh.

"why can't I just recreate the directory as it already exists"
It already exists with the Label "Samsung 2" so I think you are asking why the mount point cannot be created as "Samsung 2", right?
You can, but you have to use the tip provided by rknichols - "If you include spaces in the directory name, you have to deal with how to represent that in /etc/fstab. It needs to be represented by its octal encoding, "\040", and since the next character is a digit you have to hope that the decoder is smart enought to stop after three octal digits. It's best not to use spaces in names that have to appear in /etc/fstab."
So in fstab the entry would be:
#Entry for /dev/sdb2 :
sudo mkdir /media/el-junior/"Samsung 1"
But rknichols did note that "since the next character is a digit you have to hope that the decoder is smart enought to stop after three octal digits".
You're forgiven Longhorn, you really meant #Entry for /dev/sdb2 :sudo mkdir /media/el-junior/"Samsung 2". Right ? since /dev/sdb2 ponts to Samsung 2 and /dev/sdb1 points to Samsung 1 as in:

#Entry for /dev/sdb1 :
UUID=7345E4783A2909A2 /media/el-junior/Samsung 1/040 ntfs-3g defaults,nobootwait,noauto,user 0 0


#Entry for /dev/sdb1 :
UUID=7345E4783A2909A2 /media/el-junior/Samsung 2/040 ntfs-3g defaults,nobootwait,noauto,user 0 0

You see that is one of the problems I'm having, what should I do afterwards ? Enter sudo mount -a to check if these entries are right ? Correct ? Also does sudo mount -a also check if the mount point folders I create for both mount points are correct ? You know, #Entry for /dev/sdb2: sudo mkdir /media/el-junior/"Samsung 2" Eh?

Last edited by Kevin Williams; 12-10-2015 at 08:59 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot mount External Hard Drive - fstab error scottaudio Linux - Software 14 09-18-2014 06:38 AM
Question on External Drive Mount Points ervt Linux - General 1 04-15-2008 06:03 PM
creating mount points on the unused Hard disk after installation of RedHat Linux ES 4 vamsikatakam Linux - Enterprise 4 03-21-2007 12:55 PM
Mount points on usb devices (dig. camera, zip drive, external hard disk) Impaler Linux - Hardware 3 05-29-2006 11:08 PM
8 mount points on hard drive? drtydane Linux - Newbie 3 12-15-2005 09:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration