Im having a problem, my primary partition is running out of space. Due to this, I can't access linux machine remotely (through vncserver). I have another drive (/dev/sdb) having much more free space. I want to shrink space from (/dev/sdb) and extend to (/dev/sda1) partition which is my primary partition and have all linux boot, kernel etc files. What would be best risk free way to do this without losing my data on primary drive(/dev/sda1) ?? fdisk or 'dd' command or 'mount and umount' ? Any help would be highly appreciated. :)
You have to use
resize2fs command,Which is used to resize your partition.
For more information refer this link.
resize2fs /dev/sda 6000M
You can use
resize2fs to increase as well as decrease the size of partition.
First,you have to decrease the size of
/dev/sdb.Then,After increase the size of
I hope this will helps you.
The Risk Free way would be if you can copy(mirror) all your data from /dev/sda1 to some other partition.
After this is done, I would recommend to go with GParted live CD and execute all partition modifying commands from there. This seems to be the most secure way of doing it.
You need a live CD/temp OS to boot on it, resize the new partition to the right size, mount the old and new partitions and copy your files first with
cp -avx /media/originalRootPartition /media/newRootPartition
Then you should change some references (UUID or partition name) to the new partition in /etc/fstab to match the new partition, and reinstall grub on that new partition :
The answers given so far don't seem to take into account that the free space you have is on another drive.
I don't think you can easily extend a partition to another physical drive, although I may be mistaken. Anyway, a more straightforward thing to do in this case is to constantly
mount a partition from your other drive (say
/dev/sdb1) into your filesystem. For example, you could keep your
/dev/sdb1. That would make some space in
/dev/sda1. Look into
fstab on how to achieve this and don't forget to backup first.
I use often for Servers which run over a few years and go now out of space this workaround:
Normally one or two applikations/services/deamons/whats so ever... need the most most space. If thats the case u can mount move the directory from disk sda to disk sdb, so you utilize more space.
here is what i do: create a directory on the empty drive
now we just have to copy all data from the original folder to "/mountpointsdb/data/deamon_database"
cp /usr/deamon/database/* /mountpointsdb/data/deamon_database
now we can delete the original folder, but make sure the deamon want run. Thiss will give you more free space on sda. After that just mount the new folder to the old location and start the deamon:
mount --bind /mountpointsdb/data/deamon_database /usr/deamon/database
If u want this to be permentent you have to make an entry like this in the mtab:
/mountpointsdb/data/deamon_database /usr/deamon/database none bind