Possible Duplicate:
How to move /usr to a new partition?

I use Ubuntu 11.04.

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              9611492   7553508   1569744  83% /
none                   1665832       644   1665188   1% /dev
none                   1672460      1436   1671024   1% /dev/shm
none                   1672460       648   1671812   1% /var/run
none                   1672460         0   1672460   0% /var/lock
/dev/sda3             67285624  19445284  44422384  31% /home

Im starting to be a bit short on / partition. I have a lot of free space on my disk.

enter image description here

I would like to mount /usr and /opt on new partitions without loosing the data. But I have no idea of how doing this.

Can you help me.

marked as duplicate by RobotHumans, Jorge Castro, Mitch, Eliah Kagan, jokerdino Jul 20 '12 at 5:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


It's probably easiest to do by booting from a Live CD, i.e. boot from the install and select to test Ubuntu.

Once booted, open a terminal up and create new partitions for /usr and for /opt, although you may not have much in there. These will need to be logical partitions soyou'll need to create an extended partition (/dev/ada4) first.

You'll need several temporary mount points, so I usually create subdirectories in /mnt (e.g. /mnt/root, /mnt/usr and /mnt/opt) copy the existing contents across, then edit the existing fstab (which will be in /mnt/root/etc/fstab) to mount the new /usr and /opt.

Sequence of commands is (UNTESTED!!!) in Live CD terminal is roughly:

# fdisk /dev/sda
.... create new partitions. 4 (extended) 5 (to hold /usr) 6 (to hold /opt)
# mkdir /mnt/root
# mkdir /mnt/usr
# mkdir /mnt/opt
# mount /dev/sda1 /mnt/root
# mount /dev/sda5 /mnt/usr
# mount /dev/sda6 /mnt/opt
.... copy data
# cp -dpRxv /mnt/root/usr/* /mnt/usr
# cp -dpRxv /mnt/root/opt/* /mnt/opt
.... edit /mnt/root/etc/fstab
.... i.e. add extra lines to mount /dev/sda5 on /usr and /dev/sda6 on /opt

At this point, you you be able to boot from /dev/sda and check everything works OK, but you will notice that we haven't deleted the old contents of /usr and /opt from /dev/sda1; we've just mounted the new directories over the old ones and hence hidden their contents. This is so if it doesn't work, you can just undo the edits from fstab (delete or comment out the extra lines you added) and you'll be back where you started without losing anything.

Finally, when you've check it's OK, boot into the Live CD again, mount /dev/sda1 on /mnt and remove the old contents of /usr and /opt

# rm -Rvf /mnt/usr/* /mnt/opt/*

While I have restructured disks in the past, there is always the danger of mistyping a command and wiping out some data. In this case, since you never mount /dev/sda3 you should be OK, BUT I OFFER NO GUARANTEE AND YOU SHOULD CHECK CAREFULLY THAT YOU UNDERSTAND EACH STEP BEFORE TRYING ANYTHING!


There's two ways of doing that which I'm aware of:

  • The first would be to use an Ubuntu live CD or USB, boot your laptop from that and using GParted in the OS booted from that CD/USB unmount your /dev/sda3 partition so that you can resize it to take up the whole of your hard drive space.

  • The second would be to copy and paste all the data you need onto an external hard drive, then using an Ubuntu install such as a live CD/USB and reinstall Ubuntu 11.04 (or 11.10 or 12.04 if you feel like upgrading) and merge the partitions so you fill up the whole of your hard drive space.

As Ubuntu works quite well when it comes to partitioning both of these options are safe, however as always when modifying disk partitions it is always very recommened to back up beforehand that way even in the case even if something happens to go wrong, you're sure not to have lost any data.

Hope my answer was of some help, feel free to comment to ask me for more details if you're unsure of anything I've explained above as I might not have explained everything thoroughly enough. [Also I'm assuming when you said you wanted to create new partitions that you meant that you want to be able to use all the free disk space you have at the end of your hard drive, rather than create separate partitions for /usr and /opt as that would be quite a hassle to access afterwards]

Not the answer you're looking for? Browse other questions tagged or ask your own question.