Archive for the ‘Linux’ Category

Warning: Command line utilities tend to be simple but very powerful i.e. typing incorrect commands (especially the directions of < and > below) can result in your source drive being wiped out – suggest to back up important files before proceeding. Proceed with instructions below at your own risk.

Do following in an OS X terminal

1) Determine source/destination drives/disks;

mount

2) Unmount partition

diskutil unmount /Volume/XXXXXXX

3) Clone/image partition to file (assumes /dev/disk1s2 is source). Note: this can take some time depending on read/write speeds of drives;

sudo su -i
cat /dev/disk1s2|gzip -c9 > ./filename.cat.gz

4) Restore image to partition (assumes /dev/disk1s2 is destination and drive is unmounted). Note: this can take some time depending on write speeds of drives;

sudo su -i
gzcat ./filename.cat.gz > /dev/disk1s2

Above was tested using in OS X 10.12. You may get “unexpected end of file” / “uncompress failed” errors but nevertheless the commands work.

Warning: Linux utilities tend to be simple but very powerful i.e. typing incorrect commands (especially the directions of < and > below) can result in your source drive being wiped out – suggest to back up important files before proceeding. Proceed with instructions below at your own risk.

1) Install pv;


sudo apt-get install pv

2) Determine source/destination drives/disks;


sudo parted

Enter print all in the parted command line then look for /dev/sda, /dev/sdb etc. and associated partition descriptions to determine source/destination drives/disks.

3) Start the actual cloning/imaging (assumes /dev/sda is source and /dev/sdc is destination);


sudo su
pv < /dev/sda > /dev/sdc

4) Install new drive then use linux gparted utility to extend partition sizes.

Above was tested using an Ubuntu 14.04 LiveUSB with an internal source drive containing a Windows 10 and an Ubuntu 14.04 partition. Windows did report a strange error during initial boot after new drive was installed but sorted itself after restarting. No issues found booting into the Ubuntu partition.

SED examples

Posted: April 15, 2016 in Linux
Tags:

sed -i '/^#/d' vendor/broadcom/hammerhead/device-partial.mk #remove all lines beginning with #

sed -i '1,2d' vendor/broadcom/hammerhead/device-partial.mk #delete 1st 2 lines

sed -i 's_:broadcom \\_ _g' vendor/broadcom/hammerhead/device-partial.mk #replace :broadcom \ with a space

sed -i 's_:system_ system_g' vendor/broadcom/hammerhead/device-partial.mk #replace :system with system

sed -i 's_ vendor/_install -D -m 644 vendor/_g' vendor/broadcom/hammerhead/device-partial.mk #replace vendor/ with install -D -m 644 vendor/

sed '1 i\#!/bin/bash' vendor/broadcom/hammerhead/device-partial.mk #add #!/bin/bash to 1st line

Android phones may already have a terminal emulator app installed by default (otherwise install a terminal emulator app from the Google Play store) then do the following;

tar czvf - inputfilename |split -b 5M - outputfilename.tar.gz.

Resulting filenames will be outputfilename.tar.gz.aa, outputfilename.tar.gz.ab, outputfilename.tar.gz.ac etc.

inputfilename can be a file or folder, 5M in above example splits files into 5MB sizes.

To extract/recombine;

cat outputfilename* |tar xzvf -

Credits to StackExchange

Linux curl command usage example

Posted: September 2, 2015 in Linux
Tags:

Enter the following into any Terminal window to begin/continue downloading a file from most webservers.

curl -C - -O http://filename

Credits to TheGeekStuff

sudo pacman -S connman
sudo systemctl stop netctl
sudo systemctl disable netctl
sudo systemctl stop dhcpcd
sudo systemctl disable dhcpcd
sudo systemctl enable connman
sudo systemctl start connman
reboot
connmanctl > enable wifi
connmanctl > scan wifi
connmanctl > agent on
connmanctl > services (then copy wifi hash of your SSID)
connmanctl > quit
sudo touch /var/lib/connman/<SSID>-psk.config
sudo <your editor of choice> /var/lib/connman/<SSID>-psk.config
containing;

[service_wifi_<connman wifi hash of your SSID>]
Type = wifi
Name = <SSID>
Passphrase = <ASCII Passphrase>

… then quit editor/save file

connmanctl > scan wifi
connmanctl > services (and you’ll note an “AO” next to your SSID i.e.
already connected – wifi will be auto enabled upon boot from now on)

Disclaimer:
Custom unwarranted kernels are provided on an “as is basis” – use at your own risk. Steps below also assumes you know how to restore your kernel in case not working. Suggest to only use kernels compiled for your current distribution/version.

Note: this kernel is custom built/tailored for the Toshiba NB205 and will not work properly for any other PC’s/laptops (although it should work for machines with similar hardware)

.config
kernel headers and image

To use/install
1. Extract to any directory using 7-Zip
2. Open terminal window
3. cd {extracted directory)
4. sudo pacman -U *linux-zen-nb-head*3.15.8*.xz
5. sudo pacman -U *linux-zen-nb-3.15.8*.xz
6. Edit kernel command line (either directly in /etc/default/grub or /etc/grub.d/40_custom assuming using Grub2) per below

Comment out the following lines i.e. add a “#” in front

#kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/<boot drive id> loglevel=3 ro quiet resume=/dev/disk/by-uuid/<swap drive id>
#initrd /boot/initramfs-linux.img

Add following below commented line
kernel /boot/vmlinuz-linux-zen-nb root=/dev/<boot drive partition> loglevel=3 ro quiet resume=/dev/<swap drive partition>

Example
kernel /boot/vmlinuz-linux-zen-nb root=/dev/sda3 loglevel=3 ro quiet resume=/dev/sda6

7. Rebuild your grub menu
8. Reboot and enjoy

If your system kernel panics / doesn’t boot
1. Assuming using GRUB2 – select the default ArchBang kernel boot entry at GRUB2 screen then press “E”. Scroll down to the “kernel…” line. Change the kernel name back to vmlinuz-linux and on the next line type initrd /boot/initramfs-linux.img then press “Ctrl-X” to reboot
2. Undo the changes made to /etc/default/grub or /etc/grub.d/40_custom and rebuild grub menu

To uninstall completely
1. Boot into any other kernel
2. Open terminal window
3. sudo pacman -R linux-zen-nb-headers
4. sudo pacman -R linux-zen-nb
5. Undo changes to /etc/default/grub or /etc/grub.d/40_custom, rebuild grub menu per above then reboot

Patches:
http://liquorix.net/sources/3.15.8-1.patch.gz

Note:
Kernel defaults to using BFS CPU scheduler and CFQ IO scheduler.
Add elevator=bfq in kernel command line to use BFQ IO scheduler instead without recompiling.

Credits to:
Damentz for liquorix/zen patch; Nigel Cunningham for TuxOnIce patch; Pappy (Kernel Seeds) for initial .config seed; dieghen89 (kernel-netbook project) for BFQ tip.