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!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to add a new partition to my Centos 6.5 box. I want it to be ext3 with barriers=0.
I've come up with the following steps, but before trying, would like someone to give it a quick look and make sure I am not going to do anything bad. Also, in the steps, I have four questions and would appreciate some clarification on them. At the end of this post, I provided some information about my current configuration.
Thank you!
Code:
# Steps to add a 100G partition with ext3 and barriers=0 using LVM
# Note that you must be logged on directly as root so that lv_home isn't being used
umount /dev/VolGroup/lv_home
# IMPORTANT. First, reduce the filesize to something smaller (10%?) than the new volumn size
# Question 1. How do I know the current filesize, and that I am not doing something too small?
resize2fs /dev/VolGroup/lv_home 900G
# Shrink the volumn to make space for the new partion
lvreduce -L 1000G /dev/VolGroup/lv_home
# Allow file to take remaining space in volumn
resize2fs /dev/VolGroup/lv_home
# Mount home back to normal
mount -t ext4 /dev/VolGroup/lv_home /home
# Add a new volumn
# Question 2. How can I tell it to use all remaining space?
lvcreate -L 100G -n lv_mysql VolGroup
# Partition the volumn
mkfs -t ext3 /dev/VolGroup/lv_mysql
# To move files, stop mysql, move /var/lib/mysql to a temp directory,
service mysqld stop
mv /var/lib/mysql /var/lib/mysql.bak
# Mount the new partition
mount -t ext3 -o barrier=0 /dev/VolGroup/lv_mysql /var/lib/mysql
mv /var/lib/mysql.bak/* /var/lib/mysql
service mysqld start
# Question 3. How do I update /etc/fstab to automatically mount?
# Question 4. Is how I moved /var/lib/mysql of the /home partition to the new ext3 partition correct?
Existing configuration
Code:
[root@devserver ~]# mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/VolGroup-lv_home on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[root@devserver ~]# fdisk -l /dev/sda
Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00056f9a
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 182402 1464625152 8e Linux LVM
[root@devserver ~]# lvdisplay
--- Logical volume ---
LV Path /dev/VolGroup/lv_root
LV Name lv_root
VG Name VolGroup
LV UUID 3LPnlL-M45t-Bc2k-Pe4y-OnP0-woWd-53h4Sa
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2014-04-19 05:52:22 -0700
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/VolGroup/lv_home
LV Name lv_home
VG Name VolGroup
LV UUID sXZfcT-Onaj-t9xi-OG0C-3s0Z-gwcT-IqVku0
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2014-04-19 05:52:30 -0700
LV Status available
# open 1
LV Size 1.31 TiB
Current LE 343282
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/VolGroup/lv_swap
LV Name lv_swap
VG Name VolGroup
LV UUID KPJ2YB-NtyE-hoFF-tq85-0e8E-Lv2N-FdAM5j
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2014-04-19 05:55:29 -0700
LV Status available
# open 1
LV Size 5.83 GiB
Current LE 1492
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@devserver ~]# ls -l /dev/mapper
total 0
crw-rw----. 1 root root 10, 58 Apr 21 23:12 control
lrwxrwxrwx. 1 root root 7 Apr 21 23:48 VolGroup-lv_home -> ../dm-2
lrwxrwxrwx. 1 root root 7 Apr 21 23:48 VolGroup-lv_root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Apr 21 23:48 VolGroup-lv_swap -> ../dm-1
[root@devserver ~]#
Last edited by NotionCommotion; 04-24-2014 at 10:09 AM.
Answer to #1: To find the size of the filesystem you can run df -h and the table will show you how much free space you have left in the logical volume.
Answer to #2: You can run pvscan and that will show you how much space is left on the pv. Just use that after the "-L".
Answer to #3: Just use a text editor to edit /etc/fstab...I prefer using vi so your command would be vi /etc/fstab Then just follow the same syntax as what is already listed there. After saving your changes you can run "mount -a" and that will read /etc/fstab and if you have the entry in correctly it will mount your new filesystem.
Answer to #4: It looks correct. I'm not sure how mysql handles manually moving libraries though.
# IMPORTANT. First, reduce the filesize to something smaller (10%?) than the new volumn size
# Question 1. How do I know the current filesize, and that I am not doing something too small?
resize2fs /dev/VolGroup/lv_home 900G
resize2fs won't let you make the filesystem too small for its current contents.
Quote:
# Add a new volumn
# Question 2. How can I tell it to use all remaining space?
lvcreate -L 100G -n lv_mysql VolGroup
Instead of "-L 100G" use "-l 100%FREE" (lower-case "L", or "--extents").
Quote:
# Partition the volumn
mkfs -t ext3 /dev/VolGroup/lv_mysql
That is "formatting", not "partitioning" (the only error is in the comment).
Quote:
# Mount the new partition
mount -t ext3 -o barrier=0 /dev/VolGroup/lv_mysql /var/lib/mysql
mv /var/lib/mysql.bak/* /var/lib/mysql
service mysqld start
# Question 3. How do I update /etc/fstab to automatically mount?
# Question 4. Is how I moved /var/lib/mysql of the /home partition to the new ext3 partition correct?
In place of that final "mv", I would use
Code:
cp -a /var/lib/mysql.bak/ /var/lib/mysql
and later delete the originals after I was sure everything was working. Note that I left off the trailing "*" in "/var/lib/mysql.bak/*". The trailing "*" would not include any dotfiles in that directory. Ending that argument with the "/" lets cp do the recursion and include the dotfiles. That little trick won't work for your mv command, which would also have omitted any dotfiles (not that I know whether there actually are any in /var/lib/mysql).
Everything seems to be working MySQL is okay with moving the library. For unknown reasons, MySQL runs about 80 times slower if I use the default configuration on my hardware. Ever heard anything like that?
I was considering the following but wasn't sure if it was all space or all remaining space . Didn't want to take the chance without knowing for sure.
Code:
lvcreate -l 100%FREE -n lv_mysql VolGroup
I suppose I could do the following to regain the space after the fact as I already did the steps described in my original post. Agree?
"/dev/VolGroup/lv_mysql" and "/dev/mapper/VolGroup-lv_mysql" refer to the same thing. It doesn't matter which one you use, so go along with what is used in the rest of your /etc/fstab.
"100%FREE" is pretty explicit in meaning 100% of the free space in the VG. The command you want for expanding your current LV is lvextend, and you would want "-l +100%FREE" for that. (Without the "+" sign I believe it would set the size of the LV to whatever the current free space was, which might be smaller than the LV's current size. Pardon me for not actually trying that out.)
Since I was the one who suggested that, I guess I have to share in the blame, but I don't see what is wrong with it.
With the system running, put that line back in /etc/fstab, perhaps changing "barrier=0" to "barrier=0,noauto" to stop the automatic mounting during boot, and then see what messages you get from a simple
Code:
mount /var/lib/mysql
At least that way you can record the error messages.
Personally, when I intend on messingvwith fstab I manually mount, see man mount for options
Edit: then unmount!
I then edit fstab, and then mount the mountpoint
E.g.
Code:
mount /var/lib/mysql
Since you are 'messing' with mysql, I would stop mysql before that, restarting after the mount
And .... go from there..
But...
I wouldn't expect an unbootable system from what you did, but maybe I missed something
So, lets's get some points straight:
- it did boot; init handles fstab
- whoever updated fstab is responsible, not fstab.
- why are you trying to disable write barriers in ext3 (which doesn't enable them by default) ?.
Thanks, my mistake apparently - I (now) see a bug filed against Redhat. I remember all the discussion on barriers as a feature for ext4, and took the (Fedora) manpage as authoratative.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.