Custom partitioning
When the os is installed everything is lumped into one root partition.
I have tried creating the required disks on linode's dashboard, then booting the OS via the rescue image to mount the new disks and copy over the files (before modifing fstab), but the system went down in flames!
Has anyone got a guide to show how to do this with linode as i am struggling without a diskdroid type installer.
i was looking at creating the following partitions:
/
swap
/home
/opt
/tmp
/var
/var/log
Any help would be greatly appreciated - or do most linode users not bother with this?
jk
6 Replies
1) Deploy the distro as small as possible.
2) Create all the other disk images the sizes you want.
3) Boot into rescue mode (note which image is on which device node)
4) Mount all the images into unique locations (/media/xvda, /media/xvdb, etc)
5) For each of the folders you want to move: cp -au /media/xvda/var/* /media/xvde/ … then blow away the source 'rm -rf /media/xvda/var/*'
6) Edit /media/xvda/etc/fstab to reflect the mounts [when not in rescue mode].
7) Modify your configuration profile to reflect the new disk mappings
8) Reboot.
9) Profit?
-Chris
@caker:
5) For each of the folders you want to move: cp -au /media/xvda/var/* /media/xvde/ … then blow away the source 'rm -rf /media/xvda/var/*'
Since you want /var and /var/log as separate partitions, make sure the above step is done on /var/log before you do it on /var.
I tried something similar, but i must have messed things up somewhere.
Am i on the right lines if, in rescue mode, I mount and copy as follows?
mkdir /mount/home
mkdir /mount/tmp
mkdir /mount/opt
mkdir /mount/var
mkdir /mount/var/log
mount /dev/xvda /mnt <– this is the root device for the Linode OS installation
mount /dev/xvdc /mount/home
mount /dev/xvdd /mount/tmp
mount /dev/xvde /mount/opt
mount /dev/xvdf /mount/var
mount /dev/xvdg /mount/var/log
cp -au /mnt/home/* /mount/home/
cp -au /mnt/tmp/* /mount/tmp/
cp -au /mnt/opt/* /mount/opt/
cp -au /mnt/var/log/* /mount/var/log/ <-- thanks Stever i defo messed this up on the first attempt
cp -au /mnt/var/* /mount/var/
I'm not 100% confident about the above commands, but this bit really concerns me
rm -rf /mnt/home/*
rm -rf /mnt/tmp/*
rm -rf /mnt/opt/*
rm -rf /mnt/var/*
rm -rf /mnt/var/log/*
umount /mnt
umount /mount/home
umount /mount/tmp
umount /mount/opt
umount /mount/var
umount /mount/var/log
shutdown -h now
I tried adjusting fstab before this shutdown on my first attempt as i wasn't sure if the OS could reboot properly without knowing where all the deleted files have gone - Anyway, i will give it a go.
When i delete the home dir i think my ssh info will also go so i guess i will need to re-enable root login via ssh get back into the machine without having to use the Linode lish console
Upon restart, would I modify the mount points for the new disk images roughly as follows?
/etc/fstab: static file system information.
#
proc /proc proc defaults 0 0
/dev/xvda / ext3 errors=remount-ro 0 1
/dev/xvdc /home ext3 defaults,nosuid,nodev 0 2
/dev/xvdd /tmp ext3 defaults,nosuid,nodev 0 2
/dev/xvde /opt ext3 defaults,nodev 0 2
/dev/xvdf /var ext3 defaults,nosuid,nodev 0 2
/dev/xvdg /var/log ext3 defaults,nosuid,nodev,noexec 0 2
reboot
Any assistance/corrections from anyone would be very welcome.
jk
However, i had to start completely from scratch with no disks created at the dashboard; then deploy the distro before creating the disks for the additional partitions via the dashboard.
Before i booted into the finnix rescue iso i also needed to edit the configuration profile so that each disk was assigned to the block device i wanted it to be assigned to (otherwise it was too much of a swine to try and track what was happening).
The commands i eventually used were as follows:
mount /dev/xvda /media/xvda <– this is the root device for the Linode OS installation
mount /dev/xvdc /media/xvdc <-- Home
mount /dev/xvdd /media/xvdd <-- Tmp
mount /dev/xvde /media/xvde <-- Opt
mount /dev/xvdf /media/xvdf <-- Var
mount /dev/xvdg /media/xvdg <-- VarLog
finnix was on xvdh*
cp -au /media/xvda/home/* /media/xvdc/
cp -au /media/xvda/tmp/* /media/xvdd/
cp -au /media/xvda/opt/* /media/xvde/
cp -au /media/xvda/var/log/* /media/xvdg/
cp -au /media/xvda/var/* /media/xvdf/
rm -rf /media/xvda/home/*
rm -rf /media/xvda/tmp/*
rm -rf /media/xvda/opt/*
rm -rf /media/xvda/var/*
mkdir /media/xvda/var/log
umount /media/xvda
umount /media/xvdc
umount /media/xvdd
umount /media/xvde
umount /media/xvdf
umount /media/xvdg
shutdown -h now
The machine still need to be shutdown via the dashboard after using this command.
A couple of reboots later and ssh was available again.
I then modified the fstab as follows:
/etc/fstab: static file system information.
#
proc /proc proc defaults 0 0
/dev/xvda / ext3 errors=remount-ro 0 1
/dev/xvdc /home ext3 defaults,nosuid,nodev 0 2
/dev/xvdd /tmp ext3 defaults,nosuid,nodev 0 2
/dev/xvde /opt ext3 defaults,nodev 0 2
/dev/xvdf /var ext3 defaults,nosuid,nodev 0 2
/dev/xvdg /var/log ext3 defaults,nosuid,nodev,noexec 0 2
After saving fstab and making a couple of reboot attempts from Linode's dashboard i was able to log back in and check if it had worked.
df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda 1033208 355280 635988 36% /
tmpfs 254932 0 254932 0% /lib/init/rw
udev 10240 136 10104 2% /dev
tmpfs 254932 0 254932 0% /dev/shm
/dev/xvdc 253920 16428 234872 7% /home
/dev/xvdd 1032088 32828 988776 4% /tmp
/dev/xvde 3628452 65628 3525960 2% /opt
/dev/xvdf 5039616 222012 4766404 5% /var
/dev/xvdg 5007296 131440 4824984 3% /var/log
Thanks for you assistance Steve and Chris.
jk
@theNADS:
cp -au /media/xvda/home/* /media/xvdc/
cp -au /media/xvda/tmp/* /media/xvdd/
cp -au /media/xvda/opt/* /media/xvde/
cp -au /media/xvda/var/log/* /media/xvdg/
cp -au /media/xvda/var/* /media/xvdf/
rm -rf /media/xvda/home/*
rm -rf /media/xvda/tmp/*
rm -rf /media/xvda/opt/*
rm -rf /media/xvda/var/*
You could save yourself a couple steps by moving the data from one location to the other:
mv /media/xvda/home/ /media/xvdc/
mv /media/xvda/tmp/ /media/xvdd/
mv /media/xvda/opt/ /media/xvde/
mv /media/xvda/var/log/ /media/xvdg/
mv /media/xvda/var/ /media/xvdf/
–
Travis
@otherbbs:
You could save yourself a couple steps by moving the data from one location to the other:
mv /media/xvda/home/ /media/xvdc/ mv /media/xvda/tmp/ /media/xvdd/ mv /media/xvda/opt/ /media/xvde/ mv /media/xvda/var/log/ /media/xvdg/ mv /media/xvda/var/ /media/xvdf/
Remember to add a * after the source directories (mv /media/xvda/home/* /media/xvdc/, etc)… otherwise, you'll end up with /home/home/alice, /home/home/bob, etc, after you mount /dev/xvdc on /home.