通过命令行调整RAID 0arrays上的分区大小

简单地说,当我设置服务器时,它不打算用于现在的状态,并且root(/)已经耗尽磁盘空间,而/ home有大量的东西浮动。

Filesystem 1K-blocks Used Available Use% Mounted on rootfs 10157944 9600344 45656 100% / /dev/root 10157944 9600344 45656 100% / /dev 8183468 8 8183460 1% /dev none 1636756 252 1636504 1% /run none 5120 0 5120 0% /run/lock none 8183772 0 8183772 0% /run/shm /dev/md3 211225328 17996836 182583336 9% /home 

学过的知识! (下次给/更多房间…)

以下是parted的输出,显示磁盘及其当前大小和RAIDarrays。

 Model: ATA INTEL SSDSA2CW12 (scsi) Disk /dev/sda: 120GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 2097kB 10.5GB 10.5GB primary ext4 boot, raid 2 10.5GB 11.0GB 535MB primary linux-swap(v1) 3 11.0GB 120GB 109GB primary raid Model: ATA INTEL SSDSA2CW12 (scsi) Disk /dev/sdb: 120GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 2097kB 10.5GB 10.5GB primary ext4 raid 2 10.5GB 11.0GB 535MB primary linux-swap(v1) 3 11.0GB 120GB 109GB primary raid Model: Linux Software RAID Array (md) Disk /dev/md3: 218GB Sector size (logical/physical): 512B/512B Partition Table: loop Number Start End Size File system Flags 1 0.00B 218GB 218GB ext4 Model: Linux Software RAID Array (md) Disk /dev/md1: 10.5GB Sector size (logical/physical): 512B/512B Partition Table: loop Number Start End Size File system Flags 1 0.00B 10.5GB 10.5GB ext4 

我需要做的是将/ home分区缩小40GB并将/ partition增加40GB。 当我使用resize命令时Parted告诉我:

 "WARNING: you are attempting to use parted to operate on (resize) a file system. parted's file system manipulation code is not as robust as what you'll find in dedicated, file-system-specific packages like e2fsprogs. We recommend you use parted only to manipulate partition tables, whenever possible. Support for performing most operations on most types of file systems will be removed in an upcoming release." 

并查找e2fsprogs告诉我他们是ext2工具,考虑到磁盘是EXT4,这让我很害怕。

有没有一种安全的方法来调整分区大小? 我正在通过SSH工作在离服务器600英里的地方,没有直接访问权限。

提前致谢

Ext2,ext3和ext4是同一文件系统的演进; 事实上,没有激活新function的ext4文件系统是ext3文件系统,并且没有激活新function的ext3文件系统是ext2文件系统。 这就是为什么ext3和ext4没有单独的程序集:它是同一套工具,e2fsprogs,它们已逐渐增强以应对ext3和ext4。

resize2fs (“ext2 / ext3 / ext4文件系统大小调整器”)的限制是它只能在卸载时收缩文件系统。 因此,如果你想缩小/home ,你需要先卸载它。 你可以扩大一个挂载的文件系统,这对/不是问题。

更大的问题是调整RAID-0arrays的大小。 管理RAIDarrays的一个工具是mdadm 。 据我所知,无法调整RAID-0arrays的大小。

据我所知,除非您愿意在维护期间将所有数据复制到/home/ ,否则您将无法使用此配置。 (您可以放弃仅复制/home的数据并创建一个更大的根分区侵占其空间。)您可以使用磁盘开头的未分区空间来存储/home的当前内容。 这不是很困难,但它容易出错。 这不是我在没有物理访问的情况下尝试的东西(当你将根分区移动时,特别容易搞砸启动加载器)。 你不熟悉这些工具会使你更容易犯一个容易修复的小错误,但只能插入启动CD。

我的建议是移动一大块//home并创建一个符号链接,直到某人可以物理地访问该服务器为止。

对于未来,我建议不要使用md-RAID的RAID-0并使用LVM剥离。 LVM卷可以resize,甚至是已剥离的卷。 LVM在这里稍慢 ,但更容易管理(正如您现在所遇到的问题所示)。 使用RAID进行镜像(RAID-1)和其他RAID模式。

此外,如果您决定坚持使用RAID-0以获得5%的性能提升,那么如果您拥有单个RAID-0arrays则会更容易。