Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, I have Ubuntu installed on my hard drive and I have only one (& swap) partition. Now I would like to repartition the drive and have /, /root and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! m5ernel's Avatar
    Join Date
    Mar 2011
    Posts
    4

    Hard drive repartitioning


    Hi,
    I have Ubuntu installed on my hard drive and I have only one (& swap) partition. Now I would like to repartition the drive and have /, /root and /home partitions without reinstalling the OS.
    Is it safe to do it? And how to?

    Thanks,
    Milos

  2. #2
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,043
    Quote Originally Posted by m5ernel View Post
    Hi,
    I have Ubuntu installed on my hard drive and I have only one (& swap) partition. Now I would like to repartition the drive and have /, /root and /home partitions without reinstalling the OS.
    Is it safe to do it? And how to?

    Thanks,
    Milos
    Yes you can do it without a reinstall (but I suggest / and /home and not creating a separate partition for root user home area /root). The risky part of this is resizing the existing partition (I'm assuming at the moment the whole drive is occupied by the existing root and swap partitions).
    The steps should be something like:-
    1. backup critical data (your docs, photos etc).
    2. boot from a live CD (Ubuntu will do) and check you can get online incase you need further help part way through the process then
    a) resize the existing root partition
    b) create the home partition
    c) mount both partitions and use cp -a to copy home folder information to the new home partition
    d) modify /etc/fstab to mount your home partition
    e) check the output of blkid and adjust /etc/fstab if needed for root (if UUID is used this may change with partition resize)

    If you want more help with this posting the output of
    Code:
    mount
    cat /etc/fstab
    sudo fdisk -l

  3. #3
    Just Joined! m5ernel's Avatar
    Join Date
    Mar 2011
    Posts
    4
    Quote Originally Posted by Jonathan183 View Post
    The steps should be something like:-
    1. backup critical data (your docs, photos etc).
    2. boot from a live CD (Ubuntu will do) and check you can get online incase you need further help part way through the process then
    a) resize the existing root partition
    b) create the home partition
    c) mount both partitions and use cp -a to copy home folder information to the new home partition
    I did this yesterday and stopped at "c". I'll continue later today and of course, there are more questions:
    - Now, can I just delete old /home on the boot partition?
    - Does it mean that the new home partition will automatically take over after mounting or is there something else to be done?
    - What about making more partitions, e.g. /etc ? As I understand it can help keeping installed software after updating and esp. new installatons of OS.

    There are many information on that on the Internet but none is precise enough (for me, that is ).

    Thanks,
    Milos

  4. #4
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,043
    Don't delete anything until you have everything working !
    When you mount your new home partition to /home ... all you see is whats on the new home partition (unless you unmount the home partition). I'd leave everything on there until you get short of hard disc space.
    You can create separate partitions, but if it's for a desktop system I'd stick with
    /
    /home
    swap

    think about having separate partition for genuine user data (docs etc), separate /home will do but it also contains config files for each user.
    I also have a separate /var partition.
    All the systems I have are desktop/laptop with a gui and local users rather than servers for www and files etc. So the above covers all I need.

    You should find information on recommended partitioning for each distro ... here for Arch - scroll down to partition scheme information. It's fairly short and explains the sort of thing you can do. I'm running ext4 partitions for root, data, home and reiserfs for var.

  5. #5
    Just Joined!
    Join Date
    May 2011
    Posts
    44
    If you're moving the swap space you'll have to deactivate the swap.

    You can use Gparted to deactivate/activate swap or from the commandline

    Code:
    $ sudo swapoff -a
    $ sudo swapon -a
    Of course if your swap is at the logical end of your drive and you are not moving/resizing swap you will not need to deactivate swap.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •