Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Moving the filesystem root to a different partition and booting from it

+1
−0

My primary drive is partitioned basically like so (only roughly to scale):

 / /home                                       junk
 v v                                           v
|xx############################################*************xxx
^                                                             ^
/boot/efi                                                  swap
Motivation

The "junk" space is in fact separately partitioned and formatted - it's left over from a failed attempt to set up dual boot with Windows, but I no longer have any interest in that. I don't care about anything written on these partitions and would be happy to wipe and reformat them and reuse the space.

The problem is that the partition where / is mounted is far too small for my needs. When I initially set up Linux, I followed old advice with unrealistic expectations about the "system" partition size (and allocated a larger swap partition than I really need). Essentially: I want to be able to install more apps, run the distro's OS update rather than reinstalling for new versions, and not worry so much about maintenance tasks like apt cache cleanup or journalctl vacuuming.

So I want the OS to be on a larger partition, and fortunately I have tons of room to work with. But I don't want to move or otherwise disrupt the /home partition for this, first off because it's hundreds of GB and second because I don't want to risk needing to reach for a backup for all my commonly used data.

I've come up with a plan where I won't have to touch the /home partition at all. I might expand it into the "junk" space in the future, but I definitely don't want to move it. I might also try using that space to install separate Linux distros side by side - haven't decided yet.

My current plan is to:

  • Back up everything anyway
  • From a live boot, use Gparted to, in order:
    • scrub the junk partitions
    • expand the current swap partition to the size I want, and format it as ext4
    • copy and paste the / partition to the former swap partition
  • Set up the system so that it (will|can) boot from the new /
  • Reboot from the new partition
  • Use Gparted again to wipe the old / partition and designate it as swap space, and start using it

My primary question is about the boot setup step. How can I reconfigure the system so that it will boot assuming that / is mounted on the new partition, and ignoring the contents of the old partition?

Aside from that, I want to make sure that I'm managing the swap space in a valid way. I don't want to erase the old partition until I've confirmed I can boot from the new one, of course. Will Linux complain if I try to boot the system without either a swap partition or a swap file, even if there's plenty of RAM for basic tasks? (I.e. will I need to create a temporary swap file?) I know I can swapon the new swap partition for that boot once everything else is working, but how do I make it permanent? Finally, with my current plan, can I avoid the need to start with a live boot, if I swapoff first?

If it matters, the OS is Linux Mint 20.3 (Ubuntu 20.04) running Cinnamon.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+0
−0

Disclaimer: I'm not a Mint (or Ubuntu) user.

Using your distro's live image:

  1. Do your partition stuff
  2. Mount the new root to the live system at /mnt[1]
  3. Mount your other partitions to the new root as they should be
  4. Chroot into /mnt
  5. Check your /etc/fstab, there should be an entry about mounting your root. Update it to mount the new root partition.[2]
  6. Update your initramfs image(s), perhaps with update-initramfs?
  7. Run your distro's boot configuration scripts. Perhaps it's update-grub for you? There are some moving parts in this step. MBR/EFI? Which bootloader?
  8. exit the chroot
  9. Unmount everything with umount --all
  10. Reboot and see if it works
  11. If it didn't, study the linux boot process in more detail. There are good articles on Wikipedia and ArchWiki.

Swap

Yeah it's probably best to decommission the current swap before everything. Your system will work fine without it too.

Personally I'd recommend just dropping the swap partition, and making a new swapfile when the other stuff is done. Swapfiles are just more flexible.


  1. Doesn't actually matter where. ↩︎

  2. Your distro could have some helpers for generating this file as well, based on the current mounts. ↩︎

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Clarifications (3 comments)

Sign up to answer this question »