New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Resize partition under Ubuntu
blackjack4494
Member
Recently I got a free SSD upgrade for my server.
Instead of 20GB I now have 30GB.
But I actually never had to do such thing like resizing a partition in an existing machine.
So here is the output of lsblk
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 30G 0 disk
└─vda1 252:1 0 20G 0 part /
I don't have a full backup of the server so that is what I do know. Until now it was enough for me to have backups of the important services there.
So my question now is it enough to use resize2fs or do I have to use fdisk in advance to accomplish my task?
Hopefully no server will be harmed during the process :P
Comments
yes
EDIT2:
inside fdisk, type
p
to list partitions - note the block where /dev/vda1 startstake a deep breath
then
d
to delete the first and only partition /dev/vda1 (this only deletes partition table info which was specifying the old 20 GB size, the filesystem itself will not be changed by this operation)then
n
to create a new 30 GB /dev/vda1 partition - just make sure this starts at the same block that the previous instance that you just deleted did. (It's nice if the old /dev/vda1 started at the default value but I won't assume that and neither should you.)Also, assuming this is Linux filesystem ("id 83") then no need to specify that (otherwise type
t
and set whatever other partition type)type
p
again to make sure your new 30 GB /dev/vda1 partition is bootable if it was before(type
a
to toggle the boot flag if necessary)if you've mistyped something along the way, type
q
to exit without saving so you can start over.otherwise type
w
to write the new partition table and exit fdisk.Then you're ready for the
resize2fs
operation - you actually will have to rune2fsck
with some flag that I forget at the moment before resize2fs will do its thing ... (but resize2fs will tell you exactly what to do if you just go ahead and run it first, so that's what I usually do.)resize2fs /dev/vda1
Thanks @uptime
I managed to sucessfully resize the partition.
Tho I came across one important thing - it asks me whether I want to remove the ext4 signature. I used google and got results where they advised to not do it!
Somehow the fourth search result was a link to Hetzner
https://wiki.hetzner.de/index.php/Resize_Ext_Partition
In the end I followed the steps (similar to yours) but I did not need e2fsck. So resize2fs did it all at the end to finish the task.
glad to hear that worked - that "delete the existing partition" step is a fine example of Unix-style YOLO™ way ... just a bit nerve-wracking "wtf, really?" if you haven't seen it done before (and a good way to screw up your system if you mis-type something anyway). So I was a bit glib to offer that recipe from memory without triple-checking the steps described ....
I do see the
e2fsck
bit included in the Hetzner writeup but perhaps it could be skipped in some situations if resizing a fresh filesystem or whatever ...sfdisk would have been easier.
With LVM this things are much easier
Yeah I mean if you do understand that no actual data will be deleted but the partition table, you won't be that scared but still. If you fk it up and have no backup it will probably gone anyway
Yes, everybody keeps saying so, please teach me how
lvm
can make my life easier in this instance.In my experience I had to:
parted
print
resizepart
lvm
partition numberAnd then:
Depending on your specific situation, the last commands may be condensed to:
but in my case I wanted to leave space for a swap partition, and
lvresize
didn't accept--resizefs
for a reason I can't remember (something else having changed).Though I use LVM, I have found no real advantage over good ol' partitioning, when not dealing with spanned volumes. Boot from systemrescueCD and you even get a GUI, to resize your partitions (gparted).
(Never liked the concept of spanned volumes, though I dare say it's useful in large installations.)
Yes, it must be highlighted that GParted does not fully handle lvm.
Aye, I didn't make that clear distinction and was referring to traditional partitioning. Much as I hate the complexity/non-intuitive webmin, it can handle LVM, though good luck when altering live production systems!