TL; DR:如何在线组合RAID + LVM分区(不接触rootfs)?
我有一个服务器,用于以前的东西,并有一定的分区结构创build。 df -h显示
Filesystem Size Used Avail Use% Mounted on /dev/mapper/raid1-rootfs 50G 28G 20G 59% / tmpfs 16G 0 16G 0% /lib/init/rw udev 16G 152K 16G 1% /dev tmpfs 16G 624K 16G 1% /dev/shm /dev/md0 460M 29M 408M 7% /boot /dev/mapper/raid1-data 99G 20G 74G 22% /data /dev/mapper/raid1-mysql 99G 4.6G 89G 5% /data/mysql /dev/mapper/raid1-backup 99G 664M 93G 1% /data/backup /dev/mapper/raid1-activemq 99G 188M 94G 1% /data/activemq /dev/mapper/raid1-backups 1.0T 651G 373G 64% /backup
基本上我不需要不同的/data分区了。 我主要需要将备份存储在/backup上挂载的最后一个分区中。
为了有更多的磁盘空间,我想将其上面的分区的4*99G添加到/backup 。 也可以将它们组合在一个单独的分区中,然后我可以安装一些子目录。
该磁盘被镜像,显然具有LVM。
如何做到这一点我有点失落,我想能够在网上做,我没有物理访问。
你能解释或指导我如何实现这一目标吗?
PS:
fdisk -l告诉我:
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted
lvdisplay输出:
--- Logical volume --- LV Name /dev/raid1/swap VG Name raid1 LV UUID gOtYhu-oORL-JZRy-inlb-hlyn-0qGU-SBxYo3 LV Write Access read/write LV Status available # open 1 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Name /dev/raid1/rootfs VG Name raid1 LV UUID Y3np5X-IyEn-WMGW-2t51-LIiX-9I8z-rnBXZp LV Write Access read/write LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/raid1/activemq VG Name raid1 LV UUID 0mGA9R-wi89-adqN-oI2x-W24j-2qzD-pXJdNA LV Write Access read/write LV Status available # open 1 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Name /dev/raid1/mysql VG Name raid1 LV UUID D5dD6A-1TDZ-fKsO-pc1u-Xttm-Wb2K-RjqAJw LV Write Access read/write LV Status available # open 1 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3 --- Logical volume --- LV Name /dev/raid1/backup VG Name raid1 LV UUID Brfzgy-nDWG-xyAD-b2a5-sTWf-T7hX-jZRiji LV Write Access read/write LV Status available # open 1 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4 --- Logical volume --- LV Name /dev/raid1/data VG Name raid1 LV UUID JmF16w-jLJz-V3Is-WeTb-K0Qn-uG21-WhLWJY LV Write Access read/write LV Status available # open 1 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:6 --- Logical volume --- LV Name /dev/raid1/storage VG Name raid1 LV UUID 0qRsZl-Kbix-6dhc-g7UD-xJuG-tK3t-zP04fd LV Write Access read/write LV Status available # open 1 LV Size 25.00 GiB Current LE 6400 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:7 --- Logical volume --- LV Name /dev/raid1/backups VG Name raid1 LV UUID g3VgO6-QkEv-KlD4-Wo7N-0cvn-Aolg-1hz1P1 LV Write Access read/write LV Status available # open 1 LV Size 1.00 TiB Current LE 262144 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:8
请注意,有一个分区被排除在输出之外,与此操作无关。
首先确保您不再需要存储在/data文件系统上的/data (如果需要,可以在其他位置备份或复制)。 确保没有进程在这些文件系统上使用文件( lsof -n | grep /data )。
卸载文件系统:
# umount /dev/mapper/raid1-backups # umount /dev/mapper/raid1-activemq # umount /dev/mapper/raid1-backup # umount /dev/mapper/raid1-mysql # umount /dev/mapper/raid1-data
如果这些卸载中的任何一个失败,请再次检查是否有任何进程正在使用文件系统。 确保你最后卸载/dev/mapper/raid1-data ,因为其他的文件系统都安装在该文件系统之上。
不要忘记修改/etc/fstab来删除这些文件系统的行。
现在这些逻辑卷不再需要了,您可以删除它们:
# lvremove raid1/data # lvremove raid1/mysql # lvremove raid1/backup # lvremove raid1/activemq
注意raid1/backup ,你也有一个raid1/backups ,你想保持!
请注意,您的lvdisplay输出中显示的raid1/storage也显示为未安装。 检查是否需要该逻辑卷,如果不是,则可以删除该逻辑卷。
现在,分配给这些逻辑卷的空间已经返回为可用于卷组(可以使用vgdisplay raid1进行检查)。 您现在可以增长“备份”逻辑卷:
# lvresize --resizefs --size +XXX raid1/backups
将XXXreplace为您在vgdisplay输出中看到的空闲大小; 如果显示500 GiB,则使用--size +500G 。
--resizefs告诉lvresize和逻辑卷一起修改文件系统; 它使用fsadm命令来做到这一点。 这应该在ext2,ext3,ext4,reiserfs和xfs文件系统上工作。 至lessext3和ext4文件系统在安装时应该可以resize(我不清楚其余部分)。