Disk Maintenance
From Realm Business Systems Ltd
Contents
Burn ISO to USB
dd if=xxx.iso of=/dev/sdc bs=64K sync
dd copy continue on errors
dd if=/dev/sda conv=noerror,sync of=/dev/sdb bs=64K
ddrescue
ddrescue -d -f -r3 /dev/sda /dev/sdb -b8192 In this example rescue /dev/sda to /dev/sdb ## No need to partition /dev/sdb beforehand, but if the partition table on /dev/sda ## ## is damaged, you will need to recreate it somehow on /dev/sdb. ## ddrescue -f -n /dev/sda /dev/sdb logfile ddrescue -d -f -r3 /dev/sda /dev/sdb logfile ## check for errors ## fsck -v -f /dev/sdb1 fsck -v -f /dev/sdb2 ddrescue command options; -f : Overwrite output device or partition. -n : Do not try to split or retry failed blocks. -d : Use direct disc access for input file. -r3 : Exit after given three (3) retries (use -1 as infinity retries). -b2048 : Sector size of input device [default is set to 512].
Format Disk
parted /dev/sdc mklabel gpt unit TB mkpart primary 0 -0 or; mkpart primary 0.00 1.00TB quit mkfs.ext4 -L BACKUP2 /dev/sdc1 mkfs.xfs /dev/vm/sme mkfs.xfs -L 16TB1 /dev/sdc1
Label
e2label /dev/sdd1 USB1 tune2fs -L volume-label device ntfslabel device new-label xfs_admin -L label device
Zero
Zero MBR; dd if=/dev/zero of=/dev/sdc bs=446 count=1 Zero MBR + Partition Table; dd if=/dev/zero of=/dev/sdc bs=512 count=1 Zero MDADM; dd if=/dev/zero of=/dev/sdc bs=1M count=1024
mdadm repair
mdadm --manage /dev/md1 --add /dev/sdb3
mdadm create
mdadm --create --verbose /dev/md3 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1
After creating, SAVE the RAID configuration
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Mount NTFS
Read Only; mount -t ntfs /dev/xxx /mnt/windows -o ro Read Write; ntfs-3g /dev/sdaX /mnt/windows
Add Disk to MDADM
TEMPPROX:/vm/oldimages# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 1.8T 0 disk ├─sda1 8:1 0 7.5G 0 part │ └─md0 9:0 0 7.5G 0 raid1 [SWAP] ├─sda2 8:2 0 488M 0 part │ └─md1 9:1 0 487.7M 0 raid1 /boot └─sda3 8:3 0 1.8T 0 part └─md2 9:2 0 1.8T 0 raid1 / sdb 8:16 0 1.8T 0 disk └─sdb1 8:17 0 1.8T 0 part /mnt/BACKUP1 TEMPPROX:~# parted /dev/sda GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: ATA WDC WD2003FYYS-0 (scsi) Disk /dev/sda: 2000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 8000MB 7999MB primary boot, raid 2 8000MB 8511MB 512MB primary raid 3 8511MB 2000GB 1992GB primary raid parted /dev/sdb mklabel msdos mkpart primary 1049kB 8000MB mkpart primary 8000MB 8511MB mkpart primary 8511MB 2000GB mdadm --manage /dev/md0 --add /dev/sdb1 mdadm --manage /dev/md1 --add /dev/sdb2 mdadm --manage /dev/md2 --add /dev/sdb3 grub-install /dev/sdb
Manual Disk swap
ABPROX:~# smartctl -a /dev/sda Serial Number: WD-WCAW34414439 ABPROX:~# smartctl -a /dev/sdb Serial Number: WD-WCAW34329788 ABPROX:~# cat /proc/mdstat Personalities : [raid1] md2 : active raid1 sda3[0] sdb3[1] 960505856 blocks super 1.2 [2/2] [UU] bitmap: 2/8 pages [8KB], 65536KB chunk md1 : active raid1 sda2[0] sdb2[1] 499392 blocks super 1.2 [2/2] [UU] md0 : active raid1 sda1[0] sdb1[1] 15616000 blocks super 1.2 [2/2] [UU] unused devices: <none> ABPROX:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 14.9G 0 part │ └─md0 9:0 0 14.9G 0 raid1 [SWAP] ├─sda2 8:2 0 488M 0 part │ └─md1 9:1 0 487.7M 0 raid1 /boot └─sda3 8:3 0 916.1G 0 part └─md2 9:2 0 916G 0 raid1 / sdb 8:16 0 931.5G 0 disk ├─sdb1 8:17 0 14.9G 0 part │ └─md0 9:0 0 14.9G 0 raid1 [SWAP] ├─sdb2 8:18 0 488M 0 part │ └─md1 9:1 0 487.7M 0 raid1 /boot └─sdb3 8:19 0 916.1G 0 part └─md2 9:2 0 916G 0 raid1 / sdc 8:32 0 1.8T 0 disk └─sdc1 8:33 0 1.8T 0 part /mnt/backups mdadm --manage /dev/md0 --fail /dev/sda1 mdadm --manage /dev/md0 --remove /dev/sda1 mdadm --manage /dev/md1 --fail /dev/sda2 mdadm --manage /dev/md1 --remove /dev/sda2 mdadm --manage /dev/md2 --fail /dev/sda3 mdadm --manage /dev/md2 --remove /dev/sda3 sfdisk -d /dev/sdb > sfdisk_sdb.output ABPROX:~# cat sfdisk_sdb.output # partition table of /dev/sdb unit: sectors /dev/sdb1 : start= 2048, size= 31248384, Id=fd, bootable /dev/sdb2 : start= 31250432, size= 999424, Id=fd /dev/sdb3 : start= 32249856, size=1921273856, Id=fd /dev/sdb4 : start= 0, size= 0, Id= 0 sfdisk /dev/sda < sfdisk_sdb.output mdadm --manage /dev/md0 --add /dev/sda1 mdadm --manage /dev/md1 --add /dev/sda2 mdadm --manage /dev/md2 --add /dev/sda3 ABPROX:~# sfdisk -l /dev/sda Disk /dev/sda: 121601 cylinders, 255 heads, 63 sectors/track Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sda1 * 0+ 1945- 1946- 15624192 fd Linux raid autodetect /dev/sda2 1945+ 2007- 63- 499712 fd Linux raid autodetect /dev/sda3 2007+ 121601- 119594- 960636928 fd Linux raid autodetect /dev/sda4 0 - 0 0 0 Empty ABPROX:~# sfdisk -l /dev/sdb Disk /dev/sdb: 121601 cylinders, 255 heads, 63 sectors/track Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sdb1 * 0+ 1945- 1946- 15624192 fd Linux raid autodetect /dev/sdb2 1945+ 2007- 63- 499712 fd Linux raid autodetect /dev/sdb3 2007+ 121601- 119594- 960636928 fd Linux raid autodetect /dev/sdb4 0 - 0 0 0 Empty --------------------------------- HowTo; write the GRUB boot sector dd if=/dev/sdb2 of=/dev/sda2 grub-install /dev/sda grub2-install /dev/sdb
FreePBX RAID recovered
https://help-grub.gnu.narkive.com/tNbK14Jv/grub2-install-couldn-t-find-physical-volume-null grub2-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image. I think I know what happens. Did you reboot after MD was resynced? If not, please try blockdev --flushbufs /dev/sda1 blockdev --flushbufs /dev/sdb1 grub2-install /dev/sda grub2-install /dev/sdb