Skip to content

Instantly share code, notes, and snippets.

@jalons
Created September 14, 2016 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalons/2cc7952270c2b0a2ea62a4edd0dbac1b to your computer and use it in GitHub Desktop.
Save jalons/2cc7952270c2b0a2ea62a4edd0dbac1b to your computer and use it in GitHub Desktop.
mdadm fun
ahlee@ipsum:~$ dd if=/dev/zero of=sda bs=1G count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.998008 s, 1.1 GB/s
ahlee@ipsum:~$ dd if=/dev/zero of=sdb bs=1G count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.60719 s, 412 MB/s
ahlee@ipsum:~$ sudo losetup /dev/loop0 sda
ahlee@ipsum:~$ sudo losetup /dev/loop1 sdb
ahlee@ipsum:~$ sudo mdadm --create --verbose /dev/md99 --raid-devices=2 --level 1 /dev/loop0 /dev/loop1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 1047552K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md99 started.
ahlee@ipsum:~$ sudo mkfs.ext3 /dev/md99
mke2fs 1.42.13 (17-May-2015)
Discarding device blocks: done
Creating filesystem with 261888 4k blocks and 65536 inodes
Filesystem UUID: 3fa9df88-03a1-4bab-a811-65e2624ccf11
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
ahlee@ipsum:~$ sudo mkdir -p /mnt/raid; sudo mount /dev/md99 /mnt/raid
ahlee@ipsum:~$ echo "Testing" | sudo tee /mnt/raid/test
Testing
ahlee@ipsum:~$ sudo umount /mnt/raid
ahlee@ipsum:~$ sudo mdadm --stop /dev/md99
mdadm: stopped /dev/md99
ahlee@ipsum:~$ sudo mdadm --stop /dev/md99
mdadm: stopped /dev/md99
ahlee@ipsum:~$ sudo mdadm --remove /dev/md99
ahlee@ipsum:~$ sudo losetup -d /dev/loop1
ahlee@ipsum:~$ rm sdb
ahlee@ipsum:~$ sudo mdadm -A --force /dev/md98 /dev/loop0
mdadm: /dev/md98 has been started with 1 drive (out of 2).
ahlee@ipsum:~$ sudo mount /dev/md98 /mnt/raid/
ahlee@ipsum:~$ cat /mnt/raid/test
Testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment