1

I have a disk that was in a mdadm raid1 with a btrfs partition. Now I want to use this partition without the raid stuff and mount it normally. I already zeroed the mdadm superblock, but now the offsets that mdadm created are still present and I can't mount the partition. Before I deleted the superblock, I noted that the data offset was 2048.

What can I do now? I would try to move the partition by that 2048 bit, but I'm not sure how to do that exactly.

Wouldn't it be enough to alter the parition table and set the begin sector 2048 bits further?

Edit: Here is the full information from mdadm

mdadm --examine /dev/sdb
/dev/sdb:
   MBR Magic : aa55
Partition[0] :      4980480 sectors at         2048 (type fd)
Partition[1] :      4194304 sectors at      4982528 (type fd)
Partition[2] :     11329536 sectors at      9437184 (type fd)
root@debian-test:/home/debian# mdadm --examine /dev/sdb3
/dev/sdb3:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 8bd40f46:896acdc5:6f3fa1f7:67f779fc
           Name : dsm-virtualbox:2
  Creation Time : Thu Jul 12 23:05:16 2018
     Raid Level : raid1
   Raid Devices : 1

 Avail Dev Size : 11327488 (5.40 GiB 5.80 GB)
     Array Size : 5663744 (5.40 GiB 5.80 GB)
    Data Offset : 2048 sectors
   Super Offset : 8 sectors
   Unused Space : before=1968 sectors, after=0 sectors
          State : clean
    Device UUID : 5cf0a635:f107d2b7:18498037:0a9d68f7

    Update Time : Thu Jul 12 23:29:40 2018
       Checksum : b3b49d3d - correct
         Events : 6


   Device Role : Active device 0
   Array State : A ('A' == active, '.' == missing, 'R' == replacing)

I'm only interested in partition 3, the rest are system paritions that I'll delete.

0

I am no expert for mdadm, but assuming raw data with just an offset, you are right since you can alter the partition table for accessing the partition as such. You probably need to delete the partition and then create a new partition at the desired location. The MBR is self contained, no data will be written to the partition itself (this is only true for primary partitions).

Alternatively, you can wrap a block device with a loop device, starting at a given offset. The offset reportedly is 2048 sectors, an equivalent of 2048 · 512 = 1048576 bytes.

offset=1048576
losetup -f /dev/sdb3 -o $offset

Then mount the newly created loop block device (usually /dev/loop0).

Or using mount directly:

mount -o loop,ro,offset=$offset /dev/sdb3 /mountpoint

(ro added for safety reasons during experiments.)

  • Just tried it and still got no valid mount: mount -o loop,ro,offset=2048 /dev/sdb3 /mnt/ mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error – Fizz Khalifa Jul 13 '18 at 0:14
  • My bad. The offset is given in sectors, not bytes. I adjusted my answer. Also relevant: unix.stackexchange.com/questions/64889/… – Hermann Jul 13 '18 at 10:37
  • Thanks, just tested it and all worked as expected. I also recreated the partition starting 2048 sectors further, now I can mount it normally. Sadly there seems to be no way to expand that partition to the left to use the space of the first two partitions... still thanks a lot. – Fizz Khalifa Jul 14 '18 at 23:11
  • You are correct. All filesystems I know cannot grow into space before the beginning. But you can move the partition with the filesystem to the beginning of the disk. I recommend gparted. This action is somewhat dangerous as data is physically copied around on the disk. In case of a power loss, complete data loss is likely. – Hermann Jul 15 '18 at 0:08

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.