On Tue, Jun 09, 2009 at 05:25:33PM -0500, Boyd Stephen Smith Jr. wrote: > In <[email protected]>, Zhengquan Zhang > wrote: > >On Mon, Jun 08, 2009 at 04:01:41PM -0500, Boyd Stephen Smith Jr. wrote: > >> (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. > > Note that the numbers above exactly match the numbers below. Above is > goals/semantics; below is actions/commands. > > >> Example: splitting / into / and /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.) > > > >I don't understand this. Why do I need to remount / read only? > > Because we are going to make a copy of (part of) it. If other programs make > changes during the time it we are making our copy, our copy might be > inconsistent or out-of-date. Therefore, we can't allow other programs to be > writing changes until we are done getting our copy.
Thanks Boyd for another informative reply. Now I think I somewhat understand now. Could you please confirm me on another question? If I use a system rescue disk and do this with out the rsync command. mount /dev/debian/var /var the device /dev/debian/var is still empty and so we need the rsync step, is it correct? Thanks again for your time and patience, Zhengquan > > You will need to make read-only whatever file system is being split. > > >> 3. mount /dev/debian/var /mnt > > > >Why do I need to mount the lv to mnt? > > This is a temporary location so that you can populate the new file system > without disturbing the rest of the system. > > >> 4. rsync -HaAxX --progress --stats /. /mnt/. > > > >So everything in / will have a copy in /mnt ? > > Yes, but it won't descend into file systems mounted below /. In particular, > /mnt doesn't contain a copy of /mnt! (An impossible situation, but that > doesn't stop a computer from trying if you give it the right directions.) > > >and because we have mounted var lv to /mnt. var lv has a copy of > >everything in / ? > > Ah, good catch. The correct command would be: > rsync -HaAxX --progress --stats /var/. /mnt/. > > We only want the new lv to contain a copy of /var. > > >> 5. umount /mnt > > > >I don't understand this. > > Simply removes the new file system from its temporary mount point, since it > is now ready to be used in its permanent location. > > >> 6. mount /dev/debian/var /var > > > >So now var lv is mounted to /var and it now has everything in /var? > > Yes. > > >> 7. mount -o remount,rw / > > > >Till here I am totally confused.. > > This makes '/' read-write again. Note that '/var' was read-write as soon as > you finished step 6, since it is now a separate file system. This command > makes whatever else in is '/' read-write. For example, /root. > > >> 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/.[!.]* > > This is definitely wrong, and would have made you very unhappy. The correct > command is: > rm -rf /mnt/var/* /mnt/var/.[!.]* > > This is removing the old version of /var that is part of the old file > system. The current version is already on the new file system and in active > use. > > >> 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. > > HTH > -- > Boyd Stephen Smith Jr. ,= ,-_-. =. > [email protected] ((_/)o o(\_)) > ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' > http://iguanasuicide.net/ \_/ > -- Zhengquan -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

