0

I have a Proxmox disk with 130Gb LVM image. I moved it to 235Gb disk. And resized in the Proxmox. Done.

But in my Linux distro, the partition still 130Gb (disk become 235Gb).

The partitions: /dev/sda1 /dev/sdb1

They are part of RAID1 volume: /dev/md0

What is the correct way to resize it from 130Gb to 235Gb without loosing data?

**root@debian:~# fdisk -l**

Disk /dev/sdb: 235 GiB, 252329328640 bytes, 492830720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd098f1da

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1            2048 273436671 273434624 130.4G fd Linux raid autodetect
/dev/sdb2       273436672 291502079  18065408   8.6G fd Linux raid autodetect

Disk /dev/sda: 235 GiB, 252329328640 bytes, 492830720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x559572cb

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 273436671 273434624 130.4G fd Linux raid autodetect
/dev/sda2       273436672 291502079  18065408   8.6G fd Linux raid autodetect

Disk /dev/md0: 130.3 GiB, 139864309760 bytes, 273172480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/md1: 8.6 GiB, 9241100288 bytes, 18049024 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


**root@debian:~# cat /proc/mdstat**
Personalities : [raid1]
md1 : active (auto-read-only) raid1 sda2[0] sdb2[1]
      9024512 blocks super 1.2 [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
      136586240 blocks super 1.2 [2/2] [UU]
      bitmap: 0/2 pages [0KB], 65536KB chunk

unused devices: <none>


**root@debian:~# cat /proc/partitions**
major minor  #blocks  name

   8       16  246415360 sdb
   8       17  136717312 sdb1
   8       18    9032704 sdb2
   8        0  246415360 sda
   8        1  136717312 sda1
   8        2    9032704 sda2
  11        0    1048575 sr0
   9        0  136586240 md0
   9        1    9024512 md1

I tried without succes:

**root@debian:~# mdadm --grow --size max /dev/md0**
mdadm: component size of /dev/md0 unchanged at 136586240K
unfreeze

**root@debian:~# resize2fs /dev/md0**
resize2fs 1.43.3 (04-Sep-2016)
The filesystem is already 34146560 (4k) blocks long.  Nothing to do!
0

Although the mdadm grow command is correct, it doesn't help here because your partitions are still of the old size.

Disk /dev/sdb: 235 GiB, 252329328640 bytes, 492830720 sectors
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1            2048 273436671 273434624 130.4G fd Linux raid autodetect
/dev/sdb2       273436672 291502079  18065408   8.6G fd Linux raid autodetect

Your disk is 235G, but the partition is only 130G large and mdadm only sees those 130G.

So you'd have to grow the partition, but there's your next problem, another partition is already there and in the way. So you have to move the 2nd partition away first before you can grow the 1st partition. Another option would be to create a new, 3rd partition and a new RAID on top and use them separately.

If that 8G RAID happens to be swap space, you could also disable swap temporarily, stop the swap RAID, delete those partitions and then grow/re-create as you see fit. Unlike user data, swap can be discarded and re-created on a whim, without a migration step.

  • Thanks! So, I need to delete sda2 and sdb2 (yes, it's swap). How to I do all that exactly? Can you help me with the command please? – user1443462 Jan 5 at 19:21
0

So, if somebody need it. I found working way. I used systemrescuecd.

First step it to remove sda1/2 from RAID1: mdadm /dev/md0 --fail /dev/sda1 mdadm /dev/md1 --fail /dev/sda2 mdadm /dev/md0 --remove /dev/sda1 mdadm /dev/md1 --remove /dev/sda2

After I removed /dev/sda2 in Gparted (via systemrescuecd)

Removed labels "boot" and "raid" from SDA1 in Gparted

Then, in the command line: Parted /dev/sda resizepart 1 245000 quit

Created sda2 in Gparted linux-swap.

mdadm --add /dev/md0 /dev/sda1 mdadm --add /dev/md1 /dev/sda2

Same thing for sdb1/2.

After: e2fsck -f /dev/sda1 e2fsck -f /dev/sdb1

And: mdadm --grow --size max /dev/md0

Then I used "check" for md0 in GParted.

Done. Works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.