Thursday, March 5, 2015

Resize partiton on SD card

How to resize the partition on SDcard?
Scenario: You have written an image onto sdcard and that image is not using all the space on the disk
using gparted and parted.

# parted /dev/mmcblk0
- unit chs
- print
(This will show capacity of the sdcard in terms of cylinder-head-sector)
Max value is capcity -1 cylinder.

-- Sample --
$ sudo parted /dev/sdd
(parted) unit chs
(parted) print
Disk /dev/sdd: 121535,3,31
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 121536,4,32.  Each cylinder is 65.5kB.
Partition Table: msdos

Number  Start      End         Type     File system     Flags
 1      16,0,0     1215,3,31   primary  fat32           lba
 2      1232,0,0   26671,3,31  primary  ext4
 3      26688,0,0  29743,3,31  primary  linux-swap(v1)
-- Sample end --

then use "resizepart" command to resize the partition.

Optionally i can use gparted to do the same thing graphically.

Wednesday, February 18, 2015

Useful Commandline

To copy files preserving parents use --parent
$ cp --parents source destination

Saturday, May 24, 2014

SSH Agent Forwarding


Scenario

  • - Password login is disabled on both the servers Node1 and Node2
  • - Your public key is added to both the servers Node1 and Node2 when they were created. (for example using OpenStack)
  • - Firewall rules only allow access to Node1


Question
- How to login to Node2

Solution: Enable agent forwarding


  •  Add your ssh private key to ssh forwarding agent

 ssh-add -c  ~/.ssh/your_private_key

  •  ssh to Node1 by enabling agent forwarding, like so:

 ssh user@Node1 -A

  •  Once you login to Node1, you can login again to Node2

 ssh user@Node2

  •  You can combine both steps into 1 command like so

 ssh user@Node1 -A -t ssh user@Node2


Friday, January 3, 2014

VIM Chores

1. Read the output of a vim command (ex mode).
Say for example to list all the loaded plugins in vim

:redir @q 
:scriptnames
:redir end 

The output is now saved into q register. 
To paste from register q just type:

 "qp 

 The output is in vim now.

2. Read the output of a external command in vim
Say for example, i want to get the list of all processes in linux in vim

:read !ps -ef

and the processlist is now in the vim buffer.

Thursday, August 8, 2013

Automatically mount Netgear ReadyShare folder in linux (fedora) at boot

Here is the sweet little /etc/fstab entry that mounts the Netgear ReadyShare folder at boot time to a local folder on my linux desktop(Fedora 18!). Theoretically, it mounts when you first access the mount point.

//192.168.1.1/USB_Storage /readyShare cifs x-systemd.automount,guest,noperm,sec=ntlm 0 0