Archiv für den Monat: Juli 2016

Rescue Raid Data / mount raid disks

Today i want to access/mount a single disk of my WDCloud Mirror Gen2   Raid1 with my Linux

i tried to mount it (first i have figured out the partition with gparted)

root@pc:~# mkdir -p /media/nfsdisk 
root@pc:~# mount /dev/sdb2 /media/
mount: unknown filesystem type 'linux_raid_member'
Medium /dev/sda: 5,5 TiB, 6001175126016 Bytes, 11721045168 Sektoren
Einheiten: sectors von 1 * 512 = 512 Bytes
Sektorengröße (logisch/physisch): 512 Bytes / 4096 Bytes
I/O Größe (minimal/optimal): 4096 Bytes / 4096 Bytes
Typ der Medienbezeichnung: gpt
Medienkennung: 830CEC50-A486-4BBB-82F9-F61FAB8C98F4

Gerät Start Ende Sektoren Größe Typ
/dev/sda1 2048 4196351 4194304 2G Microsoft basic data
/dev/sda2 6293504 11718945899 11712652396 5,5T Microsoft basic data
/dev/sda3 11718946816 11721045134 2098319 1G Microsoft basic data
/dev/sda4 4196352 6293503 2097152 1G Microsoft basic data

Die Einträge der Partitionstabelle stimmen nicht mit der Reihenfolge der Medien überein.

examine /dev/sdb2

root@pc:~# mdadm --examine /dev/sdb2
/dev/sdb2:
          Magic : c54a7cba
        Version : 1.0
    Feature Map : 0x1
     Array UUID : 4151f8f8:4151f8f8:4151f8f8:4151f8f8
           Name : 1
  Creation Time : Thu Nov 19 12:21:47 2015
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 5852141296 (2790.52 GiB 2996.30 GB)
     Array Size : 2926070648 (2790.52 GiB 2996.30 GB)
   Super Offset : 5852141552 sectors
          State : clean
    Device UUID : 22f64ef8:4151f8f8:413abe12:34ac24a6

Internal Bitmap : 2 sectors from superblock
    Update Time : Mon Jul 18 20:57:32 2016
       Checksum : 11e885b1 - correct
         Events : 226


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

 

 

i tried to mount it with

root@pc:~# mdadm -A -R /dev/md1 /dev/sdb2
mdadm: /dev/sdb2 is busy - skipping

 

but it does not work

root@pc:~# mdadm --stop /dev/md1
mdadm: stopped /dev/md1
root@pc:~# mdadm -A -R /dev/md1 /dev/sdb2
mdadm: /dev/md1 has been started with 1 drive (out of 2).
root@pc:~# mount /dev/md1 /media/nfsdisk
root@pc:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1,8T 0 disk 
├─sda1 8:1 0 931,4G 0 part 
├─sda2 8:2 0 2,8G 0 part [SWAP]
└─sda3 8:3 0 928,7G 0 part /home
sdb 8:16 0 2,7T 0 disk 
├─sdb1 8:17 0 2G 0 part 
├─sdb2 8:18 0 2,7T 0 part 
│ └─md1 9:1 0 2,7T 0 raid1 /media/nfsdisk
├─sdb3 8:19 0 1G 0 part 
└─sdb4 8:20 0 1G 0 part 
sdc 8:32 0 1,8T 0 disk 
└─sdc1 8:33 0 1,8T 0 part 
sdd 8:48 0 111,8G 0 disk 
└─sdd1 8:49 0 111,8G 0 part /
sde 8:64 0 119,2G 0 disk 
└─sde1 8:65 0 119,2G 0 part 
sr0 11:0 1 4,2G 0 rom
root@pc:~# mount | grep md1
/dev/md1 on /media/nfsdisk type ext4 (rw)

hint at the end

root@pc:~# mdadm --assemble --scan

 

video 2 mp4 converter

created a new script for movie 2 mp4 convertion

features:

*  save metadata
* save creaton date
* delete greater files if you whant

#!/bin/bash
# 
# converter for video files to mp4
# this script delete also all huger files if you want
# please take care with DELETE FILES = yes
# double check our output first if the quality is good enough for you
# this script keeps metadata and date of creaton for the file
#
# written 2016/07/17 by Daniel Gohlke to clean up my NAS
#
# you need ffmpeg and some codecs, if i forget something please update this script
# sudo apt-get install libavcodec-extra-53 libavutil-extra-51 libavformat-extra-53 libx264-146 ffmpeg
# change what ever you need

EXTENSION_NEW="mp4"
DELETE_FILES="no"
DEFAULT_CRF="22" # some kind of medium
OUTPUT_DIR="output"

read -p "Please enter CRF Quality / higher value is lower quality [51 worst .. 0 Loseless (default $DEFAULT_CRF) ]: " CRF
CRF=${CRF:-$DEFAULT_CRF}
echo "convert with CRF $CRF"


# error handling
function finish {
  if [ $FILENAME ]; then
    echo "some error occoured, cleanup file $OUTPUT_DIR/$FILENAME.mp4"
    echo "Error on line $1"
    rm -f "$OUTPUT_DIR/$FILENAME.mp4"
  else
    echo "User Break, leave $d untouched"
  fi
  rm -f $OUTPUT_DIR/filelist.txt
}

# Trap if something failed
trap 'finish $LINENO' ERR
#trap 'finish $LINENO' EXIT


function start_convert {

 mkdir -p $OUTPUT_DIR
 find . -type f \( ! -iname "filelist.txt" \) | grep -v "$OUTPUT_DIR" > $OUTPUT_DIR/filelist.txt 
   for d in $( cat $OUTPUT_DIR/filelist.txt ); do
#  for d in *; do
    echo "converting with crf $DEFAULT_CRF $d";
    FILENAME=$(basename "$d")
    EXTENSION="${FILENAME##*.}"
    FILENAME="${FILENAME%.*}"
    
    # convert
    ffmpeg -stats -i $d -c:v h264 -strict experimental -crf $CRF -map_metadata 0 $OUTPUT_DIR/$FILENAME.mp4

    # pply another file's attributes to new file
    touch -r $d $OUTPUT_DIR/$FILENAME.mp4    
    FILESIZE_OLD=$(stat -c%s "$FILENAME.$EXTENSION")
    FILESIZE_NEW=$(stat -c%s "$OUTPUT_DIR/$FILENAME.$EXTENSION_NEW")
#    echo $FILESIZE_OLD  
#    echo $FILESIZE_NEW
    
    if [ "$DELETE_FILES" == "yes" ]; then
      echo "delete greater files is turned on"
  
      if [ "$FILESIZE_OLD" -ge "$FILESIZE_NEW" ]; then
        echo "delete $FILENAME.$EXTENSION"
        rm -f $FILENAME.$EXTENSION
      else 
       echo "delete $OUTPUT_DIR/$FILENAME.$EXTENSION_NEW"
       rm -f $OUTPUT_DIR/$FILENAME.$EXTENSION_NEW
      fi
        
    else 
      echo "delete greater files is turned off"
    fi
    
  done

rm -f $OUTPUT_DIR/filelist.txt
exit 0
}

#ffmpeg -stats -i 0621232021DVB-TDasErste.m4v -c:v h264 -strict experimental -crf 20 -map_metadata 0  FILENAMEdefaultcrf20.mp4

# Start Program
read -p "Do you wish to start convert your videos? (y/n)" yn
case $yn in
  [Yy]* ) start_convert;;
  [Nn]* ) exit;;
   * ) echo "Please answer yes(y) or no(n).";;
esac

 

link to github: https://github.com/danielgohlke/scripts/blob/master/converttomp4.sh