LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-18-2016, 09:58 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
Created mdadm array is too small for partitions. Can it be enlarged?


I'm trying to create a RAID mapped to existing partitions per instructions in http://fds-team.de/cms/articles/2013...-player-u.html. I'm using Ubuntu 16.4 and mdadm 3.3.

My fdisk shows:

Code:
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 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: 0x325b78d7

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2048  24578047  24576000  11.7G 27 Hidden NTFS WinRE
/dev/sda2  *     24578048  25163775    585728   286M  7 HPFS/NTFS/exFAT
/dev/sda3        25163776 256779447 231615672 110.5G  7 HPFS/NTFS/exFAT
/dev/sda4       256780286 488396799 231616514 110.5G  5 Extended
/dev/sda5       480221184 488396799   8175616   3.9G 82 Linux swap / Solaris
/dev/sda6       256780288 480221183 223440896 106.6G 83 Linux
Per the instructions, I create the RAID as:
Code:
mdadm --build /dev/md0 --level=linear --raid-devices=3 /dev/loop0 /dev/sda2 /dev/sda3
But, when I fdisk /dev/md0, it does not give me enough sectors:

Code:
Disk /dev/md0: 110.7 GiB, 118888136704 bytes, 232203392 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: 0xccc7addb

Device     Boot  Start       End   Sectors   Size Id Type
/dev/md0p1        2048    587775    585728   286M  7 HPFS/NTFS/exFAT
/dev/md0p2      587776 232203391 231615616 110.5G  7 HPFS/NTFS/exFAT
The 1st partition is exactly the right size as compared with the original fdisk for /dev/sda2, and I can mount /dev/md0p1 and see the files, NP. Even though I've used all remaining sectors for the /dev/md0p2 partition, you can see that it only allocates 231615616 sectors, instead of the needed 231615672 sectors for /dev/sda3. It is 56 sectors too short. Trying to mount this partition gives me:

Code:
$ mount /dev/md0p2 /mnt
Failed to read last sector (231615663): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/md0p2': Invalid argument
The device '/dev/md0p2' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
It there any way to force mdadm to allocate more sectors in the build?

Last edited by mfoley; 08-18-2016 at 10:02 PM.
 
Old 08-19-2016, 05:25 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The size gets rounded down to a multiple of the mdadm chunk size, which is 64KiB by default. With the sizes as shown, that's going to lose 56 sectors. You can either change the chunk size to 4096 bytes ("--chunk=4"), or just pad the array with another 8-sector (4096 bytes) loop device at the end.
 
1 members found this post helpful.
Old 08-20-2016, 12:19 PM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Great! That did it:

Code:
mdadm --build /dev/md0 --rounding=4 --level=linear --raid-devices=3 /dev/loop0 /dev/sda2 /dev/sda3
I used --rounding instead of --chunk simply because the man page said that parameter was for --level=linear. Result:

Code:
root@labrat:~# fdisk /dev/md0
Command (m for help): p
Disk /dev/md0: 110.7 GiB, 118888165376 bytes, 232203448 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: 0xccc7addb

Device     Boot  Start       End   Sectors   Size Id Type
/dev/md0p1        2048    587775    585728   286M  7 HPFS/NTFS/exFAT
/dev/md0p2      587776 232203447 231615672 110.5G  7 HPFS/NTFS/exFAT
You can see this matches the original fdisk /dev/sda exactly for the Windows partitions. I can now mount and see the files:

Code:
$ mount /dev/md0p2 /mnt
$ ls -ltr /mnt
drwxrwxrwx 1 root root          0 Jul 13  2009 PerfLogs
lrwxrwxrwx 2 root root         60 Jul 14  2009 Documents and Settings -> /mnt/Users
drwxrwxrwx 1 root root       4096 Aug  4  2015 ProgramData
drwxrwxrwx 1 root root          0 Aug  5  2015 Intel
drwxrwxrwx 1 root root      16384 Nov  4  2015 Windows
drwxrwxrwx 1 root root       4096 Nov  4  2015 Program Files (x86)
drwxrwxrwx 1 root root       8192 Nov  4  2015 Program Files
drwxrwxrwx 1 root root       4096 Nov  4  2015 Config.Msi
drwxrwxrwx 1 root root       4096 Jan  6  2016 Users
drwxrwxrwx 1 root root       4096 Jan  6  2016 $Recycle.Bin
-rwxrwxrwx 1 root root 3140259840 Jan 25  2016 hiberfil.sys
-rwxrwxrwx 1 root root 4187017216 Jan 25  2016 pagefile.sys
drwxrwxrwx 1 root root       8192 Jan 25  2016 System Volume Information
 
  


Reply

Tags
build, mdadm



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FATAL ERROR: Bad logical partition 7: enlarged logical partitions overlap stf92 Slackware 2 03-18-2016 06:43 PM
[SOLVED] cfdisk : FATAL ERROR: Bad logical partition 10: enlarged logical partitions overlap riller Fedora 8 05-31-2012 08:17 AM
[SOLVED] mdadm: only give one device per ARRAY line: /dev/md/:raid and array laughing_man77 Linux - Hardware 4 03-23-2012 04:05 PM
A special steps require to re-initial RAID0 array created with mdadm? CyyberspaceCowboy Linux - Software 3 10-19-2010 04:48 PM
MDADM screws up the LVM partitions? Can't mount the LVMs after mdadm stopped alirezan1 Linux - Newbie 3 11-18-2008 04:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration