Search code examples
servercentos7volumemount

How to attach extra volume on Centos7 server


I have created additional volume on my server. Filesystem Size Used Avail Use% Mounted on /dev/sda1 19G 3.4G 15G 19% / devtmpfs 874M 0 874M 0% /dev tmpfs 896M 0 896M 0% /dev/shm tmpfs 896M 17M 879M 2% /run tmpfs 896M 0 896M 0% /sys/fs/cgroup tmpfs 180M 0 180M 0% /run/user/0 /dev/sdb 25G 44M 24G 1% /mnt/HC_Volume_1788024 How can I attach /dev/sdb either to the whole server (I mean merge it with "/dev/sda1") or assign it to specific directory on server "/var/lib" without overwriting current /var/lib...


Solution

  • Your will not be able to "merge" as you are using standard sdX devices and not using something like LVM for file systems. As root, you can manually run: mount /dev/sdb /var/lib/

    The original content of /var/lib will still be there (taking up space on your / filesystem) To make permanent, (carefully) edit your /etc/fstab and add a line like:

    /dev/sdb           /var/lib                   FILESYSTEM_OF_YOUR_SDB_DISK     defaults        0 0
    

    You will need to replace "FILESYSTEM_OF_YOUR_SDB_DISK" with the correct filesystem type ("df -T", "blkid" or "lsblk -f" will show the type)

    You should test the "correctness" of your /etc/fstab by first: umount /var/lib (if you previously mounted) Then run: mount -a then df -T and you should see the mount point corrected and the "mount -a" should have not produced any error.