Resizing a RAID partition. Newb needs help please

805 views
Skip to first unread message

FLGuy

unread,
Jul 14, 2012, 11:04:31 AM7/14/12
to
Yet another question for this newb.
alt-f flashed to my box.
2 hitachi 1TB discs

I had 880 GB as a RAID 1 md0 and the rest as linear md1
Decided I didn't need that much space as a RAID drive so I used the Filesystem Maintenance page to shrink the md0 and after many hrs I now have md0 as 464.1GB
I did a shrink on the RAID also on the RAID Maintenance Page. Down to 510GB. Great!




Status page shows this:
Dev. Label CapacityAvailable FSMode DirtyAutomatic FSCK in
md0
464.1GB
35.5GB
ext4 RW
43 mounts or 173 days
md1
99.4GB
99.2GB
ext4 RW
49 mounts or 179 days
sda4
486.2MB
467.2MB
ext4 RW
47 mounts or 177 days
sdb4
486.2MB
475.8MB
ext4 RW
45 mounts or 175 days






























I tried to expand md1 (non-raid) on the filesystem maintenance page. It looks like it is expanding then just stops and shows the same size again.
How can I get the extra space as part of md1 (my non-raid section)?

Sorry about all the questions but linux is like Greek to me. That's why I love your easy to use firmware :)
Thanks

Joao Cardoso

unread,
Jul 14, 2012, 5:50:16 PM7/14/12
to al...@googlegroups.com


On Saturday, July 14, 2012 2:53:56 PM UTC+1, FLGuy wrote:
Yet another question for this newb.
alt-f flashed to my box.
2 hitachi 1TB discs

I had 880 GB as a RAID 1 md0 and the rest as linear md1
Decided I didn't need that much space as a RAID drive so I used the Filesystem Maintenance page to shrink the md0 and after many hrs I now have md0 as 464.1GB
I did a shrink on the RAID also on the RAID Maintenance Page. Down to 510GB. Great!

Right.

A little background. that you can also find in the Filesystem/RAID/Disk partitioner help pages:

Your data needs a filesystem, and a filesystem needs a device.
A filesystem can be ext2/3/4, NTFS, fat...
A device can be a physical disk partition such as sda2 (second partition on first disk, sda) or a logical device such as RAID, LVM...
Logical devices are build upon physical disk devices, called disk partitions -- your md0 uses disk physical partition sda2 and sdb2 (second partition on second disk)

A filesystem can be shrink, compacting data at its beginning, so *consecutive* free space space is made available near the end of the device, and you can latter shrink the device.
Or a filesystem can be enlarged, occupying the totality of the available device space.

-If the device is a logical one, such as RAID or LVM, there are device related tools to shrink the device, creating available consecutive free space in the physical devices that supports it ( the RAID components or disk partitions sda2/sdb2 ). But even after doing that the whole physical devices that support the logical devices are still assigned to it. You have to shrink/enlarge the physical device (disk partition) to use the free disk space for other uses, and for that you have to use the Disk Partitioner (see bellow)
(logical devices can also be enlarged to occupy the totality of the supporting physical devices.)

-If the device is a physical one, such as sda4, you have to use the Disk Partitioner to enlarge or shink it

BUT that it is NOT easy, as to maintain safe the filesystem or logical device that a partition supports, the partition CAN'T be moved from its current location, only its length can be adjusted.
Most often following a partition another partition exists, so if you are enlarging the first you are changing the beginning of the second, and that DESTROYS the second partition filesystem/logical device/data.

*** So, you you are a newbie, I don't recommend you to follow that route.***

Even if after these warnings you want to get some advise, without of course any warranty regarding your data safeguard, you have to post your current filesystem, RAID and disk layout. You can post a screenshot of the Filesystem, RAID and Disk Partitioner web pages(two are needed, one for disk sda, other for disk sdb).

From the command line, the equivalent will be

    mdadm --detail /dev/md0 /dev/md1
    sfdisk -luS /dev/sda /dev/sdb
    blkid

...

I tried to expand md1 (non-raid) on the filesystem maintenance page. It looks like it is expanding then just stops and shows the same size again.  
How can I get the extra space as part of md1 (my non-raid section)?

md1 is also a RAID, only a different kind of RAID. The only non-RAID you have is sda4/sdb4.
And you can't increase md1 at md0 expenses without messing with disk partitions, which I don't advise you to do.
 
Sorry about all the questions but linux is like Greek to me. That's why I love your easy to use firmware :)

If it is too easy than you will made mistakes, as there are a couple of concepts that you have to master before ;-)
 
Thanks

FLGuy

unread,
Jul 15, 2012, 8:07:16 AM7/15/12
to al...@googlegroups.com
I understand about the partitions and logical drives. I've used gparted on another system when I put ubuntu on my netbook but never dealt with arrays before. GParted has a nice graphical interface so I could see what was going on. It lets you non-destructively move and resize partitions.
So I guess what I want to do is make sda2 and sdb2 smaller and then expand sda3 and sdb3 into the freed up space.
sda3 and sdb3 have almost no data on them now so I could easily copy that to another place and reload it after resizing. I did put the Alt-f folder on that partition. The data on sda-b2 is critical but should not be affected if the partition is being shrunk. Correct? I don't even use the Linux user files on sda-b4

As I examine my log file it appears the physical order of the partitions on my drives is sd*1, 4, 2, 3 so the two partitions I want to manipulate are at the end of the disk.
So I guess I will have to stop the array md0, then for each disk: fail sd*2, remove sd*2 then change the partition size of sd*2.
After both discs are done with the repartitioning rebuild the array md0 with partitions sda2 and sdb2.
Since I have the Alt-f folder on sd*3 i assume I'll have to re-download the packages and install them on md0 in order to grow the partition sb*3 since that data will be destroyed in the process.
Please give me all the hand holding you can with this process.
Thanks again


Here is the log file you asked for:

# mdadm --detail /dev/md0 /dev/md1
/dev/md0:
        Version : 0.90
  Creation Time : Tue Feb  1 16:36:17 2011
     Raid Level : raid1
     Array Size : 535276224 (510.48 GiB 548.12 GB)
  Used Dev Size : 535276224 (510.48 GiB 548.12 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sat Jul 14 13:17:56 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 01e2fa47:12e7faa6:06a4a40d:274ef8cc
         Events : 0.4214511

    Number   Major   Minor   RaidDevice State
       0       8        2        0      active sync   /dev/sda2
       1       8       18        1      active sync   /dev/sdb2
/dev/md1:
        Version : 0.90
  Creation Time : Tue Feb  1 16:45:11 2011
     Raid Level : linear
     Array Size : 105932416 (101.03 GiB 108.47 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 1
    Persistence : Superblock is persistent

    Update Time : Tue Feb  1 16:45:11 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

       Rounding : 64K

           UUID : fa7ebebd:2a5053fb:5242e129:18629536
         Events : 0.1

    Number   Major   Minor   RaidDevice State
       0       8        3        0      active sync   /dev/sda3
       1       8       19        1      active sync   /dev/sdb3
# sfdisk -luS /dev/sda /dev/sdb

Disk /dev/sda: 121601 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1            63   1060289    1060227  82  Linux swap
/dev/sda2       2088450 1847587454 1845499005  83  Linux
/dev/sda3     1847587455 1953520064  105932610  83  Linux
/dev/sda4       1060290   2088449    1028160  83  Linux

Disk /dev/sdb: 121601 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1            63   1060289    1060227  82  Linux swap
/dev/sdb2       2088450 1847587454 1845499005  83  Linux
/dev/sdb3     1847587455 1953520064  105932610  83  Linux
/dev/sdb4       1060290   2088449    1028160  83  Linux
# blkid
/dev/mtdblock0: TYPE="minix"
/dev/md0: UUID="12370280-8d8f-4b43-bfeb-19f361b36017" TYPE="ext4"
/dev/md1: UUID="657fb9ec-49ae-4b5f-8b20-5e0f818ffbd5" TYPE="ext4"
/dev/sda4: UUID="3b18a5e3-3803-4ce1-bd47-4454d4adfd23" TYPE="ext4"
/dev/loop0: TYPE="squashfs"
/dev/mtdblock1: TYPE="minix"
/dev/sdb4: UUID="0dfd0c2f-fb50-44cd-afc6-45ae00d7fb29" TYPE="ext4"
/dev/sdb2: UUID="47fae201-a6fa-e712-0da4-a406ccf84e27" TYPE="mdraid"
/dev/sda2: UUID="47fae201-a6fa-e712-0da4-a406ccf84e27" TYPE="mdraid"
/dev/sdb1: TYPE="swap"
/dev/sda1: TYPE="swap"
/dev/sdb3: UUID="bdbe7efa-fb53-502a-29e1-425236956218" TYPE="mdraid"
/dev/sda3: UUID="bdbe7efa-fb53-502a-29e1-425236956218" TYPE="mdraid"
#

Joao Cardoso

unread,
Jul 15, 2012, 11:02:14 AM7/15/12
to al...@googlegroups.com


On Sunday, July 15, 2012 1:07:16 PM UTC+1, FLGuy wrote:
I understand about the partitions and logical drives. I've used gparted on another system when I put ubuntu on my netbook but never dealt with arrays before. GParted has a nice graphical interface so I could see what was going on. It lets you non-destructively move and resize partitions.

You called yourself a newbie, not me :-)

'parted' is available as a disk-instalable package for Alt-F; 'parted' is the command line side of 'gparted'.

But first a few remarks:

-Alt-F Disk Partitioner is only able to deal with partitions in start-sector increase order. As such you can't use it with a D-Link partitioned disk. You have to use either fdisk or sfdisk using the command line.

-You can/shall delete the 'alt-f' (notice the case, it is *not* Alt-F) folder, as it is only needed for the reloaded/on-top Alt-F run mode. As you have flashed Alt-F it is not needed and if you decide to return to D-Link firmware the problems you had previously will reappear. You can/shall also remove the fun_plug file.´

-Disk instalable packages are installed in a folder called 'Alt-F' (notice the case, not 'alt-f'). I often install such packages in small partitions, in your case you could use sda4 or sdb4 for that purpose, as you can't use these partitions for other purposes.

-Use of 'parted', which is a disk instalable package, is very tricky, as it will be running from disk and if that disk is being partitioned by 'parted' problems might/will occur during the partitioning. You can install it on an USB pen/stick, but even then problems might arise.

-The Disk Wizard has a bug that makes it not repect the checkbuttons, see the followups on the RC2 announcement.

 
So I guess what I want to do is make sda2 and sdb2 smaller and then expand sda3 and sdb3 into the freed up space.

Yes. I would'nt call "expand" to it, as you are going to change sda3/sdb4 start sector.

You have already shrunk the *filesystem* who lies in md0, followed by shrunking the md0 RAID *device*, so you have to also shrunk the sda2/sdb2 partitions now.
Take care to not specify a too small lenght for those partitions, as you might make errors using decimal-based or binary-based (GB/GiBytes) sizes. It's better to count sectors and give some allowance. Unfortunately Alt-F does not make clear werther displayed sizes are GB or GiB.
After shrunking sda2/sdb2 you should then first 'enlarge' the md0 RAID *device* and afterwards the md0 *filesystem*. Enlarging is fast.
 
sda3 and sdb3 have almost no data on them now so I could easily copy that to another place and reload it after resizing. I did put the Alt-f folder on that partition.

You mean 'alt-f', right?
 
The data on sda-b2 is critical but should not be affected if the partition is being shrunk. Correct?

Correct. But only you know your data value. A backup is always recommended.

If you don't have a disk to backup, and the linear md1 array has no data worth, I would proceed as follow:

Using one RAID1 disk as a backup disk while remaking RAID devices:

-verify that the md0 array is not degraded.
-remove one of your disks and keep it safe in a drawer. All your data is still there and you can recover it if needed. This will be the "old" disk.
-The md0 RAID with your data raid will now be degraded, no problem. I would now made all changes to this disk. I will call it "new". I would even repartition it completely, create new RAID arrays, whatever. Don't forget to create a swap partition as the first disk partition. That's *crucial*. And create a device large enough to hold the data that is in the "old" disk, safe in the drawer. I would use the Disk Wizard for this, and then fine-tune the last partitions using the Disk Partitioner, if needed. RAID will be in degraded state, as only one disk is available.
-I would now re-insert the "old" disk in the box. Your old md0 RAID should also appear in degraded mode, but with other name, md3, e.g,  but usable and with all data on it. Copy the data to the newly created RAID filesystem on the "new" disk; you can use Setup->Folders, but experiment if first.
-After all data is copied to the "new" disk, and after double checking it, I would stop/destroy the "old" disk RAID, copy (your two disks are identical) the partition table from the "new" disk  to the "old" disk using the Disk Partitioner top section -- take extra care here -- then add the "old" disk RAID partition to the "new" disk RAID partition (you have already done this earlier), and your RAID will leave the degraded state after a rebuild.

All this can be done using the web pages, no cli needed.

Please double check the above and if you don't understand anything don't proceed! I might be making an error.

I don't even use the Linux user files on sda-b4

As I examine my log file it appears the physical order of the partitions on my drives is sd*1, 4, 2, 3

Yes. The Disk Partitioner will refuse to work.
 
so the two partitions I want to manipulate are at the end of the disk.

Yes, this simplifies things a lot.
 
So I guess I will have to stop the array md0, then for each disk: fail sd*2, remove sd*2 then change the partition size of sd*2.

I don't think that you need to fail the RAID components, as the RAID has already been shrunk. Just shrunk the partitions, then enlarge the RAID then the filesystem
 
After both discs are done with the repartitioning rebuild the array md0 with partitions sda2 and sdb2.
 
I don't think this to be needed. You don't even need to stop the RAID, as long as it is already shrunk. Just be sure you allow for some margin in the partitions -- remember the GB/GiB issue.

Since I have the Alt-f folder on sd*3 i assume I'll have to re-download the packages

If you mean 'Alt-F', yes. Better to stop all services first (System Utilities).
 
and install them on md0

I would leave that to the end. You don't need disk-instalable packages for the procedure.
 
in order to grow the partition sb*3 since that data will be destroyed in the process.

Yes.
 
Please give me all the hand holding you can with this process.

I think this is all. There are other discussion topics where this is discussed in more detail, look for then first. Unfortunately topic subjects are not always meaningfull :-(
 
Reply all
Reply to author
Forward
0 new messages