stevepedwards.com/DebianAdmin linux mint IT admin tips info

Cheap But Handy USB/SATA/IDE Backup Gizmos from the Web

Linux' ability to copy and/or replace data easily for backup purposes is second to none with tools such as cp, rsync and dd, so with cheap hardware like these below, making/changing Windows or Linux drive/partition/file backups from spare SATA hard drives is even easier, as you don't need to take the cover off a tower to supply power from spare connectors you may not even have in the running PC. Ideal for IT Field Techs or anyone really...

The two I bought this week (£13 and £3 resp) show a mains powered unit required to power SATA/IDE hard disks with 2 amp current;

http://www.ebay.co.uk/itm/351853736993?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

and a USB/mains 12V, 2A PSU optionally powered device, ideal for low power 5V SSD drives if you don't have a generic 12V PSU to use with hard disks:

http://www.ebay.co.uk/itm/391662246422?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

So how can you use them?

Some methods for different situations should give you some ideas...

First, to see them register in linux:

stevee@T3400 ~ $ tail -f /var/log/syslog

Now attach all the connectors - best to plug in the power last - depending on your kit and what you want to do, something like:

When the mains PSU is connected, whether an IDE or SATA, you should see the device ID show similar to:

Jan 20 13:58:18 T3400 kernel: [12794.948018] usb 2-6: new high-speed USB device number 5 using ehci-pci
Jan 20 13:58:19 T3400 kernel: [12795.081278] usb 2-6: New USB device found, idVendor=1738, idProduct=b0b7
Jan 20 13:58:19 T3400 kernel: [12795.081283] usb 2-6: New USB device strings: Mfr=4, Product=5, SerialNumber=6
Jan 20 13:58:19 T3400 kernel: [12795.081286] usb 2-6: SerialNumber: 20160726
Jan 20 13:58:19 T3400 kernel: [12795.081568] usb-storage 2-6:1.0: USB Mass Storage device detected
Jan 20 13:58:19 T3400 kernel: [12795.081908] scsi host9: usb-storage 2-6:1.0
Jan 20 13:58:19 T3400 mtp-probe: checking bus 2, device 5: "/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-6"
Jan 20 13:58:19 T3400 mtp-probe: bus: 2, device: 5 was not an MTP device
Jan 20 13:58:20 T3400 kernel: [12796.080931] scsi 9:0:0:0: scsi scan: INQUIRY result too short (5), using 36
Jan 20 13:58:20 T3400 kernel: [12796.080940] scsi 9:0:0:0: Direct-Access SAMSUNG HD251HJ PQ: 0 ANSI: 0
Jan 20 13:58:20 T3400 kernel: [12796.081311] sd 9:0:0:0: Attached scsi generic sg5 type 0
Jan 20 13:58:20 T3400 kernel: [12796.082123] sd 9:0:0:0: [sde] 488397168 512-byte logical blocks: (250 GB/232 GiB)
Jan 20 13:58:20 T3400 kernel: [12796.084373] sd 9:0:0:0: [sde] Write Protect is off
Jan 20 13:58:20 T3400 kernel: [12796.084379] sd 9:0:0:0: [sde] Mode Sense: 3b 00 00 00
Jan 20 13:58:20 T3400 kernel: [12796.085407] sd 9:0:0:0: [sde] No Caching mode page found
Jan 20 13:58:20 T3400 kernel: [12796.085411] sd 9:0:0:0: [sde] Assuming drive cache: write through
Jan 20 13:58:20 T3400 kernel: [12796.116316] sde: sde1 sde2 < sde5 >
Jan 20 13:58:20 T3400 kernel: [12796.127919] sd 9:0:0:0: [sde] Attached SCSI disk
Jan 20 13:58:21 T3400 kernel: [12797.161528] EXT4-fs (sde1): mounted filesystem with ordered data mode. Opts: (null)
Jan 20 13:58:21 T3400 udisksd[2542]: Mounted /dev/sde1 at /media/stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808 on behalf of uid 1000

If you have valid, readable data on the disk, it's contents window should open also:

Ah, it's a spare Linux Mint install..what a surprise!

So what machine was it originally from? You can find out by window or command line, as the file system auto mounted at :

/media/stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808

so, read it's hostname in it's /etc/hostname:

sudo vi /media/stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808/etc/hostname
[sudo] password for stevee:

intelmint

That machine does not exist anymore as it's now a dedicated W10 box (tech support reasons only I assure you!)

What might you want to do before you put this disk in a spare PC?

Maybe update your current home directory contents to this disk? This is easy using your current backup aliases and rsync assuming you have aliases setup already, or type them from scratch into a .bash_aliases file.

I now use my T3400 as my main PC via a TV, with enlarged fonts for less eye strain wearing glasses on laptops, so I have multiple backup aliases set up and saved in .bash_aliases so I can run them manually when I like, to keep my other PC's backed up remotely from the T3400. If I download a file from the Internet, I can back it up instantly to any other PC set up for an alias as below:

stevee@T3400 ~ $ ls -ha ./
. .dbus .Heaven .openshot .viminfo
.. Desktop .hplip Pictures VirtualBox VMs
.bash_aliases .dmrc .ICEauthority .pki .Xauthority
.bash_history Documents ID .profile .xsession-errors
.bash_logout Downloads .kchmviewer Public  
.cache .gconf .linuxmint .selected_editor
.cinnamon .gksu.lock .local .ssh
.config .gnome .mozilla Templates
Contacts .gnome2 Music Videos

stevee@T3400 ~ $ alias
alias BIGducks='du -cBG * | sort -nr | head -11'
alias MEducks='du -cBM * | sort -nr | head -11'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias buAMDA8='rsync -e ssh --progress /home/stevee/* stevee@AMDA8:/home/stevee/ --exclude=~/.    -vah'
alias budell490='rsync -e ssh /home/stevee/* stevee@dell490:/home/stevee/ --exclude=~/. --delete-excluded --exclude=VirtualBox\ VMs/ -vah'
alias budellmint='rsync -e ssh /home/stevee/* stevee@dellmint:/home/stevee/ --exclude=~/. --exclude=Videos --exclude=VirtualBox\ VMs/ -vah'
alias ducks='du -cks * | sort -rn | head -11'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --colour=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'

Most of these were explained in older Posts, and are critical in keeping network admin to a lazy minimum! They should be self explanatory, as an alias is just a short version of a longer, less convenient command to type. The key things are the rsync switches -vah:

verbose: shows me transfer details live

archive: saves directories recursively

human-readable: shows sizes in k,m, g byte sizes

I'm going to use an existing alias/rsync command for my current T3400 user account that backs up an identical clone of my account files (except hidden files) to another networked PC, then amend it to suit writing to the local spare disk's user account instead:

alias budellmint='rsync -e ssh /home/stevee/* stevee@dellmint:/home/stevee/ --exclude=~/. --exclude=Videos --exclude=VirtualBox\ VMs/ -vah'

First, it a local copy, so ssh is not required, just rsync alone.

Also, I think I want to save the VirtualboxVM machines I have on the T3400 also, so I don't exclude this folder, but I don't want to copy my local hidden files still, such as massive google caches etc. so keep the --exclude=~/. function. Always add the rsync dry run (-n) option to check it works as you want and does not delete things it should not!

However I don't care what old user files are in this drive's /stevee directory, so will delete them with the --delete-excluded switch:

rsync   /home/stevee/*  --delete-excluded  /media/stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808/home/stevee/    --exclude=~/.   -vahn

This dry run copies all my current home directory except the hidden App cache/user files to the spare disk home account AND deletes what is on the drive that is not in my current home directory:

It scrolls fast, so if you want to see what may be deleted, pipe it through less and check the lines:

 rsync   /home/stevee/*  --delete-excluded  /media/stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808/home/stevee/    --exclude=~/.   -vahn | less

sending incremental file list
deleting Desktop/hardinfo_report8.html
deleting Desktop/hardinfo_report.html
deleting Documents/Taxing a vehicle - GOV.UK_files/selection-buttons.js
...

When happy it will copy correctly and not delete what it shouldn't, remove the dry run (n):

 rsync   /home/stevee/*  --delete-excluded  /media/stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808/home/stevee/    --exclude=~/.   -vah

Note that although the /media directory belongs to root, the sub-directories; /stevee/e91e6b73-aa2d-44e7-ab71-5cddb44f0808 is where the disk file system is mounted, of which, IT'S /home/stevee folder still belongs to you from the prior install, so allowing you write access to it.

As the future is SSD, and they are at least 2x faster than most SATA HDs (check USB3 etc.) then the cheaper £3 gizmo is worth having in the tool kit as it powers 5V USB direct to the drive if your USB port can do it, and has 2 connectors for extra power for those USB ports that can't.

Just connect up and plug in as you would any other external USB drive, and as 128GB SSD drives have dropped to around £30 on Ebay, it won't be too far away to have only these drives in all your kit.

Regarding dd, there really is no need to clone linux OSs as it's far quicker to re-install and replace home directory backups than use dd due to speed.

For cloning proprietary disks like Windows, it still can't be beaten for price - it's free!! - if you have a linux system anyway - which EVERY IT user should these days, you don't need a functional Windows system to run Win only cloning software that can copy a boot drive.

Win server OS's offer system drive mirroring, but it may be very time consuming to make/break mirrors to have spare cloned drives for your Win server systems so dd is probably the quicker and more convenient option overall.

You can boot a linux system on your Win PC, then clone that Win drive using one of these USB/SATA devices without removing covers etc.

Just check the clone works so you KNOW you have a functional, ready-to-go backup for the inevitable future HD failure...if you are a small business without a system drive backup, then you would need to allow at least a day's downtime to re-install Win from scratch - Windows DVDs, all licensed software, hours of updates all over again, backup files for how many user accounts? etc...yawn...

But then! If you are a small business, why are you paying for Windows in the first place? Mint desktops are free and do everything and more - securely - that any Windows user usually does.

For cloning, I go by my rough DD past tests experience of about 1.5 - 4hrs to dd 80GB of data to a hard disk - but it all depends on hardware/system speed.

Disk geometry is the only factor to be aware of - even with linux journaled file systems - you may have to run fsck on an unmounted cloned linux drive before you boot it (hence why you may as well re-install from scratch as there is no cost/license issue anyway - and it's FAR quicker - 6 mins from USB install to first functional desktop with Rafaela) if you used disks of different sizes and geometries - so the file system can re-order the data correctly for sector size/inodes etc. and actually boot properly.

Windows does a reasonable job of checking it's file system if dirty (just slow, like everything it does), but if you use different disk types/sizes/geometries it's not guaranteed it will re-organize itself correctly unless identical disk geometries are used - may be important (see the Win10 clone trials with DD later) else you have to re-install on a new drive from scratch for the same machine for a 2nd backup drive - then go through the whole update/Apps/backups re-install process again - very time consuming!

So it's worth having a clone of your Windows system drive for each machine - especially for a workplace/small business that doesn't have an OEM deal or a full time IT staff member to do it all when a drive fails on a critical Win PC..usually at the worst possible time! At least you can change a drive quickly - even if it's files are old - as these can be updated by recent backups - which of course you have!???.

Other handy uses for these gizmos include running linux CAV anti virus on a contaminated Windows drive, or searching for lost files or partitions with testdisk, and of course using any spare hard disks as quick n dirty back up drives.

Use these gizmos to test any drive controller and disk hardware faults - if a drive stops working in a PC it could be controller failure or heat - maybe not a failed drive - removing it and checking it outside will verify this as Disks shows SMART data such as airflow temp records:

What sort of bottleneck are these gizmos? They are USB2 limited so the performance of the SSD drive is around 40MB/s (320Mb/s) read:

I found the cheaper gizmo could power 2.5" SATA hard disks from a generic 0.5A, 12V PSU, and showed the same 40MB/s read speed as above:

Interesting to see the access time differences between SSD and hard disk! HDs are about 17 times slower in comparison! 0.9ms V 17ms.

An IDE drive though showed the read rate at 36MB/s/ - not much slower.

The write rates are about the same - don't be too quick to bin the robust old IDE drives just yet in older PCs! Old PCs make great dedicated network servers - backups, Apache file/webservers, MySQL servers, Network Intrusion Detection Systems (NIDS) using Snort etc.

Other Linux tricks I've used these types of gizmos for - that saved a print company's bacon many times - was cloning a Win2003 boot drive (Sage accounts, customer job database App, no external backups or re-install options) that ran out of partition space (it had been installed with only 3GB of C: drive space by an IT tech!) to a larger drive, then resized that partition using GParted:

Similarly with GParted, I replaced a Factory Reset partition on my laptop as in the old Win7 replacement Post:

Re-install Win 7 With No DVD and Replace Laptop Auto Recovery Partition

The more expensive gizmo comes with a Win driver disk of you want to use it. (I wouldn't risk attaching a virus ridden Windows drive to another working Windows system to run an AV scan personally, before trying linux cleaning options first).

For example, here is a Win10 drive attached to my T3400 using the mains SATA/USB device that won't mount as normal - is it a new, deliberate Win10 method to stop linux accessing Win10 in write mode or just another Win bug? The drive was booted and checked as clean on it's own to check this then trying again I still get:

It will mount -ro which would be enough to virus scan it but not clean it using that warning command above with -ro instead:

stevee@T3400 ~ $ sudo mount -t "ntfs" -ro "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sdd2" "Public/"
stevee@T3400 ~ $ ls Public/
Documents and Settings Program Files (x86) Windows
$GetCurrent Recovery Windows10Upgrade
hiberfil.sys $Recycle.Bin Windows10Upgrade24074.exe
pagefile.sys swapfile.sys Windows10UpgraderApp.exe
PerfLogs $SysReset $WINDOWS.~BT
ProgramData System Volume Information Windows.old
Program Files Users

Same for file recovery - as you can read, you can recover:

stevee@T3400 ~ $ sudo testdisk /dev/sdd2
TestDisk 6.14, Data Recovery Utility, July 2013
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Or unmount and resize in Gparted - as it unmounts anyway for this op it can be resized, and the new partition data is written to the MBR anyway (beware UEFI disks!?) so should work as Win OS dependent - whether it boots again after is a different matter with Win10! - I haven't done it yet:

After this the system partition is now :

So, will it boot? It did, but seemed delayed at log in re-adjusting to it's new size..?

Now I need to know if Win10 Upgrade version will mount ok in Linux as Win 7 does...I haven't checked it yet! Just assumed it will! No it bloody doesn't!!

stevee@Dell490 ~ $ sudo mount -t ntfs-3g /dev/sda2 Public/
Windows is hibernated, refused to mount.
Failed to mount '/dev/sda2': Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the 'ro' mount option.

Funny... my Win10 laptop is doing the exact same thing when booting from an external linux drive as is my HP tower! It won't mount the Windows drives with the same warning as above.

And you wonder why I can't stand the fucking shit that is Windows???

And these bastards have joined the Linux Foundation?? I can guarantee it's mainly to steal other's ideas, as they have always done...

In the mean time, you are stuck with Win10 only tools for tech repair...pile of shite...

Great, I've got to tech support this crap without my main toolkit available now.

All a virus writer has to do is attack this function to keep the drive dirty and not be mountable in linux - great...

Research required...and it's...down to the hiberfile it seems at first google..?

stevee@Dell490 ~ $ sudo ntfsfix /dev/sda2
Mounting volume... Windows is hibernated, refused to mount.
FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Windows is hibernated, refused to mount.
Remount failed: Operation not permitted

No. It's the shutdown method used! What??! Running chkdsk now in cmd as Admin:

C:\WINDOWS\system32>chkdsk

No errors found - clean system...

and shut down using c:>shutdown /s

And that did it!! It now mounts...how typically illogical and shit as usual...but C: is now mountable:

So, after all that shit, is it possible to run a CAV scan? No logical reason why not. The thing to check on the other PCs is to switch off ANY low power/sleep related functions, especially on laptops, but I KNOW this desktop did not have power saves set, as I undo it to stop screens going off - hate those green party freaks...so why it should have any hibernation settings on I don't know - some daft Win10 default somewhere I suppose...

Finally!

If you unmount it again after, then it's shown as clean by:

stevee@Dell490 ~ $ sudo ntfsfix /dev/sda2
Mounting volume... OK
Processing of $MFT and $MFTMirr completed successfully.
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/sda2 was processed successfully.

(I now found out that MS Win10 has released a free DL "Refesh/Re-install" ISO for DVD/USB boot to solve all these Upgrade version problems - just shows they generally cannot write anything that works well when they do their shit "bolt on" upgrade versions - it's always a fudge compromise).

This DL also fixed my Acer laptop's "Memory Management" issue that would not restart.

 

Comments are closed.

Post Navigation