1

I have two Raids, raid5(md0) and a raid1(md128). How can I extend "/"? OS is now on raid 5.

    root@backup:~# cat /proc/mdstat
    Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]
    md128 : active raid1 sde1[1] sdd1[0]
          2930134016 blocks super 1.2 [2/2] [UU]
          bitmap: 0/22 pages [0KB], 65536KB chunk

    md0 : active raid5 sdc1[2] sdb1[1] sda1[0]
          1953259520 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
          bitmap: 3/8 pages [12KB], 65536KB chunk


    root@backup:~# df -T
    Filesystem     Type      1K-blocks    Used  Available Use% Mounted on
    udev           devtmpfs    1841008       0    1841008   0% /dev
    tmpfs          tmpfs        378804   10440     368364   3% /run
    /dev/md0p1     ext4     1918608432 1800052 1819325628   1% /
    tmpfs          tmpfs       1894020       0    1894020   0% /dev/shm
    tmpfs          tmpfs          5120       0       5120   0% /run/lock
    tmpfs          tmpfs       1894020       0    1894020   0% /sys/fs/cgroup
    tmpfs          tmpfs        378804       0     378804   0% /run/user/0


root@backup:~# sudo lsblk -f
    NAME        FSTYPE            LABEL            UUID                                   MOUNTPOINT
    sda
    └─sda1      linux_raid_member backup:0         9c8af56c-1472-3844-c14b-5ff1fd2469cc
      └─md0
        ├─md0p1 ext4                               9f23d9b1-5573-4adb-bd98-11c06dc46602   /
        ├─md0p2
        └─md0p5 swap                               5e5c48d6-2fde-48b8-845b-796c9980e9c5   [SWAP]
    sdb
    └─sdb1      linux_raid_member backup:0         9c8af56c-1472-3844-c14b-5ff1fd2469cc
      └─md0
        ├─md0p1 ext4                               9f23d9b1-5573-4adb-bd98-11c06dc46602   /
        ├─md0p2
        └─md0p5 swap                               5e5c48d6-2fde-48b8-845b-796c9980e9c5   [SWAP]
    sdc
    └─sdc1      linux_raid_member backup:0         9c8af56c-1472-3844-c14b-5ff1fd2469cc
      └─md0
        ├─md0p1 ext4                               9f23d9b1-5573-4adb-bd98-11c06dc46602   /
        ├─md0p2
        └─md0p5 swap                               5e5c48d6-2fde-48b8-845b-796c9980e9c5   [SWAP]
    sdd
    └─sdd1      linux_raid_member 192-168-0-11:128 d4539e00-7885-2a62-84a0-94c1884e253c
      └─md128   LVM2_member                        wp1Qak-hzu5-Eb2q-JNvb-aceu-mhQf-703K5N
    sde
    └─sde1      linux_raid_member 192-168-0-11:128 d4539e00-7885-2a62-84a0-94c1884e253c
      └─md128   LVM2_member                        wp1Qak-hzu5-Eb2q-JNvb-aceu-mhQf-703K5N


root@backup:~# dumpe2fs /dev/md128 | grep -i superblock
    dumpe2fs 1.42.13 (17-May-2015)
    dumpe2fs: Bad magic number in super-block while trying to open /dev/md128
    Couldn't find valid filesystem superblock.
Andrei
  • 23

1 Answers1

0

Unfortunately your root partition is not based on LVM, so the way to expand the filesystem has to be expanding the RAID md0. The output of lsblk suggests there is an LVM installation on your md128, but I don't know if there are logical volumes (and therefore maybe active data) on that drive. You could find out with pvscan, vgscanand lvscan.

Before continuing, make sure you have a valid backup of all your valuable data!!

If there are no (valuable) data/no mounted partitions on md128, you can just stop md128 and add the two disks to your md0 to first increase the total space on /dev/md0:

mdadm --stop /dev/md128                   # this will break the md128
mdadm --add /dev/md0 /dev/sdd1 /dev/sdd2  # this will add two hot spares to md0
mdadm --grow /dev/md0 --raid-devices=5    # this will extend md0 to five disks

This could take a very long time (hours to days), as the RAID has to be resynced.

If there is an mdadm config file (/etc/mdadm/mdadm.conf) , you will have to change that to reflect the new configuration.

Now that /dev/md0 has been increased (you may see with fdisk -l /dev/md0), you have to increase the root partition. As /is on md0p1 and swap on md0p5, which is a logical partition in the extended partition md0p2, you first need to move md0p5/md0p2to the end of md0. You can do this with gparted. As the gpartedfeature list says that RAID is only supported in offline mode, you will have to reboot from an installation medium to try ubuntumode and then start gparted.

Select md0as the device to change, then move the extended partition (md0p2) to the end of the 'disk', and afterwards increase /dev/md0p1. This should resize the filesystem too; so in the end your root partition and filesystem will be increased.

Be aware that this process is not without risk, especially if you are new to linux/raid/filesystems. I am not able to describe the process in all details with pictures, as I do not use mdraid at the moment.

As there is already a RAID1 on sdd/sde with maybe LVM prepared, you might also do an easier (and less risky) solution, moving some data to a filesystem on the second RAID and mount that somewhere below / (e.g. move home). If that would be practicable to you, I could give support for that, too.

ridgy
  • 2,516