[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: split root logical volume to var tmp home etc



On Mon, Jun 08, 2009 at 04:01:41PM -0500, Boyd Stephen Smith Jr. wrote:
> In <[🔎] 20090608200757.GA26453@m364d1.ece.northwestern.edu>, Zhengquan Zhang 
> wrote:
> >Now I would like to follow other list member's advice to have separate
> >LVs for var, tmp, home etc. But I don't know how to perform the
> >operation to make it happen, I have skimmed lvm howto but I don't see a
> >chapter detailing on this task.
> 
> That because it has nothing is particular to do with LVM.  It is just like 
> splitting / into multiple partitions or across multiple disks:

It turned out I still don't understand the steps after I thought for
quite a while.

> 
> (0. [LVM specific] Create the new logical volume(s).)
> 1. Create new file system(s) on the block devices. [LVM: logical volumes]
> 2. Remount the original file system read-only.
> 3. Mount the new file system somewhere temporary.
> 4. Copy the data across.
> 5. Unmount the new file system.
> 6. Mount the new file system in it's permanent location.
> 7. Remount the old file system read-write.
> 8. Update /etc/fstab.
> (Here you may want to reboot to make sure the system will do so without 
> manual intervention, to make sure your changes to the fstab are correct, and 
> to make sure any of the files that have been moved the the new file system 
> are no longer open on the old file system.)
> 
> 9. Bind mount the old file system somewhere temporary.
> 10. Remove the data from the old file system via the bind mount.
> 11. Un- bind mount the old file system.
> 
> Example: splitting / into / and /var:
> 0. lvcreate -L 8G -n var debian

I understand this.

> 1. mkfs.ext3 /dev/debian/var

I understand this.

> 2. mount -o remount,ro /
> (The above command probably won't work because some things are constantly 
> writing to [e.g.] /var/log.  You might try something like: fuser -mk / && 
> mount -o remount,ro /.  Or, you might just work from a system rescue disk.)

I don't understand this. Why do I need to remount / read only?


> 3. mount /dev/debian/var /mnt

Why do I need to mount the lv to mnt?

> 4. rsync -HaAxX --progress --stats /. /mnt/.

So everything in / will have a copy in /mnt ?

and because we have mounted var lv to /mnt. var lv has a copy of
everything in / ?

> 5. umount /mnt

I don't understand this.

> 6. mount /dev/debian/var /var

So now var lv is mounted to /var and it now has everything in /var? 

> 7. mount -o remount,rw /

Till here I am totally confused..

> 8. echo '/dev/debian/var	/var	ext3	relatime,acl	0	2' >> /etc/fstab
> (If you want: /sbin/shutdown -r now -t 5.)
> 9. mount -o bind / /mnt
> (Okay, so now /etc/fstab and /mnt/etc/fstab are the same file.  However, 
> /var/log/messages is on the new filesystem and /mnt/var/log/messages is on 
> the old file system.)
> 10. rm -rf /mnt/* /mnt/.[!.]*
> 11. umount /mnt

Sorry Boyd I don't quite understand, but thanks for your detailed reply
and I would greatly appreciate it if you can still help me to understand
it.

Regards,
Zhengquan


Reply to: