1

I have a hd of 150GB and other of 300GB, both partitioned, the former with a root partition and the latter with some unused space.

How can I use the unused space of the second to extend the root partition of the first?

  • you can't have two hds on root part , for me two hd i'll chose one for system parts and second hd for multimedia data in order to have Disk's read/write speed ! – Jonah Nov 13 '15 at 14:44
  • as suggestion : 150gb is enough for many OSs ; partitionne it according to number of systems you use , and include 300gb in fstab and put in it shared data e.g multimedia and docs ... ! – Jonah Nov 13 '15 at 14:50
  • Is the root partition LVM? – jordanm Nov 13 '15 at 14:52
  • @jordanm, it's not LVM. – ptkato Nov 13 '15 at 14:56
1

If you're not using LVM (or btrfs or ZFS), then "move and symlink" is the best you can do.

Format the partition if it isn't already formatted, and mount it somewhere "generic", like /exra. Put the mount in /etc/fstab so it'll be mounted on every reboot. Then move and symlink large directories from the root filesystem to the /extra filesystem.

For example, to move /usr/share/doc to /extra/usr/share/doc:

# uncomment if not already mounted
# mkdir -p /extra
# mount /extra

mkdir /extra/usr/share/
mv /usr/share/doc/ /extra/usr/share/
ln -s /extra/usr/share/doc/ /usr/share/

All of this has to be done as root, of course, so sudo -i first to get a root shell.

Note: you can't safely move directories which have files currently in use by other processes...so if you want to move, say, /var/lib/mysql to /extra/var/lib/mysql you'll have to do it while mysql is temporarily shut down, or while rebooted into recovery mode.

You also can't move files/dirs that are needed early in the boot process. That means don't move /etc, /bin, /sbin, /lib (or any subdirectories thereof).

  • Is it practical or secure? For example, would be better just format everything and reinstall the system, partitioning the disks properly? – ptkato Nov 13 '15 at 16:01
  • it's practical (people have done things like this for decades). it's no more or less secure than leaving the files where they are. reformat and reinstall from scratch works too but is a lot of work. remember to backup your config files in /etc as well as your personal files in /home. and important data under /var (e.g. /var/www, /var/lib/mysql, /var/lib/postgresql) – cas Nov 13 '15 at 16:31
  • another alternative, if your rootfs is ext4 is to convert it to btrfs and then add the 300GB partition to the btrfs rootfs. note that btrfs is still not quite ready for production servers, but many people use it without problem. use a recent kernel and keep it up-to-date if you want to run btrfs. and do a lot of research on the pros and cons before deciding. – cas Nov 13 '15 at 16:35
  • @Patrick, reformat and restore from backup is a bit less intrusive than a full reinstall from scratch. It still takes time and work, but you don't have to reinstall all of your applications and reconfigure them. As an alternative ( you should still have a backup ) you can format the new drive for LVM, copy the existing root there in single user mode, reinstall your boot loader to boot the new disk, reboot, then reformat the old disk and add it to the LVM and grow the new disk back into the old one. – psusi Nov 14 '15 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.