[SOLVED] Problem with sudo after creating new logical volume and mount to /var
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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
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/
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.
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
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
Next, I renamed /var to /var.old using
mv /var /var.old
I then made a new /var directory using
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