5

I have installed ubuntu on a 8GB 5GB partition. As I have installed many packages, I am running out of space.

Qn 1 : Is there a way that I can specify another portion for installing the packages ?

Qn 2 : Can I move the whole installed files from my current partition to another place ( partition ) and make the changes in grub or so?

I don't want to reinstall the whole, so after that I just can make an upgrade :-)

The / , and home directory is in same place.

Thank you .

Hari K T
  • 242

1 Answers1

4

A1: no, it's not possible. The paths are fixed.

A2: if you want to move files to another partition, you'll need to use a Live CD. Please consider resizing partitions first which is much easier and less error-prone. This is only possible if you've enough space on one disk. Consider moving your /home folder as described here too, 8GB should be enough for / in most cases. If you want to use a second disk as root partition or wish to create a new partition on the current disk, please continue.

  1. Make a backup (preferably with disk-cloning software like Clonezilla).
  2. Boot into the Live CD, do not mount anything
  3. Create a new partition using the Disk Utility or GParted. This partition must support Linux file permissions. Such a filesystem is ext4. Label it "UbuntuRoot" so you can find the partition easier, otherwise you'll have to remember the partition name (e.g. /dev/sdb1)
  4. Open a terminal and run sudo blkid to get the UUID for your newly created partition. Example output, you'll need the last line:

    /dev/sda1: LABEL="HDD" UUID="AD078BC9C024FCDD" TYPE="ntfs"
    /dev/sda2: LABEL="DATA" UUID="FDE43758913E70EE" TYPE="ntfs"
    /dev/sda3: UUID="a88638ae-3cd3-45c0-ad06-2d56d89b19a0" TYPE="swap"
    /dev/sda4: UUID="e3f848cb-5a05-4d2d-92e0-3eaf7b27338c" TYPE="ext4"
    /dev/sdb1: LABEL="UbuntuRoot" UUID="1cdfadcf-0969-48ba-96a5-42557c23f8e9" TYPE="ext4"
    
  5. Mount your old root partition (/dev/sdb1 is your newly created partition, /dev/sda4 was your old partition):

    sudo mkdir /media/old
    sudo mount /dev/sda4 /media/old
    sudo mount /dev/sdb1 /mnt
    
  6. Copy over the files (this may take a while):

    sudo cp -prvT /media/old /mnt
    
  7. Update /mnt/etc/fstab with the new UUID. Pick an editor at your choice:

    sudo nano /mnt/etc/fstab
    gksu gedit /mnt/etc/fstab
    

    Find the line that looks like and replace the UUID of /dev/sda4 with the /dev/sdb1's UUID:

    # / was on /dev/sda4 during installation
    UUID=e3f848cb-5a05-4d2d-92e0-3eaf7b27338c /               ext4    errors=remount-ro 0       1
    
  8. Save /mnt/etc/fstab and exit the editor. Next, GRUB needs to be updated to boot from the new disk and partition.

    sudo grub-install --root-directory=/mnt /dev/sdb
    
  9. Unmount the partitions to finish it:

    sudo umount /mnt /media/old
    
  10. Reboot to check the result.
Lekensteyn
  • 174,277
  • Thank You for your quick reply on it. I will try and write the experience :-) – Hari K T Jul 23 '11 at 16:44
  • It was 5 GB only, not 8 GB. – Hari K T Aug 14 '11 at 03:43
  • 5GB is a bit low but will suffice if you're cleaning files regularly (sudo apt-get clean to clear your APT caches, browser cache). I've a fresh development installation here using only 3G including a /home of 200MB. – Lekensteyn Aug 14 '11 at 08:37
  • Sorry man , I went into trouble . Not sure how I lost my bootloader . And it was coming in the grub-rescue> terminal ( Before I tried your steps). But I went with the USB and tried your steps hoping the bootloader will install it. But all the error came when I tried to install the bootloader . I tried different ways . In yours it says root, but in the help I see boot , so to conclude these were the errors http://pastie.org/2370460 . But I had a fresh install on another partition . So now I have 2 Ubuntu :) . Anyway as the data is safe I am happy with it. – Hari K T Aug 14 '11 at 13:36
  • Read the manual if you're not sure what an option is used for. --boot-directory sets the location in which GRUB's files are placed. By default, this is /boot/grub (/mnt/boot/grub). I assume /dev/sda11 is your target partition? Otherwise, could you post the output of sudo fdisk -l and sudo blkid? – Lekensteyn Aug 14 '11 at 13:43
  • Yes sda11 it was my target which was mounted on /mnt. The other one was sda10 which was mounted on the /media/old as you suggested . – Hari K T Aug 14 '11 at 13:48
  • This is the sudo blkid and sudo fdisk -l http://pastie.org/2370527 – Hari K T Aug 14 '11 at 13:54
  • I've updated the instructions: the partition number from step 8 must be omitted. – Lekensteyn Aug 14 '11 at 13:57
  • Oh so sudo grub-install --root-directory=/mnt /dev/sda in my case, but as I have done with it, this may help some others. Sometimes I forgot how to install the bootloader . And I hope this will be same if we lost a bootloader when booting from live CD. I would like to know if there is any anyother way also ? Thank you for the replies :) . – Hari K T Aug 14 '11 at 14:12
  • That's the command you'll need (do not forget to sudo mount /dev/sda11 /mnt before). It works both from the Live CD and a regular session though the Live CD is generally recommended for such tasks. What do you mean by "another way"? – Lekensteyn Aug 14 '11 at 14:23
  • Another way I was looking was without booting from Live CD, in fedora and all there is a command line , we can just tell to install grub from the terminal . Wondering if there was something like that. – Hari K T Aug 14 '11 at 14:28
  • Are you talking about the GRUB shell or recovery mode? You said that your system wouldn't boot anymore and droppped to a GRUB shell. So, recovery mode does not make sense. I don't know if it's possible to install /boot from such a shell. – Lekensteyn Aug 14 '11 at 14:31
  • Yes grub-rescue was showing. I wonder we can do something from that also ? The other one is we insert a disk and when it starts booting there is an option to install grub in previous versions of Fedora not sure about todays case. And it will enter into a shell and we can issue certain commands to install the grub. Ok no issues and Thank you . – Hari K T Aug 14 '11 at 14:34
  • I wrote a script Clone Ubuntu to new partition, that does what your answer states. – WinEunuuchs2Unix Jul 03 '22 at 03:05