Score:0

Recreate swap and resize root partition

jp flag

I'm using Ubuntu 22.04.2 LTS. Below is my current partition table configuration. Initially, I allocated 37GB for the root partition and left the remaining space for the home partition. However, I have realized that the root partition requires more space nowadays.

enter image description here

One mistake I made was not creating an extended partition, which complicates the resizing process. My plan now is to shrink the home partition and use that space to extend the root partition. However, the swap partition is located in between, posing a challenge.

To address this, I intend to follow these steps:

  1. Disable the swap partition using the swapoff command and remove it from the operating system.
  2. Boot the system using a live USB so partitions aren't used and I can alter them.
  3. Delete the sda3 partition using gparted
  4. Utilize gparted to shrink and move the home partition (sda4).
  5. Extend the root partition using the freed space.
  6. Create a new swap partition.
  7. Reboot into the operating system and activate the new swap partition using the swapon command.

While this plan seems viable, I would appreciate any advice or alternative approaches that could help ensure a smooth and error-free process. Thank you.

P.S The reason I used a seperate home partition is to reinstall OS in case of a catastrophy but to keep the user data safe but in this point I really would like to avoid that and just make space in the root partition.

guiverc avatar
cn flag
You've not provided release details (*starting point in my opinion; and we don't know if you can easily use swap file thus have no need for any swap partition*). You don't indicate where you'll run `gparted` as the partitions may or may not be *in use* in your description too. You can non-destructively re-install Ubuntu Desktop systems even if using a *single* partition (ie. no separate /home) so I'm not sure of the requirement for separate /home, though its useful to keep if you plan on moving away from Ubuntu (*as not all OSes can non-destructively re-install like Ubuntu can*).
user221315 avatar
jp flag
Hi @guiverc . I updated the information. I'm not planning to move away from Ubuntu. Just want to avoid reinstall and want the root partition extended at this point.
mook765 avatar
cn flag
An error-free procedure can not be 100% guaranteed, so it is strongly recommended to backup your personal data on a different disk. you will also have to adapt `/etc/fstab` to new UUID of new swap partition.
Score:1
gt flag

In your case you can extend root partition by follow this steps:

  1. disable swap partition and delete its line from ets/fstab

  2. reboot by live USB, copy your username folder in home partition to home folder in ubuntu root partition.

  3. now you can delete swap and home partition, and resize the root partition as you like.

  4. if you want to continue without separate home partition you can disable home partition by deleting its line from etc/fstab, delete this line:
    # /home was on /dev/sdax during installation UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /home ext4 defaults 0 2 you will see numbers or letters instead of x. save the fstab file.
    apply this command after login to ubuntu and change the directory to home by cd /home to chang the ownership of your user folder: sudo chown -R username ./username replace username by your user name

  5. if you want to back to separate home partition, don't delete its line from etc/fstab, restore your user folder to home partition and adjust its uuid in etc/fstab by the new uuid which you can get it from disks utility.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.