Unmount One hard-drive and re-mount it as another directory in Unix

0

I recently got my first Unix Dedicated Sever running CentOS

I just ran df -h and found this:

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      2.2T  1.5G  2.1T   1% /

My Server has 2 x 1TB Hard-drives, as you can see they're both mounted onto the root directory.

How do I unmount the secondary Hard-Drive and Re-mount it as /home2 (so it can be used to backup the primary hard-drive daily)

Thanks in advance.

Moe

Posted 2012-02-19T14:30:39.780

Reputation: 389

Answers

2

You will need to resize the root filesystem (resize2fs) to 1TB or less, then resize the logical volume (lvresize / lvreduce), and remove the second hard drive from the volume group (pvmove followed by vgreduce). If you're just starting, it could be easier to get the server provider to reinstall the OS.

The Arch Wiki has examples on modifying LVM volumes using the command line: https://wiki.archlinux.org/index.php/LVM#Configuration

lmz

Posted 2012-02-19T14:30:39.780

Reputation: 364

The link is great, thanks. I keep getting the error that the device is mounted and that "on-line resizing required". And I cannot unmount the "/" because the devices are using it. What can I do? – Moe – 2012-02-19T15:03:54.887

Get the server provider to reinstall :) Or ask for KVM/IP access and a rescue CD to boot from. – lmz – 2012-02-19T15:05:05.220

I ended up getting my host to reload the OS with the partition requirements. Thanks. – Moe – 2012-02-19T20:54:50.213

1

This doesn't really answer your question directly, but is probably a better approach if I understand what you're trying to do correctly.

If you intend to use the second hard drive to backup the primary drive everyday, would it not be better to run the hard drives in a RAID-1 configuration? RAID-1 writes the data to both drives simultaneously - you can boot the system, even if all the drives (except 1) fail (so one drive can also be used to "build" another into the array, in-case one dies).

If you do not have a RAID card, this can also be achieved using software RAID, configured during the CentOS installation. This documentation is slightly outdated, but will get the job done: Configuring Software RAID

Josh

Posted 2012-02-19T14:30:39.780

Reputation: 364

RAID 1 is a good idea to improve reliability, but RAID is not backup. – lmz – 2012-02-19T15:33:46.920

1Yes, but he didn't say what exactly he wanted to backup. If the second drive will be an almost mirror of the first drive, it would probably be better to use RAID anyway. It isn't like the second drive would be detached from the host when not being used to backup, so it doesn't offer any advantages over a RAID implementation (unless it is a partial backup, and the rest of the free space might be used to store other things). – Josh – 2012-02-19T15:42:24.120