LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-25-2012, 06:36 PM   #1
swilsy
Member
 
Registered: May 2012
Distribution: Ubuntu Server 16.04/Lubuntu 18.04
Posts: 36

Rep: Reputation: Disabled
Problem with sudo after creating new logical volume and mount to /var


I am running Ubuntu Server 12.04 64-bit. I am using LVM. I was doing some research on creating a MediaWiki server when I found a how-to with a partitioning scheme laid out. It recommended creating separate logical volumes, including one for /var (I think because files and data will be stored there, and it may need to grow over time). There is already a logical volume called root mounted at / with ext4 as its filesystem type. My issue came up after mounting a newly created logical volume to /var. Now, whenever I type sudo before a command I get this:

sudo: unable to mkdir /var/lib/sudo: No such file or directory

To be clear when the logical volume is mounted at /var, I get the above sudo: message everytime I type sudo before a command. Though it does ask for my password right after printing that statement, and whatever command I typed works as usual. As soon as I umount the logical volume from /var, everything works as usual.

Below is the series of commands I used to create my logical volume then mount it at /var, just in case I missed something.The volume group I am using is called serviceYourHours.

sudo lvcreate -L 5G -n var_1 serviceYourHours

sudo mke2fs -t ext4 /dev/serviceYourHours/var_1
I could use some help here understanding when to use ext2, ext3, and ext4. I have two other logical volumes formatted as ext3 and one as ext4

sudo mount /dev/serviceYourHours/var_1 /var
 
Old 11-25-2012, 06:47 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Have you copied the original content from /var to the new partition or do you just have mounted it over the old content, hiding it with that?
 
Old 11-25-2012, 06:53 PM   #3
swilsy
Member
 
Registered: May 2012
Distribution: Ubuntu Server 16.04/Lubuntu 18.04
Posts: 36

Original Poster
Rep: Reputation: Disabled
I did not copy the data from /var. I found another thread which mentions that, but I don't really understand why I need to copy the data. I'm sorry for the ignorance, I'm just staring to get comfortable with linux. Other thread I found: http://www.linuxquestions.org/questi...volume-411038/
 
Old 11-25-2012, 07:32 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
If you mount a file-system to a directory that contains already files and directories, that content will be hidden and becomes inaccessible. Many of the files in /var are needed for the system to function properly, so you should move them over to the new file-system.
 
1 members found this post helpful.
Old 11-25-2012, 08:32 PM   #5
swilsy
Member
 
Registered: May 2012
Distribution: Ubuntu Server 16.04/Lubuntu 18.04
Posts: 36

Original Poster
Rep: Reputation: Disabled
TobiSGD, Thank you for your replies. I reread the the thread mentioned above, and thought about it some more. I think this makes sense to me now. When I create a new logical volume, I am creating a reserved section of disk space and labeling it (in this case as var_1). I then format that space as filesystem type of my choosing (in this case ext4). Now, in order to add files to that newly created disk space labeled var_1, I first have to mount it somewhere, but after files are written to the logical volume var_1 post mounting, those files remain in var_1 even if I unmount var_1 and mount it somewhere else. In my case, when I mounted var_1 to /var which already contained files and information, I covered up and made inaccessible files needed to properly run the sudo command. Upon realizing all of this, I mounted my logical volume var_1 to a new directory I created. I copied all of the files from the current /var directory to this new directory using
cp -a -r /var/* /new_dir

Then, I logged in as the root user using
sudo -i

because I was going to run into the issue I originally posted about regarding the use of sudo prior to commands in the next step when I begin moving around and replacing /var.

Unmounted /new_dir using
umount /new_dir

Next, I renamed /var to /var.old using
mv /var /var.old

I then made a new /var directory using
mkdir /var

Next, I mounted the logical volume var_1 to the newly created /var directory using
mount /dev/serviceYourHours/var_1 /var Remember, serviceYourHours is the volume group

Finally removed the /new_dir and /var.old directories using
rmdir /new_dir
rmdir /var.old

and logged out of the root user with
exit
 
Old 11-25-2012, 08:33 PM   #6
swilsy
Member
 
Registered: May 2012
Distribution: Ubuntu Server 16.04/Lubuntu 18.04
Posts: 36

Original Poster
Rep: Reputation: Disabled
In case is wasn't obvious from the previous post. Everything seems to be working just fine.
 
Old 11-25-2012, 08:50 PM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Keep in mind that you have to add a new entry to the /etc/fstab file, so that the changes keep persistent after a reboot.
 
Old 11-25-2012, 10:06 PM   #8
swilsy
Member
 
Registered: May 2012
Distribution: Ubuntu Server 16.04/Lubuntu 18.04
Posts: 36

Original Poster
Rep: Reputation: Disabled
I am looking into that right now. I notice that my root lv mounted at / has fstab option of errors=remount-ro.

What does that mean? What is wrong with using default for the option?
 
Old 11-25-2012, 10:15 PM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
The errors=remount-ro option causes that the partition will be remounted read-only if file-system errors occur to prevent further corruption,
 
1 members found this post helpful.
  


Reply

Tags
mount, partitions


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
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
creating logical volume of exact specified size devkpict Linux - Software 1 07-16-2009 03:59 AM
How to resize a logical volume mounted as /var (FC9) prabhatsoni Linux - Hardware 10 01-04-2009 03:40 PM
Creating a logical volume on RHEL3 samash Red Hat 3 06-17-2006 11:31 AM
How do I move /var to a logical volume? bret Linux - General 5 02-03-2006 11:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11: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
Open Source Consulting | Domain Registration