Post installation re-partitioning: how to move /var?
I've have a file & print server running Debian woody on a 500mb partition (uses just over 2/3 of it), but had not realised that /var could fluctuate so much, & dont want it to clog the disk. I''d rather keep the partition small so that I can easily reinstall from backup if need be. I've read* that its good practice to keep certain directories on different partitions, and have all the /home directories on a separate disk, but unsure how to move /var now that all is set up.
Is it just a case of repartitioning some empty space on the disk (say with cfdisk) and editing /etc/fstab to point to it? Do I need to manually shift stuff over? Is there anything else I would need to edit to make sure that the system knew that the location had changed? I know that this is a case of 'I wouldnt start frm there...' but I would really rather not reinstall all over again... again. ;-] * http://www.debian.org/doc/manuals/se...3.en.html#s3.2 http://wwwcmc.pharm.uu.nl/gillies/debian/ All the best, Wolfpeach |
Something that may help you in debian is qparted which allows moves in some cases.
http://ftp.gnu.org/gnu/parted/ Much like partition magic. What you can do backup your var data to a removable media or the like, rm -rf your /var partition, add the new drive with the /var partition formatted and mount. Qparted will assist with this. cfdisk can do it as well, but I think it sucks- YMMV. It's not as bad as it seems. You just need to get your data off both drives to make sure it isn't lost. Or if you're a gunslinger, you can just copy it over to another directory like /root/ohcrap. Have fun. Thor |
Thanks Thor!
Have copied /var over to another partition (hda3), and am editing fstab to mount it at boot & point to it... just wondering what the mount point should be given as... Its currently copied over as /var, so should the mount point be / or /var? (ie, keep an empty /var directory on hda1, and copy over just the contents of /var to hda3... ) agghhh.... getting confused here! :confused: btw, Gnuparted looks fun, will give it a spin sometime. |
OK - sorted now (minus a few fingernails tho! - thank god for the backup I took with tar last week!)
Heres how: 1) make the new partition, & format with mkfs. (in my case hda3) 2) mount the new filesystem in /mnt # mkdir /mnt/new # mount /dev/hda3 /mnt/new 3) Go to single-user mode so that there is no rw activity on the directory during the process (could be messy...) # init 1 (re-enter root password - wont work via ssh... gave me a shock!!) 4) Backup data in var only (not the /var directory itself) # cd /var # cp -ax * /mnt/new 5) Rename the /var directory (to make sure this has worked before deleting it!) # cd / # mv var var.old 6) Make new var directory # mkdir var 7) Unmount the new partition # umount /dev/hda3 8) Remount it as /var # mount /dev/hda3 /var 9) Edit /etc/fstab to include the new partition, with /var given as the mount point, so that it will be included in the filetree automatically at boot. & when y'r sure that alls well, delete var.old... Bingo. :cool: |
hey, nice, thanks for the explanation!
I wanted to free up some diskspace of my rootpartition too, and had an empty 150 MB partition around. Just enough for the javasdk :). Worked perfectly, as it is nothing system-critical and all javastuff is in one directory. Thanks |
All times are GMT -5. The time now is 10:41 PM. |