LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-25-2016, 01:39 AM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 235

Rep: Reputation: Disabled
Script that runs before fstab


On CentOs7, if I have this line in /etc/fstab:

/dev/sda6 /mnt/tempdir ext4 default 0 0

But I may NOT have /mnt/tempdir yet.

What script I can use to add command to
create directory /mnt/tempdir such that
init process runs it before init runs /etc/fstab
via command mount -a?
 
Old 05-25-2016, 03:17 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Distribution: SLES 12
Posts: 1,577

Rep: Reputation: 106Reputation: 106
With fstab the patitions are mouted.
I think it is not possible to create a directory below /mnt before the lines in fstab are executed.
You can create that directory manually from command line in run level 3 or 5.
 
1 members found this post helpful.
Old 05-25-2016, 06:20 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Normally, /mnt is on a permanent filesystem (as part of the root filesystem). Once the subdirectory is created, it will be available on the next boot - thus available before the mount operation gets done.
 
1 members found this post helpful.
Old 05-25-2016, 09:40 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,961

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
Indeed, once you have created that directory it will stay there. If you just need the boot to proceed regardless, you could use the "nofail" option.
Code:
/dev/sda6 /mnt/tempdir ext4 nofail 0 0

Last edited by rknichols; 05-25-2016 at 09:41 AM.
 
1 members found this post helpful.
Old 05-25-2016, 10:55 AM   #5
fanoflq
Member
 
Registered: Nov 2015
Posts: 235

Original Poster
Rep: Reputation: Disabled
I thought using rc.local might be a solution using these commands:

Quote:
mkdir /mnt/tempdir
mount -t ext4 /dev/sda5 /mnt/tempdir
Quote:
[user1@localhost mnt]$ file /dev/sda5
/dev/sda5: block special
Then change ownership of rc.local to execute on reboot:
chmod +x /etc/rc.d/rc.local

I have also commented out mount command in /etc/fstab.
But when I reboot I see these in /mnt/tempdir:

Quote:
[user1@localhost mnt]$ ls tempdir1/
aquota.user lost+found
So it works......
But notice I did not specify quota in rc.local.
So why is aquota.user added auto-magically?
What causes it?


Addendum:

But now I have another problem:


Quote:
[user1@localhost ~]$ sudo chown user1.user1 /mnt/tempdir1/
[user1@localhost ~]$ ls -al /mnt/tempdir1/
total 13
drwxr-xr-x. 3 user1 user1 1024 May 25 11:04 .
drwxr-xr-x. 3 root root 21 May 25 11:00 ..
drwx------. 2 root root 12288 May 25 11:04 lost+found
[user1@localhost ~]$ ls -al /mnt
total 5
drwxr-xr-x. 3 root root 21 May 25 11:00 .
dr-xr-xr-x. 17 root root 4096 Apr 15 14:53 ..
drwxr-xr-x. 3 user1 user1 1024 May 25 11:04 tempdir1
[user1@localhost ~]$ sudo quotacheck -u user1 -f /mnt/tempdir1
quotacheck: Cannot stat() given mountpoint user1: No such file or directory
Skipping...
quotacheck: No correct mountpoint specified.
quotacheck: Cannot initialize mountpoint scan.
[user1@localhost ~]$


[user1@localhost tempdir1]$ pwd
/mnt/tempdir1
[user1@localhost tempdir1]$ sudo quotacheck -u -f /mnt/tempdir1
quotacheck: Mountpoint (or device) /mnt/tempdir1 not found or has no quota enabled.
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
Quote:
The directory exists, and mount point exists like so:
[user1@localhost tempdir1]$ mount | grep tempdir1
/dev/sda5 on /mnt/tempdir1 type ext4 (rw,relatime,seclabel,data=ordered)

and I do quotacheck again:

[user1@localhost tempdir1]$ sudo quotacheck -u -f /mnt/tempdir1
quotacheck: Mountpoint (or device) /mnt/tempdir1 not found or has no quota enabled.
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.


Why am I not able to do quotacheck?

Thank you.

Last edited by fanoflq; 05-25-2016 at 11:36 AM.
 
Old 05-25-2016, 12:01 PM   #6
dab1414
Member
 
Registered: May 2011
Location: OK, USA
Distribution: Slackware 14.1_64
Posts: 70

Rep: Reputation: 49
Look here , or here or here for Centos guide.

Seems you might need to enable quota in /etc/fstab first.
 
Old 05-25-2016, 12:26 PM   #7
fanoflq
Member
 
Registered: Nov 2015
Posts: 235

Original Poster
Rep: Reputation: Disabled
Here is the "solution":

I added userquota to rc.local like so:
Quote:
mount -t ext4 -o defaults,usrquota /dev/sda5 /mnt/tempdir1
On reboot, here is what I see:
Quote:
[user1@localhost mnt]$ ls -al tempdir1/
total 1
drwxr-xr-x. 2 user1 user1 1024 May 25 11:24 .
drwxr-xr-x. 3 root root 21 May 25 11:45 ..

[user1@localhost mnt]$ mount | grep tempdir1
/dev/sda5 on /mnt/tempdir1 type ext4 (rw,relatime,seclabel,quota,usrquota,data=ordered)

Then ran quotacheck to create aquota.user file:
Quote:
[user1@localhost mnt]$ sudo quotacheck -u -f /mnt/tempdir1
[sudo] password for user1:
[user1@localhost mnt]$ ls -al tempdir1/
total 8
drwxr-xr-x. 2 user1 user1 1024 May 25 11:54 .
drwxr-xr-x. 3 root root 21 May 25 11:45 ..
-rw-------. 1 root root 6144 May 25 11:54 aquota.user

[user1@localhost mnt]$ sudo quota -f /mnt/tempdir1/
Disk quotas for user root (uid 0): none

# Now you can turn quota on, edit quota....
sudo quotaon -f /mnt/tempdir1
sudo edquota -u user1 -f /mnt/tempdir1
But I do not know why aquota.user in /mnt/tempdir1 was created when I did not use the usrquota option in mount command as described in my previous post.
 
Old 05-25-2016, 12:53 PM   #8
dab1414
Member
 
Registered: May 2011
Location: OK, USA
Distribution: Slackware 14.1_64
Posts: 70

Rep: Reputation: 49
Quote:
Originally Posted by fanoflq View Post
But I do not know why aquota.user in /mnt/tempdir1 was created when I did not use the usrquota option in mount command as described in my previous post.[/B]
Here is a manpage for quotacheck

Quote:
Description

quotacheck examines each filesystem, builds a table of current disk usage, and compares this table against that recorded in the disk quota file for the filesystem (this step is ommitted if option -c is specified). If any inconsistencies are detected, both the quota file and the current system copy of the incorrect quotas are updated (the latter only occurs if an active filesystem is checked which is not advised). By default, only user quotas are checked. quotacheck expects each filesystem to be checked to have quota files named [a]quota.user and [a]quota.group located at the root of the associated filesystem. If a file is not present, quotacheck will create it.
 
Old 05-25-2016, 12:58 PM   #9
fanoflq
Member
 
Registered: Nov 2015
Posts: 235

Original Poster
Rep: Reputation: Disabled
Quote:
quotacheck expects each filesystem to be checked to have quota files named [a]quota.user and [a]quota.group located at the root of the associated filesystem. If a file is not present, quotacheck will create it
But I did not ran quotacheck at the time before I look at /mnt/tempdir1.
I just boot up and look at /mnt.tempdir1,
and aquota.user shows up.
I also deleted tempdir1 before reboot!
 
Old 05-25-2016, 04:29 PM   #10
MadeInGermany
Member
 
Registered: Dec 2011
Posts: 198

Rep: Reputation: 76
Maybe the /dev/sda5 was mounted some time ago, with quotas enabled?

I still do not understand why a simple entry in fstab plus one time a mkdir does not work for you.
 
Old 05-25-2016, 06:47 PM   #11
fanoflq
Member
 
Registered: Nov 2015
Posts: 235

Original Poster
Rep: Reputation: Disabled
Quote:
Maybe the /dev/sda5 was mounted some time ago, with quotas enabled?
Not sure.
I may have to delete and a retry....

Quote:
I still do not understand why a simple entry in fstab plus one time a mkdir does not work for you.
I was trying to do it using scripts and config files.
 
Old 05-26-2016, 02:36 PM   #12
fanoflq
Member
 
Registered: Nov 2015
Posts: 235

Original Poster
Rep: Reputation: Disabled
Quote:
Maybe the /dev/sda5 was mounted some time ago, with quotas enabled?

I still do not understand why a simple entry in fstab plus one time a mkdir does not work for you.
It turns out you do not have to create the path and subdirectory needed for a mount point. It is created (by who?) when command in /etc/fstab were executed at boot time.

I unmounted /mnt/tempdir, and deleted all directories in /mnt.
I also commented out everything I did in /etc/rc.local
Then created another partition, /dev/sda8, format it with ext4, and put it in /etc/fstab like so:
/dev/sda5 /mnt/tempdir ext4 defaults 0 0
/dev/sda8 /mnt/temp ext4 default 0 0

Recall that /dev/sda5 is the partition that auto-magically has aquota.user when it is mounted to /mnt/tempdir.

and now I reboot ...there is no aquota.user auto-magically create for /dev/sda8 in /mnt/temp:

Quote:
[user1@localhost mnt]$ ls -al /mnt/temp
total 13
drwxr-xr-x. 3 root root 1024 May 26 13:50 .
drwxr-xr-x. 4 root root 31 May 26 13:53 ..
drwx------. 2 root root 12288 May 26 13:50 lost+found
So I suspect there is a command that I may have done previously that creates aquota.user in /mnt/temp as shown here:
Quote:
[user1@localhost mnt]$ ls -al /mnt/tempdir
total 8
drwxr-xr-x. 2 user1 user1 1024 May 25 12:29 .
drwxr-xr-x. 4 root root 31 May 26 13:53 ..
-rw-------. 1 root root 6144 May 25 12:34 aquota.user
Question#1: Why is directory "lost+found" not shown in /mnt/tempdir but it is shown in /mnt/temp?

Below shows sda5 and sda8 are type ext4:
Quote:
[user1@localhost mnt]$ sudo parted -l
[sudo] password for user1:
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary xfs boot
2 525MB 11.5GB 11.0GB primary lvm
3 11.5GB 12.0GB 524MB extended
5 11.5GB 11.5GB 52.4MB logical ext4
6 11.5GB 11.6GB 78.6MB logical
7 11.6GB 11.7GB 52.4MB logical linux-swap(v1)
8 11.7GB 11.8GB 105MB logical ext4
I thought quota was enable in /mnt/tempdir, but that is not the case:
Quote:
[user1@localhost mnt]$ quota -u -f /mnt/tempdir
quota: Mountpoint (or device) /mnt/tempdir not found or has no quota enabled.
quota: Not all specified mountpoints are using quota.
Quote:
[user1@localhost mnt]$ mount | grep temp
/dev/sda8 on /mnt/temp type ext4 (rw,relatime,seclabel,data=ordered)
/dev/sda5 on /mnt/tempdir type ext4 (rw,relatime,seclabel,data=ordered)
Question#2:
Recall that there is nothing in /etc/fstab or /etc/rc.local command line that cause the creation of quotas in /mnt/tempdir, so how do I prevent aquota.user from being created in case for /dev/sda5?

Last edited by fanoflq; 05-26-2016 at 02:43 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
compute cluster runs old script after changing the script Reignfire Linux - Server 1 09-27-2012 06:35 AM
Script runs Manually but not in Cron, yet other parts of the script run mccartjd Linux - Newbie 5 01-08-2012 07:54 PM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 07:19 PM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 11:48 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM


All times are GMT -5. The time now is 12:48 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration