use "idevice_id --list" to list the UUIDs.
use "deviceconsole" to actually view the logs
deviceconsole -u <UUID>
May 17, 2017
May 16, 2017
unbrick TPLINK Archer C7 V2 (2017-05 from Amazon)
I bricked my Archer C7 v2 with bad configuration.
TFTP boot didn't work for me. It turned out that the product id doesn't match.
Had to connect to console.
1. The pinout is as follows. The warning on this page (https://wiki.openwrt.org/toh/tp-link/tl-wdr7500#tftp_recovery_de-bricking) itself is wrong.

2. I used the Openwrt Snapshot image. I tried the official image from TPLink website but that didn't work. I didn't try the "cut" process described in the above link.
3. The command is as follows
type "tpl" really fast at boot time to stop the autoboot
That's it.
TFTP boot didn't work for me. It turned out that the product id doesn't match.
Had to connect to console.
1. The pinout is as follows. The warning on this page (https://wiki.openwrt.org/toh/tp-link/tl-wdr7500#tftp_recovery_de-bricking) itself is wrong.

2. I used the Openwrt Snapshot image. I tried the official image from TPLink website but that didn't work. I didn't try the "cut" process described in the above link.
3. The command is as follows
type "tpl" really fast at boot time to stop the autoboot
tftpboot 0x81000000 [name of your firmware file].bin erase 0x9f020000 +f80000 cp.b 0x81000000 0x9f020000 0xf80000 reset
That's it.
May 11, 2017
socket buffer size
To find the current socket buffer size:
getsockopt(fdsocket,SOL_SOCKET,SO_RCVBUF,(void *)&n, &m);
getsockopt(fdsocket,SOL_SOCKET,SO_SNDBUF,(void *)&n, &m);
To find out more, do "man getsockopt"
To find the current bytes in the socket's buffer:
ioctl(fd,FIONREAD,&bytes_available)
ioctl(fd,FIONWRITE,&bytes_available)
To find out more, do "man ioctl"
May 8, 2017
FreeBSD recompile kernel
Download:
ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/10.3-RELEASE/src.txz
untar this to /usr/src
Go to the kernel source directory which contains the configurations.
Create a soft link in the /usr/src/sys/amd64/conf named “MYKERNEL” which links to /root/kernels/MYKERNEL file.
Goto the folder created above.
use "uname -a" and "sysctl -a" to check
Enable multi routing table in the kernel:
https://www.mmacleod.ca/2011/06/source-based-routing-with-freebsd-using-multiple-routing-table/
ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/10.3-RELEASE/src.txz
untar this to /usr/src
Go to the kernel source directory which contains the configurations.
cd /usr/src/sys/amd64/confCreate a folder named kernel in the home directory of root user i.e. /root.
mkdir /root/kernels
config -x /root/kernels/MYKERNEL
The above command generates the current configuration of the kernel
Now you can add the options you want to change.
Create a soft link in the /usr/src/sys/amd64/conf named “MYKERNEL” which links to /root/kernels/MYKERNEL file.
ln -s /root/kernels/MYKERNEL
Goto the folder created above.
cd /root/kernels/
To build a file which contains all available options, run the following commands.
cd /usr/src/sys/amd64/conf make LINTGoto the main source folder.
cd /usr/srcBuild and Install the new kernel with reference from the file “MYKERNEL”.
make buildkernel KERNCONF=MYKERNEL make installkernel KERNCONF=MYKERNELNow reboot the machine to boot into the new kernel you just created now.
use "uname -a" and "sysctl -a" to check
Enable multi routing table in the kernel:
https://www.mmacleod.ca/2011/06/source-based-routing-with-freebsd-using-multiple-routing-table/
May 2, 2017
Adding swap to your VM
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
April 4, 2017
seafiles upload error
The solution:
I needed to go into the webui system admin -> settings and change
I needed to go into the webui system admin -> settings and change
FILE_SERVER_ROOT to be seafile.example.com/seafhttp as per the local help text.March 24, 2017
Proxy settings in Windows 10, LAN settings
right click start -> control panel -> internet options -> connections tab -> LAN settings
March 15, 2017
R7000 serial consle
With the top facing up, and Ethernet ports facing away from you, i.e. the 4 console pins on the right bottom of the board, the pinout from left to right is (yellow,red,green for my personal setup):
RX, which should connects to TX of your CP2102
TX
GND
Unused
RX, which should connects to TX of your CP2102
TX
GND
Unused
February 28, 2017
openwrt kernel config change
In OpenWRT build, to change kernel config, you need to do the following:
1. make kernel_menuconfig CONFIG_TARGET=subtarget
This updates the .config file in build_dir/Linux-xxxxx
2. copy the file .config from the above directory to "target/Linux/your-board-name/config-3.14"
3. make V=99
The make command will copy the kernel config file from target/Linux to build_dir
Reference:
https://wiki.openwrt.org/doc/howto/build
1. make kernel_menuconfig CONFIG_TARGET=subtarget
This updates the .config file in build_dir/Linux-xxxxx
2. copy the file .config from the above directory to "target/Linux/your-board-name/config-3.14"
3. make V=99
The make command will copy the kernel config file from target/Linux to build_dir
Reference:
https://wiki.openwrt.org/doc/howto/build
January 12, 2017
golang vim-go setup
1. start with a fresh ~/.vim directory
2. install vim-plug if don't have it:
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'fatih/vim-go'
Plug 'tmhedberg/matchit'
call plug#end()
au FileType go nmap <C-K> <Plug>(go-doc)
let g:go_fmt_command = "goimports"4. inside vim, run "PlugInstall". This installs the plugins specified above. Restart vim. All plugins should be working now.
5. For vim-go, run ":GoInstallBinaries" to install missing tools needed by vim-go
6. Now Shift-K/Ctrl-K should run go-doc for the keyword under cursor.
Note for go-doc to work correctly, the go source code file has to be in $GOPATH/src/package-name. It cannot not be a symlink outside of GOPATH. It cannot be a raw *.go file under $GOPATH/src either. It needs to be under a package directory.
2. install vim-plug if don't have it:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
3. add the following to your .vimrc filecall plug#begin()
Plug 'tpope/vim-sensible'
Plug 'fatih/vim-go'
Plug 'tmhedberg/matchit'
call plug#end()
au FileType go nmap <C-K> <Plug>(go-doc)
let g:go_fmt_command = "goimports"4. inside vim, run "PlugInstall". This installs the plugins specified above. Restart vim. All plugins should be working now.
5. For vim-go, run ":GoInstallBinaries" to install missing tools needed by vim-go
6. Now Shift-K/Ctrl-K should run go-doc for the keyword under cursor.
Note for go-doc to work correctly, the go source code file has to be in $GOPATH/src/package-name. It cannot not be a symlink outside of GOPATH. It cannot be a raw *.go file under $GOPATH/src either. It needs to be under a package directory.
January 6, 2017
windows 10 folder sort slow in file explorer
I solved this by unchecking
the "Allow Files in the folder to have contents indexed in addition to
file properties" option. You do this by first getting the Properties of
the folder, then on the General tab press the Advanced button in the
Attributes section. Apply the changes to the folder and , subfolders and
files.
December 29, 2016
debian/ubuntu snmp has lots of "error on subcontainer ‘ia_addr’ insert (-1)" reports in /var/log/syslog
Modifying /etc/defaults/snmpd and setting "-Lsd" to "-LS6d" in SNMPDOPTS and TRAPDOPTS hides the error message (as suggested by http:// bugs.debian. org/cgi- bin/bugreport. cgi?bug= 559109).
Or you can use `sed -i "s|-Lsd|-LS6d|" /etc/default/snmpd` to fix the problem.
Or you can use `sed -i "s|-Lsd|-LS6d|" /etc/default/snmpd` to fix the problem.
November 30, 2016
solve kvm soft lockup
Update: setting to jiffies on my guest seems to be the most stable (no lockups yet in the last 24 hours) Original Post: I googled around and by adding clocksource=jiffies to my kernel i fixed it. Instead of jiffies you could also try "pit". This is for the guest OS. You can also use kvm-clock if that is available to you. To check, run the following commands and see whether kvm-clock is available
|
Some people say that the best option for a precise clock on the guest is to use the
kvm-clock source (pvclock) which is synchronized with clock's host.There are also reports of disabling C-states in the BIOS.
November 16, 2016
gvim set size and color scheme
put this in ~/_vimrc:
set lines=51 columns=200
winpos 56 56
colorscheme desert
set lines=51 columns=200
winpos 56 56
colorscheme desert
November 4, 2016
batteries, material, voltage
Carbon zinc - non-reversible, 1.5v
Alkaline - non-reversible (basically, but some reversibility can be forced) 1.5 v
NiCd - reversible - 1.2v nominal, 1.35v fully charged, 0.9v discharged
NiMH - reversible - 1.2 v nominal, 1.35 - 1.4v fully charged, 1.0 v discharged
Lead Acid - reversible, 2.0v discharged, 2.3v charged
Lithium Polymer - reversable - 3.7v nominal, 4.2v fully charged, 3.0 discharged
Lithium Ion (LiFePO4) - reversable - 3.3v nominal, 3.6v fully charged, 2.8v discharged
October 11, 2016
hexdump is awesome
It can dump binary with any specified format
hexdump -e '"optional-start" iterations/number_of_bytes "format" "optional-ending"'
Example 1:
hexdump -e '16/1 "%02X " "\n"' x.bin
dumps 16 bytes in a row one-byte-at-a-time, and then adds line return at the row.
To add an offset to each line in the format of 0x0000:
hexdump -e '"0x%04_ax " 16/1 "%02X " "\n"'
Example 2: hexdump -e '"[" 12/1 "%02 " "]\n"' x.bin dumps 12 bytes in a row with [ in the beginning and ] at the end.
October 8, 2016
October 6, 2016
Increasing a KVM Virtual Machine Disk when using LVM and ext4
Scenario: I am running several virtual machine guests using QEMU/KVM.
Both the host and guest operating systems are Ubuntu 12.04 LTS. The
guests are raw images (as opposed to QEMU qcow2 or disk partitions). My
instructions for setting up the virtual machines are here. One of the guests image is stored on the host as:
My goal is to increase the size of the guests hard disk, i.e. increase the raw image size. In this case I will increase it from 20GB to 45GB. Mathew Branwell gives a detailed description of the steps involved. I've basically copied his instructions, with some minor changes to resizing the guest image. In summary the steps are:
Be careful! Your partitions will be different from mine. Use the devices/sizes for your partitions in the following examples. I have an initial boot partion on /dev/vda1 followed by an extended partition with Linux LVM.
I want to increase the size of the Extended and Linux LVM partitions by first deleting them and then creating new ones of the same type but different size. Note the device names and system/IDs in your partition table.
To delete partitions use the d command and specifiy the partition number (2 and 5 in my case):
After rebooting and logging back in, we need to update LVM. First note the current size of the Physical Volume. On my guest virtual machine I have one physical volume:
Source: https://sandilands.info/sgordon/increasing-kvm-virtual-machine-disk-using-lvm-ext4
sgordon@host:~$ ls -lhs /var/vm/ total 14G 14G -rwxr-xr-x 1 libvirt-qemu kvm 20G May 18 14:26 it.imgCurrently the image is allocated 20GB of space. But note that as Linux ext4 file systems support sparse files, it only takes up 14GB on the disk, as the guest is only using 14GB of the 20GB space available. (The -s option for ls shows the actual size). In the guest virtual machine I am using LVM and ext4 filesystems.
My goal is to increase the size of the guests hard disk, i.e. increase the raw image size. In this case I will increase it from 20GB to 45GB. Mathew Branwell gives a detailed description of the steps involved. I've basically copied his instructions, with some minor changes to resizing the guest image. In summary the steps are:
- On the host: Increase the size of the guests image
- On the guest: Increase the disk partition
- On the guest: Increase the LVM physical and logical volumes
- On the guest: Increase the file system size
Guest: Shutdown the Guest Virtual Machine
Before getting started, lets just summarise some details about the guest, in particular the LVM Physical Volumes, Logical Volumes and filesystems. Note that in the examples guest is shown in the prompt indicating the commands are run in the guest (as opposed to the host).sgordon@guest:~$ sudo pvs PV VG Fmt Attr PSize PFree /dev/vda5 vmit lvm2 a- 19.81g 0 sgordon@guest:~$ sudo lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert home vmit -wi-ao 5.84g root vmit -wi-ao 4.66g tmp vmit -wi-ao 4.66g var vmit -wi-ao 4.66g sgordon@guest:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vmit-root 4.7G 1.8G 2.7G 40% / udev 728M 4.0K 728M 1% /dev tmpfs 293M 264K 293M 1% /run none 5.0M 0 5.0M 0% /run/lock none 732M 0 732M 0% /run/shm /dev/vda1 189M 24M 155M 14% /boot /dev/mapper/vmit-tmp 4.7G 198M 4.3G 5% /tmp /dev/mapper/vmit-var 4.7G 1.3G 3.2G 28% /var /dev/mapper/vmit-home 5.9G 2.5G 3.1G 45% /homeThe first step is to shutdown the guest virtual machine:
sgordon@guest:~$ sudo shutdown -P now Broadcast message from sgordon@guest (/dev/pts/0) at 14:51 ... The system is going down for power off NOW!
Host: Increase the Virtual Machine Image Size
Now resize the image on the host machine:sgordon@host:~$ sudo qemu-img resize /var/vm/guest.img +25G Image resized.This increases the guest image file by 25GB. To check:
sgordon@host:~$ ls -lhs /var/vm/ total 14G 14G -rwxr-xr-x 1 root root 45G May 18 14:53 guest.imgNow start and login to the guest for the remaining steps:
sgordon@host$ sudo virsh start guest Domain it started sgordon@host$ ssh guest
Guest: Increase the Partition Size
First on the guest we need to increase the partition sizes using fdisk:sgordon@guest:~$ sudo fdisk /dev/vda Command (m for help):fdisk takes single letter commands as described in the help. Using the command p to print the current partitions:
Command (m for help): p Disk /dev/vda: 48.3 GB, 48318382080 bytes 16 heads, 63 sectors/track, 93622 cylinders, total 94371840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00079e72 Device Boot Start End Blocks Id System /dev/vda1 * 2048 391167 194560 83 Linux /dev/vda2 393214 41940991 20773889 5 Extended /dev/vda5 393216 41940991 20773888 8e Linux LVMNote that my disk (/dev/vda) is 48.3GB, but my partitions are only using 20GB (20773888 blocks).
Be careful! Your partitions will be different from mine. Use the devices/sizes for your partitions in the following examples. I have an initial boot partion on /dev/vda1 followed by an extended partition with Linux LVM.
I want to increase the size of the Extended and Linux LVM partitions by first deleting them and then creating new ones of the same type but different size. Note the device names and system/IDs in your partition table.
To delete partitions use the d command and specifiy the partition number (2 and 5 in my case):
Command (m for help): d Partition number (1-5): 5 Command (m for help): d Partition number (1-5): 2 Command (m for help): p Disk /dev/vda: 48.3 GB, 48318382080 bytes 16 heads, 63 sectors/track, 93622 cylinders, total 94371840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00079e72 Device Boot Start End Blocks Id System /dev/vda1 * 2048 391167 194560 83 LinuxNow lets create new partitions. I will use the same structure as before but use the entire disk. Use the n command:
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (1-4, default 2): 2
First sector (391168-94371839, default 391168): <ENTER>
Using default value 391168
Last sector, +sectors or +size{K,M,G} (391168-94371839, default 94371839): <ENTER>
Using default value 94371839
I create a new extended partition number 2 using the default first and
last sectors. I also need to create the second new logical partition:
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (393216-94371839, default 393216): <ENTER>
Using default value 393216
Last sector, +sectors or +size{K,M,G} (393216-94371839, default 94371839): <ENTER>
Using default value 94371839
I also need to specify the type of the logical partition, i.e. Linux
LVM. From the original partition table the Id of the Linux LVM system is
8e:
Command (m for help): t Partition number (1-5): 5 Hex code (type L to list codes): 8e Changed system type of partition 5 to 8e (Linux LVM)The resulting partition table follows. Note that is is the same structure as the original table but the size of the last two partitions (/dev/vda2 and /dev/vda5) have changed from 20GB to about 45GB.
Command (m for help): p Disk /dev/vda: 48.3 GB, 48318382080 bytes 16 heads, 63 sectors/track, 93622 cylinders, total 94371840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00079e72 Device Boot Start End Blocks Id System /dev/vda1 * 2048 391167 194560 83 Linux /dev/vda2 391168 94371839 46990336 5 Extended /dev/vda5 393216 94371839 46989312 8e Linux LVMIf your partition table is correct then the last step is to write those changes:
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. sgordon@guest:~$Note the warning: you need to reboot for the new partition table to be read:
sgordon@guest:~$ sudo shutdown -r now Broadcast message from sgordon@it (/dev/pts/0) at 15:15 ... The system is going down for reboot NOW!
Guest: Increase the LVM Physical and Logical Volume Sizes
Note that this step only applies if you are using LVM.After rebooting and logging back in, we need to update LVM. First note the current size of the Physical Volume. On my guest virtual machine I have one physical volume:
sgordon@guest:~$ sudo pvs PV VG Fmt Attr PSize PFree /dev/vda5 vmit lvm2 a- 19.81g 0We need to resize the physical volume:
sgordon@guest:~$ sudo pvresize /dev/vda5 Physical volume "/dev/vda5" changed 1 physical volume(s) resized / 0 physical volume(s) not resized sgordon@guest:~$ sudo pvs PV VG Fmt Attr PSize PFree /dev/vda5 vmit lvm2 a- 44.81g 25.00gThe physical volume now takes the full space of 45GB, and there is 25GB free. We will extend the Logical Volumes to use that extra 25GB. In my case I have four logical volumes: home, root, tmp and var (and the correpending directories are mount to them). In this case I want to increase the size of the home and var volumes by 15GB and 10GB, respectively. I will use lvextend which requires you to specify the logical volume relative to the volume group.
sgordon@guest:~$ sudo vgs VG #PV #LV #SN Attr VSize VFree vmit 1 4 0 wz--n- 44.81g 25.00gThe name of my volume group is vmit. So now lets extend the two logical volumes:
sgordon@guest:~$ sudo lvextend -L +15G /dev/vmit/home Extending logical volume home to 20.84 GiB Logical volume home successfully resized sgordon@guest:~$ sudo lvextend -L +10G /dev/vmit/var Extending logical volume var to 14.66 GiB Logical volume var successfully resizedThe result, as shown below, is the volume group now has no space free and the home>/kbd> and var logical volumes are now 21GB and 15GB, respectively.
sgordon@guest:~$ sudo vgs VG #PV #LV #SN Attr VSize VFree vmit 1 4 0 wz--n- 44.81g 0 sgordon@guest:~$ sudo lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert home vmit -wi-ao 20.84g root vmit -wi-ao 4.66g tmp vmit -wi-ao 4.66g var vmit -wi-ao 14.66g
Guest: Increase the Filesystem Sizes
The last step is to grow the filesystems to use the entire logical volume. Currently the filesystems sizes are still the original sizes, as shown below.sgordon@guest:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vmit-root 4.7G 1.8G 2.7G 40% / udev 728M 4.0K 728M 1% /dev tmpfs 293M 252K 293M 1% /run none 5.0M 0 5.0M 0% /run/lock none 732M 0 732M 0% /run/shm /dev/vda1 189M 24M 155M 14% /boot /dev/mapper/vmit-tmp 4.7G 198M 4.3G 5% /tmp /dev/mapper/vmit-var 4.7G 1.3G 3.2G 28% /var /dev/mapper/vmit-home 5.9G 2.5G 3.1G 45% /homeIn my case I am using ext4 filesystems and using resize2fs I can increase their size online, that is, while they're mounted. If you have a different filesystem (or possibly older kernel) online resizing may not be possible; you may need to unmount the filesystems first.
sgordon@guest:~$ sudo resize2fs /dev/vmit/home resize2fs 1.42 (29-Nov-2011) Filesystem at /dev/vmit/home is mounted on /home; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/vmit/home to 5463040 (4k) blocks. The filesystem on /dev/vmit/home is now 5463040 blocks long. sgordon@guest:~$ sudo resize2fs /dev/vmit/var resize2fs 1.42 (29-Nov-2011) Filesystem at /dev/vmit/var is mounted on /var; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/vmit/var to 3842048 (4k) blocks. The filesystem on /dev/vmit/var is now 3842048 blocks long.Note that the resize takes some time. Finally, check the new sizes:
sgordon@guest:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vmit-root 4.7G 1.8G 2.7G 40% / udev 728M 4.0K 728M 1% /dev tmpfs 293M 252K 293M 1% /run none 5.0M 0 5.0M 0% /run/lock none 732M 0 732M 0% /run/shm /dev/vda1 189M 24M 155M 14% /boot /dev/mapper/vmit-tmp 4.7G 198M 4.3G 5% /tmp /dev/mapper/vmit-var 15G 1.3G 13G 9% /var /dev/mapper/vmit-home 21G 2.5G 18G 13% /homeI now have a 15GB /var filesystem and a 21GB /home filesystem.
Source: https://sandilands.info/sgordon/increasing-kvm-virtual-machine-disk-using-lvm-ext4
September 23, 2016
Where to download broadcom Netgear R7000 toolchain binary
The toolchain file is hndtools-arm-linux-2.6.36-uclibc-4.5.3.tar.bz2
Download URL: https://sourceforge.net/projects/nvg599.arris/files/
This tarball also contains the Broadcom code drop bcm963xx_4.06L.03_consumer_release.tar.gz, which was created using Broadcom's source code redistribution process, bcm47xx.tar.bz2 which is the 5GHz code, hndtools-arm-linux-2.6.36-uclibc-4.5.3.tar.bz2, which is the toolchain for the 5Ghz code, and axis.tar.bz2 which is the code that runs on the main SOC.
Download URL: https://sourceforge.net/projects/nvg599.arris/files/
This tarball also contains the Broadcom code drop bcm963xx_4.06L.03_consumer_release.tar.gz, which was created using Broadcom's source code redistribution process, bcm47xx.tar.bz2 which is the 5GHz code, hndtools-arm-linux-2.6.36-uclibc-4.5.3.tar.bz2, which is the toolchain for the 5Ghz code, and axis.tar.bz2 which is the code that runs on the main SOC.
Subscribe to:
Posts (Atom)
