Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
KVM - move /var or other folder to another disk partition
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

KVM - move /var or other folder to another disk partition

Hello,

Currently my disk structure is like this

[email protected]:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 752K 394M 1% /run
/dev/vda1 7.3G 6.1G 1.2G 85% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/vdb 98G 43G 51G 46% /home
/dev/vda15 105M 3.4M 102M 4% /boot/efi
tmpfs 395M 0 395M 0% /run/user/0

As you can see the vda1 storage is pretty low now and vdb is still have a lot of space.
My question, how do we move some folder (ex /var ) from vda1 to vdb, especially on KVM environment using Ubuntu.
Thank you.

Comments

  • FalzoFalzo Member

    Boot in rescue mode so you get a shell and can mount your partitions temporarily.
    Rsync the contents of var (from mounted disk) to your new partition.
    Rename var to var.old or so.
    Change mount in fstab (mounted disk).
    Reboot.
    If everything works you can remove var.old afterwards.

    UltraVPS.eu KVM in US/UK/NL/DE: 15% off first 6 month | Netcup VPS/rootDS - 5€ off: 36nc15279180197 (ref)

  • Thank you for the help....

    Care to info me the step by step command to do that?
    Thanks..

  • There may be trouble ahead.. :/
    (Why not just 'cp -a', assuming not taking the risk of mv?)

    Long live LowEndInfo.com

  • oh man, sda15?!!!?! yikes! Reminds me why I don't use partitions any more than the two absolutely necessary, which is exactly two partitions:
    1. dmraid metadata0.90 raid1 /boot
    2. a (sometimes encrypted) LVM PV

    I've always found it delightful to put my KVM VM disks in LVM PVs of the host. SO MUCH flexibility, and no filesystems getting full. WIN 1000%

  • jackbjackb Member, Provider
    edited July 15

    @Wira_Soenaryo said:
    Thank you for the help....

    Care to info me the step by step command to do that?
    Thanks..

    If you need step by step commands to do this there's a good chance you'll lose data or render your system unbootable. Partitions and mount points are not something that you should fiddle with outside of a throwaway environment if you don't understand what you're doing.

    Have a read through what @Falzo said, read the documentation / man pages, try some of it out (where reversible) and see if it makes sense to you after that. It isn't particularly complex, but it is very important that you understand it rather than blindly copying commands from the internet.

    I'm sure people will answer questions if you have any once you've read the docs.

    Thanked by 2Falzo Wira_Soenaryo

    Afterburst - Awesome OpenVZ&KVM VPS in US+EU

  • Ok noted..

    Actually I know how to do that the easier way by make copy inside the home directory or symlink to home directory and modify the fstab as needed. I just think that maybe there are some better way to do that.

    Anyway, will think about it again..
    Thank you all...

  • FalzoFalzo Member

    var should not be moved with the system normally online. there are most likely to many open files, hence you should rather do it in rescue mode.

    Symlinks are no solution anyway. I would not even call that a workaround for important folders like /var ;-)

    UltraVPS.eu KVM in US/UK/NL/DE: 15% off first 6 month | Netcup VPS/rootDS - 5€ off: 36nc15279180197 (ref)

  • @Falzo said:
    Symlinks are no solution anyway. I would not even call that a workaround for important folders like /var ;-)

    Noted Falzo.. :)
    Thank you.

  • vimalwarevimalware Member
    edited July 16

    I think this is ultravps.eu.
    (And you're OK with restoring from backups after a re install) data loss implied.
    Here's a a more permanent solution to the 'problem'.

    Boot up the alternate installer for debian /Ubuntu. Wipe all partitions.
    Create a 500MB /boot partition on first disk ( primary partition if classic MSDos partition table) .

    Create a PV (physical volume for LVM) on remaining space on disk1. (9.5)
    Mark as another PV on disk2 (100gb)

    Make LVM group with the 9.5gb, 100gb PVs : creating a new LV. (lvm logical volume)

    Create your / partition on this 109.5gb virtual disk (/dev/mapper/LV_name) . Or make multiple partitions if you're a masochist or have special mount properties

    Hope I got the instructions right. (typing on phone)

    Figuring out how to use the debian partitioner : exercise for reader. Will come in handy.

    Thanked by 2Falzo Wira_Soenaryo

    250GB USA RAID6 StorageKVM from €13/yr (no-torrenting, TopProvider)
    (affiliate for 🥰 ) https://clients.inceptionhosting.com/aff.php?aff=401&gid=30

  • AlwaysSkintAlwaysSkint Member
    edited July 16

    Debian partitioner is truly awful compared to the CentOS one. Each are quirky, however. ;)
    Performance wise, keep VG separate for each (notional) physical disc, IMHO. I usually have one called sys, the other data. You might put / and a small (~1GB) swap in sys, with other LV/partitions in data. I never like the idea of bridging VG/LV across physical discs, unless within a RAID array - that's just me though.

    @vimalware said: Or make multiple partitions if you're a masochist or have special mount properties

    No real need to journal /tmp, given its' supposed transient files (ext2) plus can secure with nosuid, noexec. Likewise a local /backup directory (mount point). /home allows quotas specific to that file system. It's not all masochism. ;)

    Thanked by 1vimalware

    Long live LowEndInfo.com

  • leapswitchleapswitch Member, Provider

    What is consuming space in /var ? If it is say MySQL, you can simply move it to a folder under /home and do a symlink. Just need to stop MySQL during the move , no need to boot into rescue mode or similar.

    Leapswitch Networks - Affordable Managed and UnManaged VPS
    Pune/Mumbai, India - Asheville, USA - Lisbon, Portugal - Kiev, Ukraine - Barcelona, Spain - Frankfurt, Germany

Sign In or Register to comment.