2

In the following output of df -h you can see that i have added a new hard drive(/dev/hdd1) and have mounted as /hdd1.

My question is if I start dumping data to /opt will that data be mounted in /hdd1 or /

My goal is to utilise the new hdd1 instead of old disk(/dev/sda3).

How can this be done?

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             442G  312G   12G  86% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             194M   57M  128M  31% /boot
/dev/sdb1             1.7T  201M  2.6T   1% /hdd1
Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148
Rajeev
  • 251
  • 1
  • 4
  • 10

2 Answers2

2

You probably can't do this easily without reformatting/repartitioning.

Here's what you need to do.

  1. Back everything up.
  2. Repartition the disks as LVM partitions.
  3. Set up LVM Volume Groups on the disks (or one big one across multiple physical volumes).
  4. Set up LVM Logical Volumes for / and any other mount points.
  5. Bask in the glory of using Logical Volume Management to reallocate space as and when you want.

I really don't want to go into the length of explaining the ins and outs of LVM, because you can pretty much just read the documentation. But that's how I'd do it.

I suppose you might be able to copy everything from the old disk to the new one, and then change the Grub configuration and MBR, but I think it'd probably be more scalable in the future to use LVM.

If you just dump data on /opt it'll still go onto the old, full disk, unless you mount /dev/sdb1 onto /opt.

Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148
0

As asked: with the above configuration, in the absence of any other information, if you write to /opt, it will be stored in /, also known as sda3.

Depending on what your data is and where it is stored, you have some options.

  • You could take Tom's advice and rebuild everything into a volume-group LVM.
  • If you are going to rebuild everything anyways, take your existing disk out and rebuild onto the brand-new large disk, then copy your data disk-to-disk and keep the old disk as a standby snapshot in case something goes horribly wrong.
  • You can move your large subdirectories in /opt to /hdd1, then create a symbolic link from /opt/$DIR to /hdd1/$DIR. (Note -- be sure the application being moved is shut down when you do this.) This lets you keep your existing system without having to rebuild everything and lets you move pieces to the new storage.

Personally I'd also rename /hdd1 to be /sdb1 or /disk2, because hdd1 means something in linux and the you are using is inconsistent with what it really is -- but that's just me.

David Mackintosh
  • 14,293
  • 7
  • 49
  • 78