You are not logged in.
Pages: 1
My current SSD of 120Gb is partitioned in three.
lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1 vfat FAT32 29BC-C4C9 414.8M 17% /boot
├─sda2 ext4 1.0 cac3e4b3-2751-4838-821f-f0a92c1f8725 964.3M 91% /
└─sda3 ext4 1.0 data 9d3ce11e-31d1-4c41-a821-082c1d5ec276 68G 14% /media/data
[tejonidhi@arch ~]$ My / is mounted under sda2 and my data in sda3. Off-lately, I have been running out of space despite not using must of / as storage. I even use pacman -Scc and -Sc commands to clear downloaded packages.
For some weird reason I keep getting my / filled.
Anyway I want to extend my / without formatting.
I want to grab extra space from sda3 and merge into sda2. Is that possible? I know its doable with LLVM partition but can it be done on ext4?
All partitions are ext4 barring ESP partition.
So I want -
1. Extract extra space from sda3.
2. Append that extra storage to sda2
Please help.
TIA
Last edited by Shashwat (2021-03-02 07:11:46)
Offline
I want to grab extra space from sda3 and merge into sda2. Is that possible? I know its doable with LLVM partition but can it be done on ext4?
You probably mean LVM. It will also involve creating PVs and is the wrong tool for this situation (and will not solve your problems as you still need to do something to the sda3 which is currently "in the way").
Anyways, what you want to do is doable but will be a bit involved in this case. It is easy to shrink or expand a partition and most filesystems (at least ext2, ext3, ext4) from the end. However if the start of the next partition is straight after the partition which needs resizing (I assume this is your case), you will need to move data around one way or another.
First, post the output of 'fdisk -l /dev/sda' (the numbering of the partitions might not actually reflect heir physical order on the disk). Assuming sda3 is straight after sda2:
You need to remove all files from sda3 one way or another, so that you can destroy your filesystem. The easiest option would be to make space on the root partition (even temporarily) to move all files from sda3 to it, but obviously this is not possible in your case.
With another disk it becomes easier (move files from sda3 to the other disk, remove sda3, expand root). If you do not have anther disk, well, in principle you could resize sda3 to be as small as possible, create another partition after it, move as much files as you can there, shrink sda3, repeat .... however this will be very slow, very error prone (make one mistake and that data is gone), and very taxing on the disk (moving a huge amount of data with random seeks all the time). If you can get away with one step (sda3 being mostly empty) this could be still an option.
In any case, the goal is to get free (unpartitioned) space on the disk after the partition to be expanded. Then expand partition and use a tool called resize2fs.
There are (proprietary) tools/software to automate some of these tasks, but they all do the same thing under the hood (i.e. there really is no way around the process; file systems can not be "merged", their starting point can not be moved easily).
Also, always make sure you have backups when making potentially destructive disk operations.
EDIT: Re-arranged the sentences a bit
Last edited by Wild Penguin (2021-03-02 07:42:12)
Offline
You don't need to destroy your file system. You can shrink the filesystem and the partition and then move the partition up. I'd personally suggest you have back up of everything that's relevant regardless and then using a gparted live disk to have something visual to work with, as juggling the distinct resize and partitioning tools from the command line can be cumbersome in this case while gparted makes this fairly trivial from an outside perspective.
Offline
[tejonidhi@arch ~]$ sudo fdisk -l
[sudo] password for tejonidhi:
Disk /dev/sda: 111.79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: Samsung SSD 750
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xdae44745
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1025484 1023437 499.7M ef EFI (FAT-12/16/32)
/dev/sda2 1026048 53184511 52158464 24.9G 83 Linux
/dev/sda3 53184512 234440703 181256192 86.4G 83 LinuxHere is the output of fdisk -l.
I can destroy sda3 and get it to work but for the sake of learning I don't want to destroy the sda3. I know that the empty space should be just beneath the sda2 for expansion.
I will of course take backup though.
@V1del - How do I move empty space up? Assumning that space I siphon from sda3 gets allocated down the table.
Last edited by Shashwat (2021-03-02 07:57:42)
Offline
What V1del suggests is the same thing I did, I just said it in a more convoluted way :-).
You have loads of disk space on sda3, so this is easy (you need only one new partition). The process is like this:
'resize2fs' on sda3 to make it small (say, 40G in this case).
resize partition sda3 - but don't make it smaller than you did on the previous step! There may be tools which can do these steps for you in one go (gparted?)
Create another partition after sda3.
Move data from sda3 to sda4
Check everything is as it it supposed to be (up to until this point there should be nothing destructive been done). You can now do step 5: remove sda3.
Whether to copy the file system contents or the whole partition (with, say, dd) is a matter of taste. I prefer to copy the contents to avoid copying empty space for no reason. (See: https://wiki.archlinux.org/index.php/Rs … tem_backup ).
It seems that gparted can "move" the partition in one go. I believe it still does steps 3. and 4. (+ step 5: delete of the old partition sda3), however I've never actually used the feature of gparted, so I'm not sure.
I believe gparted is well tested and being used a lot, and in active development (or maintenance) so definitely use it in case you are new to partitioning (personally, I've just accustomed to parted using if for years, so that's what I use).
Last edited by Wild Penguin (2021-03-02 08:28:40)
Offline
You need to move the partition (...after shrinking the file system and the partition) e.g. sfdisk has a --move-data parameter you can use to shift the partition up into the new freespace so you get more for /dev/sda2. But that is a lot of manual number juggling.
@WildPenguin You can move the existing partition (... the primary advantage is that the UUID doesn't change and you don't need to adjust fstab and the like) though I'd agree it's likely "safer" to create a new partition and just do a copy first. But for the sake of what's asked here you can just move the existing partition. FWIW parted used to have this option itself but all filesystem manipulation options have been removed from normal parted a while ago. It used to be possible to do the FS resize and the partition move directly in parted.
Last edited by V1del (2021-03-02 08:32:57)
Offline
I am looking to expand my / with additional 20Gb space. I noticed I can shift non allocated space easily using GPARTED. How do I achieve the same using resize2fs? Does it have certain parameter to shift the non allocated space up and down at the onset of resize?
Also once I put the non allocated space of 20GB right beneath /. Running resize2fs /dev/sda1 will automatically expand the /?
Also do I need to use live disc to expand the partition because I can't use either resize2fs and parted without unmounting the system.,
Edit - The screenshot was only for test. I have no applied those changes, I want to replicate the same using command.
Last edited by Shashwat (2021-03-17 08:44:10)
Offline
resize2fs does not shift partitions around, it's up to you to provide larger partition
Last edited by frostschutz (2021-03-17 08:50:51)
Offline
Pages: 1