Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
shrink Raid6 with GPT partition table
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
luringen
n00b
n00b


Joined: 20 Aug 2014
Posts: 15
Location: Norwaaay

PostPosted: Sun Dec 13, 2015 7:45 pm    Post subject: shrink Raid6 with GPT partition table Reply with quote

So i've done all of the shrinking of the filesystems and resized the physical LVM Volume, so now i have this:

I'm going to remove one drive from the array:
Code:

$ mdadm -D /dev/md127
/dev/md127:
        Version : 1.2
  Creation Time : Tue Nov  4 20:45:37 2014
     Raid Level : raid6
     Array Size : 4875878400 (4650.00 GiB 4992.90 GB)
  Used Dev Size : 975175680 (930.00 GiB 998.58 GB)
   Raid Devices : 7
  Total Devices : 7
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Sun Dec 13 20:42:55 2015
          State : clean
 Active Devices : 7
Working Devices : 7
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : spoderman:dickbutt
           UUID : cedac4d2:2c86af22:b613b3d8:23e88997
         Events : 127268

    Number   Major   Minor   RaidDevice State
       0       8        2        0      active sync   /dev/sda2
       1       8       18        1      active sync   /dev/sdb2
       2       8       34        2      active sync   /dev/sdc2
       6       8       98        3      active sync   /dev/sdg2
       7       8       50        4      active sync   /dev/sdd2
       5       8       82        5      active sync   /dev/sdf2
       8       8       66        6      active sync   /dev/sde2





Code:

$ parted /dev/md127
GNU Parted 3.2
Brukar /dev/md127
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: Linux Software RAID Array (md)
Disk /dev/md127: 4993GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flagg
        17,4kB  2097kB  2080kB  Free Space
 1      2097kB  644GB   644GB                      lvm
 2      644GB   3990GB  3346GB
        3990GB  4993GB  1003GB  Free Space

(parted)


The funny thing is that i remember when i did this process in reverse that i needed to "extend" or inform the GPT partition table itself that the block device had grown, otherwise it would not recognize the new free space, but now i need to do that again and i can't remember how.

I tried to just reduce the array size first with this result:

(The original size was 4650G, so i just tested first with just one G

Code:

mdadm --grow /dev/md127 --array-size=4649G


Code:


GNU Parted 3.2
Brukar /dev/md127
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Feil: Invalid argument under posisjonering før lesing av /dev/md127
Prøv igjen/Retry/Oversjå/Ignore/Avbryt/Cancel? Retry
Feil: Invalid argument under posisjonering før lesing av /dev/md127
Prøv igjen/Retry/Oversjå/Ignore/Avbryt/Cancel? Ignore
Feil: The backup GPT table is corrupt, but the primary appears OK, so that will be used.
OK/Avbryt/Cancel? OK
Model: Linux Software RAID Array (md)
Disk /dev/md127: 4992GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
(parted) quit



I know GPT stores data at the end of the device, therefore it started bitching when i chopped of one Gig so it could not find it.

So, anyone knows how i can resize or shrink the entire GPT device (meaning the raid array) so that GPT will accepted it's smaller size?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2970
Location: Germany

PostPosted: Sun Dec 13, 2015 8:18 pm    Post subject: Re: shrink Raid6 with GPT partition table Reply with quote

You can fix it with gdisk, x, e, w

Parted itself should be able to fix it as well but I forgot how. Apart from the manual approach where you just re-create partitions accordingly, but that changes PARTUUID.
Back to top
View user's profile Send private message
luringen
n00b
n00b


Joined: 20 Aug 2014
Posts: 15
Location: Norwaaay

PostPosted: Sun Dec 13, 2015 8:24 pm    Post subject: Re: shrink Raid6 with GPT partition table Reply with quote

frostschutz wrote:
You can fix it with gdisk, x, e, w

Parted itself should be able to fix it as well but I forgot how. Apart from the manual approach where you just re-create partitions accordingly, but that changes PARTUUID.



Yea, i've installed gdisk a little earlier today, but thing is that it will automatically relocate it to the end of the disk, i need it to relocate it 1000G from the end of the disk, so that i can reduce the size of the array

Code:

Expert command (? for help): e
Relocating backup data structures to the end of the disk

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/md127.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.



this dosen't actually do anything unless i reduce the size of the array first. but i really don't want to start writing the partition table while it is invalid as in the example in my original post.

Thank you for replying thou :)
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2970
Location: Germany

PostPosted: Sun Dec 13, 2015 8:34 pm    Post subject: Reply with quote

You could create a loop device with --sizelimit on top of the md and then use that for the relocation.

parted (and kernel too, probably) will complain either way, although in the GPT too small case it actually offers to fix directly.


GPT does some things right but it's incredibly backwards in other ways, the way it depends on physical sector size, and the way every program seems to bitch about the position of the backup. I wonder what's the point of having a backup if backup missing or in wrong place breaks everything despite "correct" primary header? How much of that is part of GPT standard, and how much just suboptimal implementation in Linux/partitioners?
Back to top
View user's profile Send private message
luringen
n00b
n00b


Joined: 20 Aug 2014
Posts: 15
Location: Norwaaay

PostPosted: Sun Dec 13, 2015 8:57 pm    Post subject: Reply with quote

Thanks for reply.

Thing is i now remember what i did when i extended the array, i only needed to run parted /dev/md127 and then i got a message saying there was more space available and if it would like to extend it for me, i just tested it now.

I just used gdisk directly after i reduced the array:

Code:

GPT fdisk (gdisk) version 0.8.10

Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): print
Disk /dev/md127: 8388608000 sectors, 3.9 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 7E93FDFC-FCB2-4056-9B69-8036BA43C909
Partition table holds up to 128 entries
First usable sector is 4096, last usable sector is 9749659614
Partitions will be aligned on 2048-sector boundaries
Total free space is 1956690864 sectors (933.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            4096      1258295295   600.0 GiB   8E00
   2      1258295296      7792968750   3.0 TiB     8300

Command (? for help): w
Caution! Secondary header was placed beyond the disk's limits! Moving the
header, but other problems may occur!

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/md127.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.


i guess this is the easy way..
Back to top
View user's profile Send private message
luringen
n00b
n00b


Joined: 20 Aug 2014
Posts: 15
Location: Norwaaay

PostPosted: Mon Dec 14, 2015 9:30 am    Post subject: Reply with quote

Yeah so now I've successfully reshaped the array, so easiest solution is to just forefully do it as i showed in my code above, and then just fix the backup table after --array-size reduction, if anyone wonders about this.

i don't think im gonna mark this as solved because it really isn't, i've just dealt with it in a bad way.

but as far as i can tell, i don't have any data loss. took me around 12 hours i think.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum