- How do I resize a partition in Ubuntu linux without losing data?
- 5 Answers 5
- You must log in to answer this question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- Resize partition with fdisk without data loss
- 1 Answer 1
- Extend linux partition size without losing any data / techniques
- 2 Answers 2
- How to Resize Linux Partition without Data Loss
- How to Resize Linux Partition without Data Loss
- 1. Install GParted
- 2. Resize Linux Disk Partition
- 3. Apply changes
How do I resize a partition in Ubuntu linux without losing data?
I ran out of space in my on the drive only to find that there was another unformatted partition in the system that is available. I now want to resize the current partition to take in the empty partition without losing data. Any ideas?
The eternal reminder of how to not lose data. Make a full and complete backup of your existing partiton before you attempt anything of this nature.
There are some options, but it would help if you gave us your current partition layout. What is the output of fdisk -l /dev/sda (or whatever your disk’s device is called)
5 Answers 5
boot from live Linux distro (you can use Ubuntu install disk) and use gparted
But always something can go wrong, so it is advisable to make a backup .
The other option is to format the unused partition and mount it and use it (depending on the size) as /home or /usr
LVM is the way to go. Turn your whole spindles into PV’s and migrate from legacy partition-based model to LVM model. RedHat has some good documentation on LVM, check it out.
@fred.bear: LVM makes it a lot less likely that you’ll accidentally delete or overwrite a filesystem, because its basic operations are creating a volume on free space and deleting a volume, rather than creating a volume on whatever was there before.
I’ve resized my partition successfully without the loss of any data using the method described here, which generally is about deleting the current partition and creating a new one with the same start and a greater end.
But that is probably not the recommended way, especially when the partition to be resized is in between other partitions, because, in my case I had to remove all my partitions (primary storage and swap) and had to recreate them all.
to find that there was another unformatted partition
Are you sure that this isn’t your swap-partition? Beside from that I would recommend LVM as mentioned before by slashdot.
You must log in to answer this question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.12.43529
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Resize partition with fdisk without data loss
I need to increase the partition using the empty space located before the partition starts without data loss. As far as I know to resize the partition and to leave data intact one should start the new partition from the same disk sector as before. Is it possible to find a solution in this case using fdisk? Moreover the partition has a filesystem. Will the resizing with fdisk damage filesystem and data?
1 Answer 1
Do you need to make the partition larger or smaller?
Any method would suggest that you back up the data anyway. Thus, backing up the data, changing the size, and restoring is a likely course of action.
There are toolsets like PartedMagic that contain tools like clonezilla and other formatting, partitioning, sizing, and such.
Lager. The first article still describes the procedure when the free space is located after the partition, but I have before it starts. I know, there is an option to use Gparted as well, but I was curious if it is possible to do just right from terminal with fdisk or something similar.
Based on (limited) knowledge, the start of a partition is not something that seems to be able to be changed on just about any OS/filesystem. Might not be an option, but backup to something, setup how you want, and restore. My current favorite is to use ZFS for disks (mirrored, of course). No concern about partition size, since it is all virtual.
@Anna There is NO way to change partition size, you must delete it and create a new one, and creating new partition does not change allocated space, you must use resize2fs to shrink or expand allocated space. Also make sure to backup everything and to reinstall bootloader if you ‘resized’ partition containing the bootloader. It doesn’t matter if free space is at end or beginning of partition.
Extend linux partition size without losing any data / techniques
I bought a 200G additional disk for my OVH cloud server because my initial disk was full. Now, my additional disk is almost full (as you can see below). So I added 200 extra more G in it. As you can see, sdb’s size is now 400G. So, how can I add the 200Gb in the sdb1 (edit : FS ext4) linux partition without losing the current data in it? When I run :
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk └─sda1 8:1 0 200G 0 part / sdb 8:16 0 400G 0 disk └─sdb1 8:17 0 199.5G 0 part /mnt
Your best bet would be to backup, re-format, and restore the data. If that is not possible, you might be able to re-arrange things in your filesystem and mount sdb somewhere that works out.
2 Answers 2
Removing or creating a partition doesn’t remove a data or a filesystem on a disk. It will only update the MBR or GPT information where partition lies and its size.
Also, if the filesystem finds itself on the device which is larger than that is stored in its superblock, it will just work as if that was small device.
Based on this knowledge, you can deduce the extension process. It is as follows:
- On a running system, run fdisk and carefully observe where the partition starts ( p ). Then remove it ( d ), and create ( n ) larger one on its place. Modern fdisk could ask about wiping signatures, if it will, say «no» (this is essential)! Pay special attention on its start, it must begin at exact same sector, but could have larger size. Exit fdisk writing changes ( w ).
Filesystem could be left mounted. That will not broke access to data. In fact, kernel will refuse to reload partition table, because the old parition was in use, and it will use old parition mapping. To update a partition mapping in the kernel, you can simply reboot, or use kpartx or partprobe program in case service interruption is infeasible.
Of course, you could have unmount filesystem in beforehand and remount after partition recreation, then kernel would not be blocked and partition mapping will be updated right after exit from fdisk.
- Resize a file system. Ext4 can be resized online (just resize2fs /dev/sdb1 , it will detect mounted filesystem and run online resize). Or you can again do this while it is unmounted, if you wish.
Of course, this is still dangerous process. Have backups somewhere.
How to Resize Linux Partition without Data Loss
Sometimes you may need to expand or shrink Linux disk partitions, without any loss of data. There are many third-party tools to manage your Linux disk partitions. For example, you can easily do this using Gparted tool. In this article, we will look at how to resize Linux partition without data loss.
How to Resize Linux Partition without Data Loss
Here are the steps to resize Linux partition without Data loss.
1. Install GParted
Open terminal and run the following command to install GParted utility.
$ sudo apt-get install gparted
2. Resize Linux Disk Partition
Start GParted. You can do so from the Ubuntu dashboard
You will see a window that lists all the partitions on your system.
Please note, you cannot resize a partition that is in use. So if your partition is in use, then open file manager, right click on this partition, and select Unmount option from dropdown menu to unmount it. If it is a swap partition, then select Swap off option instead.
Right-click the one you want to resize and click ‘Resize/Move’ from dropdown menu.
You will see the following window, that allows you to resize partition either by dragging the bar handles, or entering exact partition size numbers. Click Resize/Move to save changes.
Please note, your changes will be enqueued in GParted and not applied immediately.
3. Apply changes
Click the green tick mark to apply changes in Gparted. This will take a while. Don’t switch off your system or cancel the changes midway when the operations are being applied. In case of any errors/conflicts, it will show you an error message.
That’s it. In this article, we have learnt how to resize Linux partitions without loss of data.
The key thing is to remember to unmount partition before resizing it.
If your Linux system does not have GUI/Desktop, then you can use the CLI version of Gparted called parted instead but it is slightly complicated to use, so we recommend using GParted instead.