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.
How to extend linux sda2 partition ?
I have linux 16.04 installed. And by default it has 4 partitions:
root@rescue:~# fdisk -l
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
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: gpt
Disk identifier: 34D4AFA4-290C-4ECC-A632-...
Device Start End Sectors Size Type
/dev/sda1 40 2048 2009 1004.5K BIOS boot
/dev/sda2 4096 40962047 40957952 19.5G Linux filesystem
/dev/sda3 40962048 3905974271 3865012224 1.8T Linux filesystem
/dev/sda4 3905974272 3907020799 1046528 511M Linux swap
root@rescue:~# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.0G 0 2.0G 0% /dev
178.33.124.49:/home/pub/rescue.v8 1.9T 236G 1.6T 13% /nfs
tmpfs 2.0G 1.5M 2.0G 1% /rw
aufs 2.0G 1.5M 2.0G 1% /
178.33.124.49:/home/pub/pro-power 1.9T 236G 1.6T 13% /power
178.33.124.49:/home/pub/commonnfs 1.9T 236G 1.6T 13% /common
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 9.6M 2.0G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs 2.0G 60K 2.0G 1% /tmp
How can I extend sda2 (/root) by few hundred GBs from sda3 (/home) which is empty ?
I have searched all over the internet for this, but I can't find anything that works..
Comments
Easiest: if you can boot a rescue disk that has gparted (gui).
Other option: Since sda3 is home (empty) and sda4 is swap (useless), delete them both. Then delete/recreate sda2 with whatever size you want (do NOT touch sda1 as the starting partition boundary for sda2 should NOT be modified).
Run a fsck/resize2fs on sda2 (with sda2 unmounted, which is possible with a rescue disk). Ideally this should NOT result in data loss. resize2fs can increase size on a live/mounted fs for ext4. Increase is always quite straightforward (but decrease is not easy without unmounted operations).
Recreate new sda3 and sda4 partitions with whatever sizes you want.
You should be done.
If you cannot even boot a rescue CD, then there's a more complex way to do it with a bind mount/chroot and you can do it with your live/running setup. Google should help.
GParted is easy and user friendly, I'd recommend doing that. I've never experienced any data loss while extending a partition.
+1 for GParted
Yeah, but since the OP asks this question I'd assume OP is inexperienced. I'd recommend a full backup before touching anything.
I was just stating it out of my experience having used it on numerous occasions. Of course he should have a backup of data before messing with the partitions.
In theory you can do it with currently used / partition without any additional actions, just recreate partition, reboot and then resize FS. At least ext4 and xfs can be resized without unmounting.
This isn't the greatest idea if you have, say, an encrypted filesystem that you mount over loopback- it may just stitch them together depending on the FS.
But, yeah, gparted. I literally just booted back from a CD doing the same to recover space from an unused NTFS partition so I could make /home a bit more livable.
I forgot to mention that I'm on SSH, and I couldn't install VNCServer successfully when I wanted to do this partitioning the easy way by using GParted...
if you need the additional space only in one directory e.g. /var or something like that, you could just change the mountpoint for sda3 from /home to this other dir (of course move/rsync the existing data over there beforehands) and don't touch the partition layout at all.
Not sure if this means rescuecd is an option or not. But if you can't use a rescuecd and have to do it via SSH, see @Gamma17's answer above (and note @Clouvider's warning). It should work but of course take precautions.
Hi,
this should https://linuxconfig.org/how-to-resize-ext4-root-partition-live-without-umount explain you how to do it on ext4
There are scary stories from people trying to increase partition. Take a backup first or after the backup reinstall the server with new partitions.
I can't set partition sizes. I installed this through kimsufi automated installer.
There is nothing scary in resizing partitions/filesystems, if you do it carefully everything works, all those "scary stories" are usually just "user error"...
Also wanted to ask, why do you need/want larger root? 20G seems like more than enough... just remount those big ( /home ) partition wherever you need and use it...
I'm using a script that downloads stuff (tubeup) and by default it downloads files to /root folder which is full all the time (
/dev/sda2 4096 40962047 40957952 19.5G Linux filesystem
) and therefore it shows 'no space left' and the script stops..I wanted to change download directories, but I'm too "beginner" to do this, I didn't know how to set download location from
<root>/root/.downloads
folder to another partition (/home) folder. I found where to change it, but it didn't work. I was probably doing something wrong.Open /etc/fstab in any editor, find the line containing /home and change that to /root.
mv everything from your /root folder to /home.
Reboot. Done.
Better solution: add an unprivileged user, which gets their home created in /home/USERNAME and use this user to run your script. Most probably no change to partitions or mountpoints needed at all and most likely more secure...
Thanks. It seems that this is working.
Downloads are now being downloaded to /sda3 partition
7.8G (5 mins later) - so this is a proof that everything is working now.
It previously stayed empty and sda2 (/root) [19.5G partition] was filling up.