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

Re: LVM reorganization [follow-up]



Boyd Stephen Smith Jr. wrote:
On Wednesday 2008 December 17 23:30:04 M.Lewis wrote:
Boyd Stephen Smith Jr. wrote:
On Wednesday 2008 December 17 23:00:41 M.Lewis wrote:
Given a Lenny LVM setup as follows:

Is it possible to reorganize the current LVM to separate out say /var &
/tmp into their on LV?
Any free space on the VG? Or, can you make some by shrinking one of the
filesystems and then shrinking it's associated VG?
No, free space is all used in LVs. Yes, I can shrink /home easily by
10-20GB.

Then, I'd:
--- Prep ---
 1. Go down to or boot into single-user mode.
 2. Unmount /home
 3. Size down /home and then rattler/home
4. Optional: make sure the /home filesystem is still fine -- at this point reverting the lv shrinking is fairly easy. --- 5. Make new lvs for /var and /tmp. (BTW, if you have 1G or more, you might just put /tmp on tmpfs.)
 6. Make the new filesystems for /var and /tmp.
7. If possible, remount / read-only. If writing isbeing done to files in the old /var or /tmp during or after the rsync, you'll lose some of that data
 8. Mount the new /var and /tmp in the right place.
--- Data Migration ---
 9. Mount with -o bind / on /mnt.
10. Rsync /mnt/var/. to /var and /mnt/tmp/. to /tmp.
11. rm -rf /mnt/{var,tmp}/{.[!.],}*
12. Umount /mnt.
--- Finishing touches --
13. Add new /var and /tmp to /etc/fstab.
14. Reboot normally or simply walk the system up to your normal multi-user run level.


For those that might have been following this thread, the process has been completed now and all went well. Many thanks to Boyd for the detailed explanations along the way.

This was all brought about my my stupidly selecting auto-partitioning with a separate /home during the install.

The detailed steps follow (hopefully the wrapping doesn't screw up):

Boot the machine with the Knoppix Live CD
Open a shell window.
Become root.

lvm vgchange --ignorelockingfailure -P -a y # this is done to make the vg 'live' on the target machine

e2fsck -f /dev/curley/home # check consistency before starting (may be required by resize2fs?) resize2fs /dev/curley/home 30G # change the size of (fs) /dev/curley/home from whatever it is, to 30GB
lvreduce -L 30G /dev/curley/home		# change the size of the lv to 30G

lvcreate -L8500M -nvar curley			# make 1/2 of the new space into lv var
lvcreate -L8500M -ntmp curley			# make 1/2 of the new space into lv tmp

mkfs.ext3 -j /dev/curley/var			# format the new var fs
mkfs.ext3 -j /dev/curley/tmp			# format the new tmp fs

mkdir /mnt/root					# make a mounting point for the root fs
mkdir /mnt/newtmp				# make a mounting point for the new tmp fs
mkdir /mnt/newvar				# make a mounting point for the new var fs

mount /dev/curley/root /mnt/root		# mount the root fs of the target drive
mount /dev/curley/var /mnt/newvar		# mount the new var fs
mount /dev/curley/tmp /mnt/newtmp		# mount the new tmp fs

rsync -avH /mnt/root/var/* /mnt/newvar		# rsync oldvar to newvar
rsync -avH /mnt/root/tmp/* /mnt/newtmp		# rsync oldtmp to newtmp

rm -fr /mnt/root/var				# remove old /var
rm -fr /mnt/root/tmp				# remove old /tmp

edit /mnt/root/etc/fstab			# add the new var & tmp mountings to /etc/fstab

mkdir /mnt/root/tmp				# I'm not sure why this was necessary
chmod 1777 /mnt/root/tmp			# change the perms for /tmp


--

 LISP: To call a spade a thpade.
  00:45:01 up 5 days, 22 min,  1 user,  load average: 0.00, 0.04, 0.01

 Linux Registered User #241685  http://counter.li.org


Reply to: