Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
root@ttyp3[knoppix]# losetup -a
/dev/loop0: [1641]:11 (/mnt/hdd1/discoa.dat) offset 0, no encryption
/dev/loop1: [1641]:12 (/mnt/hdd1/discob.dat) offset 0, no encryption
/dev/loop2: [1641]:13 (/mnt/hdd1/discoc.dat) offset 0, no encryption
/dev/loop3: [1641]:14 (/mnt/hdd1/discod.dat) offset 0, no encryption
I have set up all 4 images.... but now I get messages about wrong raid superblock magic. Perhaps it's because I'm not ordering the disks in the array the right way?
dmesg:
Code:
[events: 00000000]
md: invalid raid superblock magic on [dev 07:00]
md: [dev 07:00] has invalid sb, not importing!
md: could not import [dev 07:00]!
md: autostart [dev 07:00] failed!
[events: 00000000]
md: invalid raid superblock magic on [dev 07:01]
md: [dev 07:01] has invalid sb, not importing!
md: could not import [dev 07:01]!
md: autostart [dev 07:01] failed!
[events: 00000000]
md: invalid raid superblock magic on [dev 07:02]
md: [dev 07:02] has invalid sb, not importing!
md: could not import [dev 07:02]!
md: autostart [dev 07:02] failed!
[events: 00000000]
md: invalid raid superblock magic on [dev 07:03]
md: [dev 07:03] has invalid sb, not importing!
md: could not import [dev 07:03]!
md: autostart [dev 07:03] failed!
Any ideas here? Maybe there's a way to figure out the order of the images in the array by reading certain binary data from them.
I have being taking a look at the separate devices with mdadm. It says there is no dm superblock in any of the images.
So I decided to take a look with mdadm with a very simple software raid 5 I started from scratch. When I query the separate devices, it says they are not md devices either. What's going on?
Code:
md: marking sb clean...
md: md1 stopped.
md: unbind<[dev 07:06],2>
md: export_rdev([dev 07:06])
md: unbind<[dev 07:05],1>
md: export_rdev([dev 07:05])
md: unbind<[dev 07:04],0>
md: export_rdev([dev 07:04])
[events: 00000000]
md: invalid raid superblock magic on [dev 07:04]
md: [dev 07:04] has invalid sb, not importing!
md: could not import [dev 07:04]!
md: autostart [dev 07:04] failed!
[events: 00000000]
md: invalid raid superblock magic on [dev 07:05]
md: [dev 07:05] has invalid sb, not importing!
md: could not import [dev 07:05]!
md: autostart [dev 07:05] failed!
[events: 00000000]
md: invalid raid superblock magic on [dev 07:06]
md: [dev 07:06] has invalid sb, not importing!
md: could not import [dev 07:06]!
md: autostart [dev 07:06] failed!
For your own confort, I have prepared a script so you can do what I do here in a single step.
It will create three 10mb files that will be the images of a brand new raid (disk0.dat, disk1.dat and disk2.dat) in the local directory.
It will "loop" them to /dev/loop0, 1 and 2.
It will create a config file in the local directory.
Will make the raid device (/dev/md0) with the local config file the script just created.
Will format it (ext3)
Will mount it on /mnt/tmp
Will copy there the config file
Will umount the raid, stop it, start it again, cat the file from there, umount, stop the raid again, and finally remove the loop devices.
The problem is that it always fails when reatsrting the raid after having stoped it the first time. Why is that?
script:
Code:
echo creation of the images and the loop devices
for i in 0 1 2; do
echo Image $i
dd if=/dev/zero count=10 bs=1M of=disk$i.dat
losetup /dev/loop$i $PWD/disk$i.dat
done;
echo creation of the conf file
echo raiddev /dev/md0 > raidtab
echo $'\t'raid-level$'\t\t'5 >> raidtab
echo $'\t'nr-raid-disks$'\t\t'3 >> raidtab
echo $'\t'nr-spare-disks$'\t\t'0 >> raidtab
echo $'\t'persistent-superblock$'\t'0 >> raidtab
echo $'\t'chunk-size$'\t'64 >> raidtab
echo >> raidtab
for i in 0 1 2; do
echo $'\t'device$'\t\t'/dev/loop$i >> raidtab
echo $'\t'raid-disk$'\t\t'$i >> raidtab
done
echo building the raid device
mkraid -c raidtab /dev/md0 && \
echo formatting to ext3 &&
mkfs.ext3 /dev/md0 && \
echo mounting && \
mount /dev/md0 /mnt/tmp && \
echo copying a file to the raid && \
cp raidtab /mnt/tmp/ && \
echo output of the file: && \
cat /mnt/tmp/raidtab && \
echo umounting &&
umount /mnt/tmp && \
echo shuting down the raid && \
raidstop /dev/md0 && \
echo starting the raid again && \
raidstart -c raidtab /dev/md0 && \
echo mounting again && \
mount /dev/md0 /mnt/tmp && \
echo show the file inside && \
echo the raidtab is && \
cat /mnt/tmp/raidtab && \
echo "Great! We could do it!"
echo
echo one way or the other, bring the raid down
raidstop /dev/md0
echo .... and remove the loop devices
for i in 0 1 2; do
echo device $i
losetup -d /dev/loop$i
done;
A few months ago, I have used a loop device to make a FAT filesystem with those instructions on the site that I posted. You have to specify "-o" option in order to make it feel like it is a disk. If you do not, you will have an error. I have never seen an "-a" option for losetup.
The script will not work. When using dd that way, you have to use "dd if=/dev/zero of=disk1.dat bs=516096 count=21". This syntax just make the file be almost near hard drive specs. After it is done, you have to use losetup to bring up the loop device and make a partition. Then specify partition type like RAID. Next detach the loop device. Then re-connect the loop device but specify the -o with value of 32256. Now you can setup it up the partition on the loop device in RAID. Yes, you have to always use -o32256 when bring up the loop devices for hard drive disk images. Again, the MBR information starts on the front of the image from 0 to 32256.
Oh, man! You got me SOOOOOO close to solving this problem.
I tried the -o option with the images of the RAID I'm trying to get the data from. It just complained about ONE superblock!
This is the output of dmesg:
Code:
md: invalid raid superblock magic on loop0
md: loop0 has invalid sb, not importing!
md: could not import loop0!
md: autostart unknown-block(0,1792) failed!
What a difference from when I started. Any idea how to get rid of THIS single error message?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.