LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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, 07:36 PM   #1
swilsy
LQ Newbie
 
Registered: May 2012
Location: Salt Lake City
Distribution: Ubuntu Server 12.04
Posts: 22

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, 07:47 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,614
Blog Entries: 2

Rep: Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070
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, 07:53 PM   #3
swilsy
LQ Newbie
 
Registered: May 2012
Location: Salt Lake City
Distribution: Ubuntu Server 12.04
Posts: 22

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, 08:32 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,614
Blog Entries: 2

Rep: Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070
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, 09:32 PM   #5
swilsy
LQ Newbie
 
Registered: May 2012
Location: Salt Lake City
Distribution: Ubuntu Server 12.04
Posts: 22

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, 09:33 PM   #6
swilsy
LQ Newbie
 
Registered: May 2012
Location: Salt Lake City
Distribution: Ubuntu Server 12.04
Posts: 22

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, 09:50 PM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,614
Blog Entries: 2

Rep: Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070
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, 11:06 PM   #8
swilsy
LQ Newbie
 
Registered: May 2012
Location: Salt Lake City
Distribution: Ubuntu Server 12.04
Posts: 22

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, 11:15 PM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,614
Blog Entries: 2

Rep: Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070
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 08:02 AM
creating logical volume of exact specified size devkpict Linux - Software 1 07-16-2009 04:59 AM
How to resize a logical volume mounted as /var (FC9) prabhatsoni Linux - Hardware 10 01-04-2009 04:40 PM
Creating a logical volume on RHEL3 samash Red Hat 3 06-17-2006 12:31 PM
How do I move /var to a logical volume? bret Linux - General 5 02-03-2006 12:59 PM


All times are GMT -5. The time now is 12:11 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration