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

Re: split root logical volume to var tmp home etc



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:

(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
1. mkfs.ext3 /dev/debian/var
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.)
3. mount /dev/debian/var /mnt
4. rsync -HaAxX --progress --stats /. /mnt/.
5. umount /mnt
6. mount /dev/debian/var /var
7. mount -o remount,rw /
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
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: