1

I'm using Ubuntu 10.10 - the Maverick Meerkat. And my root partition is too small to hold those two on /. Can anyone make a suggestion on how to do this:

""" create a new partition for a large moveable directory like home, var or usr. Then I rsync the directory onto the new partition and mount it. """

There was a similar subject opened on How do I change Software Center's default installation path?, but as i am pretty new to ubuntu i am struggling to reach a solution.

I want to move /usr and /var on the same partition with /home, but i don't want to make separate partitions for each one of them. For moving /home i used this solution: https://help.ubuntu.com/community/Partitioning/Home/Moving#Different_filesystems_on_the_same_disk I think i need a labeling in my fstab, can anyone tell me if this is a good idea, or give a better one?

Decebal
  • 249
  • Where are you going to relocate them to ? If you have the free space on your hard drive, it is going to be easier to resize your partitions. – Panther Dec 19 '11 at 23:43
  • can i resize my partitions without formating? i always got an error from gparted when trying to do so – Decebal Dec 19 '11 at 23:46
  • From a live CD, with the root and swap partitions unmounted. You may have to resize your partitions in steps. What error ? – Panther Dec 19 '11 at 23:48
  • however this is not a solution for what i need, i want to learn how to do a symlink !! – Decebal Dec 20 '11 at 09:19

2 Answers2

1

Since you say you don't want to move your partitions, you can do this from a live CD:

  1. Mount your root and home partitions (which I'm assuming are /dev/sda1 and /dev/sda2 respectively; check using GParted to make sure) and cd to your install's root:

    sudo mount /dev/sda1 /mnt
    sudo mount /dev/sda2 /mnt/home
    cd /mnt
    
  2. Move the directories where you want them (on /home, as you said):

    sudo mkdir -p home/outside_stuff
    sudo mv var usr home/outside_stuff
    
  3. Now, you have two options here. Choose one or the other:

    1. Use symlinks. This is the easiest method, but it isn't as robust:

      sudo ln -s home/outside_stuff/* .
      
    2. Bind mount the directories:

      • Create your mount points:

        sudo mkdir -p var usr
        
      • Add the following to /etc/fstab:

        /home/outside_stuff/var /var none bind
        /home/outside_stuff/usr /usr none bind
        
      • chroot to your system and test it:

        for i in sys proc dev; do sudo mount --bind "/$i" "/mnt/$i"; done
        sudo chroot /mnt
        mount -a    # hopefully there'll be no errors
        mount       # you should see entries for /var and /dev
        exit
        
  4. Reboot:

    sudo reboot
    
0

What you would do is boot a live CD , make new partitions.

I will assume your ubuntu root partition is at /dev/sad1 and you made two new partitions, ext4, for /usr and /var at /dev/sda2 and /dev/sda3

You then mount everything in a working directory, say /mnt/root , /mnt/usr, and /mnt/var

sudo mkdir /mnt/{root,usr,var}
sudo mount /dev/sda1 /mnt/root
sudo mount /dev/sda2 /mnt/usr
sudo mount /dev/sda3 /mnt/var

You then move your files

sudo mv /mnt/root/usr/* /mnt/usr/
sudo mv /mnt/root/var/* /mnt/var/

You then edit /mnt/root/etc/fstab and add in your new partitions

List your partitions with blkid

sudo blkid

You then edit /mnt/root/etc/fstab

# command line
sudo -e /mnt/root/etc/fstab

# graphical
gksu gedit /mnt/root/etc/fstab

Add in your new partitions

UUID=uuid_sda2_here  /usr  ext4    errors=remount-ro  0  2
UUID=uuid_sda3_here  /var  ext4    errors=remount-ro  0  2

a link will now work nor will mount --bind. You could use something such as LVM.

If that is not what you want, please clarify your question. You can not save disk space without moving the data, so sync will not save disk space. You can not add space to your root partition with a link or a mount bind, you would need to use LVM.

Panther
  • 102,067