How do I resize the root partition?
How do I resize the root partition with EXT4 file system without losing any data?
About this post
- Posted
- Archived
- Score
- 24 · 84% up
- Kind
- Text
- ID
- o268bc
How do I resize the root partition with EXT4 file system without losing any data?
26 comments
GParted Live, if you want minimum effort.
Does GParted resize both the filesystem and partition?
Yes.
Absolutely yes
But i won't use GUI for that .-.
arch linux users be like
If you don't want to use a GUI for ideological reasons, you can do the same thing with parted and tools like resize2fs.
Damn, are people really downvoting someone on a Linux sub for wanting/needing a specific UX?
I could easily see this being me if I needed to SSH into my server machine without video output to do the same thing.
This really depends what needs to be done. If you're just extending it to the right, it's pretty simple. Resize the partition, and run resize2fs to resize the ext4 partition. If you need to move the partition though (ie, to use space to the left of the partition), then you need to rewrite the data, at which point you're significantly increasing the risk of losing data, as any interruption will leave you in a corrupt state. If you need to shrink it, the fs needs to be shrunk first, then the partition.
At all times, when messing with partitions, backup your data. There is no 100% guarantee there won't be any data loss, even for simple changes, and people should know by now that there's no excuse for not having a backup if they really can't afford to lose data, especially when they start messing with the system on this level.
For tools to resize it, look into gparted for a nice GUI solution that does everything, from the partition to the filesystem resize. Or if you insist on a CLI tool (ie, if it's a server), you can use something like cfdisk, which is like an easier fdisk. You can also use parted, or something like fdisk itself.
First resize2fs, there is a redhat wiki page that tells ypu how, then I like to use cfdisk to resize the partition to the exact size. Make sure to make the checks before and after resizing.
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/storage_administration_guide/ext4grow
All with the archiso
Just use Emacs, it can do everything except edit text
Jokes apart, cfdisk works great for me. It's command line but super easy to use, and is bundled in with the archiso. Just be sure that if you are expanding your partition size, it won't automatically expand your filesystem size, use resize2fs for that
You can extend a standard partition if it is at the end of the table. Otherwise you can't.
Use gparted live, it works flawlessly
If you're worried about data loss, it's probably best to let GParted do this for you. Plenty of live images have it installed.
Just boot a live USB, and run gparted. Easy-peasy.
I am g-root