-   Linux - Newbie (
-   -   Problem with sudo after creating new logical volume and mount to /var (

swilsy 11-25-2012 06:36 PM

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

TobiSGD 11-25-2012 06:47 PM

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?

swilsy 11-25-2012 06:53 PM

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:

TobiSGD 11-25-2012 07:32 PM

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.

swilsy 11-25-2012 08:32 PM

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

swilsy 11-25-2012 08:33 PM

In case is wasn't obvious from the previous post. Everything seems to be working just fine.

TobiSGD 11-25-2012 08:50 PM

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.

swilsy 11-25-2012 10:06 PM

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?

TobiSGD 11-25-2012 10:15 PM

The errors=remount-ro option causes that the partition will be remounted read-only if file-system errors occur to prevent further corruption,

All times are GMT -5. The time now is 11:21 PM.