0

here is my partitions

lsblk -o NAME,FSTYPE,LABEL,SIZE,MOUNTPOINT
NAME   FSTYPE LABEL  SIZE MOUNTPOINT
sdb                  9.1T
├─sdb1 swap           16G [SWAP]
├─sdb2 ext3          512M /boot
├─sdb3 ext4            2T /
├─sdb4 ext4          7.1T /home
└─sdb5                 1M


df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  912K   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/sdb3       2.0T  4.8G  1.9T   1% /
tmpfs            16G   16K   16G   1% /tmp
/dev/sdb2       488M  218M  245M  48% /boot
/dev/sdb4       7.1T  4.6T  2.2T  68% /home
tmpfs           3.1G     0  3.1G   0% /run/user/0

I want to take space from root directory / 2T, to /home partition, without losing data

1
  • "Without losing data" is not guaranteed with any partition change. You need to have good backups.You cannot resize without having un allocated space. And any resize with lots of data getting moved can take a very long time. Any interruption will totally corrupt the data. With that large of /home, do you want to consider splitting into data partition(s) or have some data in data partition? askubuntu.com/questions/1013677/… & askubuntu.com/questions/1058756/…
    – oldfred
    Commented Jun 13, 2020 at 16:10

2 Answers 2

0

That kind of operation is similar to a 15-puzzle It is preferable to reinstall the linux and restore a backup of the home directory.

But if you like the challenge, you could try this:
Of course I can be wrong and it can makes you lost all of your data.

  1. install parted
  2. boot single user
  3. resize the / partition
    parted /dev/sdb
    (parted) p
    ...
    resize 3 www xxx
  4. reboot single user
  5. parted
    (parted) p
    ...
    resize 4 yyy zzz
  6. reboot
0

as people mentioned here, partition resizing can be very dangerous. and you'd better make sure there is a backup for the critical data on this computer, whichever partition it's on.

as an alternative solution, you could use 'dump' and 'restore command to backup the root file system, recreate the root partition, and then restore the dump to the new partition.

also, it's recommended to use the saved space on a separated mount point under /home (say, /home/bigdata), instead of adding it to home partition. the advantage of this approach is you don't need to resize the huge home partition, thus reduce chances of data loss.

here are the steps for my suggested alternative. you still need to look up the specific parameters of the command dump/restore, though.

  1. reboot the machine with a USB stick (or CD-ROM, if you still have it),
  2. do a dump -0 on the root partition to somewhere
  3. use parted to recreate the root partition with a smaller size and then reformat it as ext4 file system
  4. restore the dump of the root partition to the new, and with restore command
  5. created a new partition with the saved space, and mount it somewhere you need.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .