Saturday, November 22, 2014

Accessing Android Device partition from Linux OS

apt-get install mtpfs libfuse-dev libmad0-dev
And now download the mtpfs debian package from


wiz@cb-DOC:~# apt-cache search -f mtp-tools
Package: mtp-tools
Description-md5: b21df6970cd0c308c870019c053e3080
Description-en: Media Transfer Protocol (MTP) library tools
 libmtp is a library for communicating with MTP aware devices in POSIX
 compliant operating systems.  It implements MTP Basic, the subset
 proposed for standardization.
 .
 The Media Transfer Protocol (commonly referred to as MTP) is a devised
 set of custom extensions to support the transfer of music files on
 USB digital audio players and movie files on USB portable media players.
 .
 This package contains tools for communicating with MTP devices.

Here's what the libraries intend 
wiz@cb-DOC:~# apt-cache search -f libfuse-dev 
Package: libfuse-dev
Description-md5: da11b1a71c864509638e23fbce6723a3
Description-en: Filesystem in Userspace (development)
 Filesystem in Userspace (FUSE) is a simple interface for userspace programs to
 export a virtual filesystem to the Linux kernel. It also aims to provide a
 secure method for non privileged users to create and mount their own filesystem
 implementations.
 .
 This package contains the development files.


Package: libmad0-dev
Description-md5: bf2478178701150aac144fa1b8a3ff5f
Description-en: MPEG audio decoder development library
 MAD is an MPEG audio decoder. It currently only supports the MPEG 1
 standard, but fully implements all three audio layers (Layer I, Layer II,
 and Layer III, the latter often colloquially known as MP3.)
 .
 This is the package you need to develop or compile applications that use MAD.

And we have one more package which is mtpfs filesystem, which can be downloaded from https://packages.debian.org/sid/amd64/mtpfs/download or you can enable the Testing SID repos and you can fetch it from. 
apt-get install mtpfs

wiz@cb-DOC:~# apt-cache search -f mtpfs
Package: jmtpfs
Description-md5: 05e78b7506b9ac6b1d84a446189e832e
Description-en: FUSE based filesystem for accessing MTP devices
 jmtpfs is a FUSE and libmtp-based filesystem for accessing MTP (Media Transfer
 Protocol) devices. It was specifically designed for exchanging files between
 Linux (and Mac OS X) systems and newer Android devices that support MTP but
 not USB Mass Storage.
 .
 The goal is to create a well-behaved filesystem, allowing tools like find and
 rsync to work as expected. To enable certain Android apps to detect and use
 the transferred files, MTP file types are set automatically based on file
 contents using libmagic.

Package: mtpfs
Description-md5: 587c52dadb2cdcd42b55b3a80018a714
Description-en: FUSE filesystem for Media Transfer Protocol devices
 MTPfs is a FUSE filesystem that supports reading and writing from MTP (Media
 Transfer Protocol) devices, such as MP3 players, video players or digital
 cameras.
 .
 In addition to revealing media files on the connected device, MTPfs exposes a
 virtual directory called "/Playlists" which contains the device's playlists as
 m3u files.


mkdir /media/Mi-DOC

username=wiz

usermod -aG fuse $username

wiz@cb-DOC:~$ grep fuse /etc/group
fuse:x:103:wiz


wiz@cb-DOC:~$ mtpfs /media/Mi-DOC
Listing raw device(s)
Device 0 (VID=2717 and PID=0360) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
   Found 1 device(s):
   2717:0360 @ bus 2, dev 5
Attempting to connect device
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
Android device detected, assigning default bug flags
Listing File Information on Device with name: (NULL)

wiz@cb-DOC:~$ ls -ltd /media/Mi-DOC/
drwxrwxrwx 2 wiz wiz 0 Jan  1  1970 /media/Mi-DOC/

Now you can access your phone storage..

After you are done accessing your phone make sure you unmount the directory

fusermount -u /media/Mi-DOC

If not then you may face issues while trying to mount again..

wiz@cb-DOC:~$ mtpfs /media/Mi-DOC
Listing raw device(s)
Device 0 (VID=2717 and PID=0360) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
   Found 1 device(s):
   2717:0360 @ bus 2, dev 4
Attempting to connect device
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
Android device detected, assigning default bug flags
Listing File Information on Device with name: (NULL)
fuse: bad mount point `/media/Mi-DOC': Transport endpoint is not connected

This script can be found at https://github.com/rrskris/mtp-mount

Happy Mounting your Android :)

Saturday, September 6, 2014

Quiet day and Tumblerd thrashing my CPU




The user apps I had running was 1 web browser and 1 Thunar File manager program pointing to Downloads directory and I was calmly downloading some stuff over Torrent dumping into the Downloads directory..

So that's what the scenario was.. Pretty common sight eh?!

A cautious person that I am.. checked that my machine was experiencing lag my CPU topped and going off the charts and kept thrashing my cpu through the roof.
Strange behavior though..!

Now lets take a look at the load average and process list..

The running processes showed a process "tumblerd" was eating all my CPU and drying up resources..

root@cb-DOC:~# uptime
 11:43:39 up  2:16,  1 user,  load average: 79.62, 65.02, 46.63

 8903 wiz    20   0 10.4g 807m  10m S 369.2 14.3 148:20.57 tumblerd       

Now, It felt strange and I Looked up the application and noticed that tumblerd was a consequence of Thunar constantly trying to display the thumbnails of the content I was downloading and readjusting the thumbnails as more data got to append..So it basically does the thumbnail management,

Its implemented through D-Bus(main daemon) for various applications to request thumbnails.

root@cb-DOC:~# apt-file search tumblerd
tumbler: /usr/lib/x86_64-linux-gnu/tumbler-1/tumblerd


ii  tumbler                              0.1.25-1+b1             amd64                   D-Bus thumbnailing service

So the best bet was to get rid of this unresponsive process is to uninstall this buggy thunar file browser and use some other file browser if you are running xfce.

Went on to purge the tumbler
#apt-get purge tumbler on my Debian.

The following packages will be REMOVED:
  tumbler*
0 upgraded, 0 newly installed, 1 to remove and 97 not upgraded.
Purg tumbler [0.1.25-1+b1]

Here I found the shell script that checks for the application and kills if it starts to over utilize any of the resources..
https://bbs.archlinux.org/viewtopic.php?id=178881
and this too.. if you just want to remove it.. incase you are using Thunar on xfce https://forum.manjaro.org/index.php?topic=11746.0

This saved the day and reported the incident to thun and some notes for my blog..

HTH..

Monday, September 1, 2014

Reset IRC login password for freenode

How to reset the Password in 

/msg NickServ SENDPASS <username>

For more iformation use 

/msg NickServ SENDPASS help

NickServ: (notice) SENDPASS Email registration passwords.

 

Saturday, May 24, 2014

restart the wireless on acer 5745

root@cb-DOC:~# modprobe -r brcmsmac ; modprobe brcmsmac

root@cb-DOC:~# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 5c:ac:4c:b0:3f:4d
          inet addr:192.168.1.2  Bcast:192.168.1.15  Mask:255.255.255.240
          inet6 addr: fe80::5eac:4cff:feb0:3f4d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:242082 errors:0 dropped:0 overruns:0 frame:0
          TX packets:210420 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:272178906 (259.5 MiB)  TX bytes:36995927 (35.2 MiB)

mine is a subnetted network /28

root@cb-DOC:~# iwconfig
lo        no wireless extensions.

vmnet8    no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"Wiz@dmin"
          Mode:Managed  Frequency:2.417 GHz  Access Point: 4C:60:DE:D5:68:63
          Bit Rate=57.8 Mb/s   Tx-Power=19 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=44/70  Signal level=-66 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:748  Invalid misc:333   Missed beacon:0

eth0      no wireless extensions.

vmnet1    no wireless extensions.

For more information view the doc

root@cb-DOC:~# view /usr/share/doc/wireless-tools/README.Debian




Identify the program accessing a file on Linux

Make sure you check man page for fuser for more of the many switches which can be really handy..

wiz@cb-DOC:~$ man 1 fuser

Here we are just finding which program or thread is accessing a file, and it can be done as follows..

wiz@deb-DOC:~$ sudo fuser /var/log/syslog
/var/log/syslog:      3234 ---> pid of rsyslog (rsyslog since i'm running debian here)

and we also may use the lsof to do the same job and many more..

Make sure you check man page for lsof for many more switches which can be really handy..

wiz@cb-DOC:~$ man 8 lsof

wiz@deb-DOC:~$ lsof /var/log/syslog
wiz@deb-DOC:~$ sudo lsof /var/log/syslog
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
rsyslogd 3234 root    1w   REG    8,2    35170 7079847 /var/log/syslog

HTH

Webcam streaming on VLC Player

Hello.. Here is the Fun Stuff..

Using the vlc player to live stream the video capture from your webcam.. You can also use any other player like mplayer provided you have it installed..

Now, here is what you need to do..

Webcam streaming on VLC Player

wiz@cb-DOC:~/sudo apt-cache search v4l-conf
v4l-conf - tool to configure video4linux drivers

wiz@cb-DOC:~/Downloads$ vlc v4l://
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0xe0e108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.

wiz@cb-DOC:~/Downloads$ sudo apt-get install v4l-conf
[sudo] password for wiz:
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  v4l-conf
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst v4l-conf (3.102-3 Debian:7.3/stable [amd64])
Conf v4l-conf (3.102-3 Debian:7.3/stable [amd64])

wiz@cb-DOC:~/Downloads$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 0402:9665 ALi Corp. Gateway Webcam
Bus 002 Device 003: ID 0489:e011 Foxconn / Hon Hai

wiz@cb-DOC:~$ vlc v4l:// --> use the v4l protocol to watch the live stream off your webcam.
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x10b3108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.

Voila... you can now see your webcam in action.. Smile :)

more info:---> http://packages.debian.org/squeeze/libv4l-0

Install FTP client FileZilla on Debian

Lets go about installing filezilla, if you fancy a seamless drag and drop functionality connection from your GUI enabled host to your remote server. 

wiz@cb-DOC:~/.ssh$ sudo apt-cache search filezilla
[sudo] password for wiz:
filezilla - Full-featured graphical FTP/FTPS/SFTP client
filezilla-common - Architecture independent files for filezilla

wiz@cb-DOC:~/.ssh$ sudo apt-get install filezilla
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following extra packages will be installed:
  filezilla-common libtinyxml2.6.2
The following NEW packages will be installed:
  filezilla filezilla-common libtinyxml2.6.2
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,324 kB of archives.
After this operation, 11.3 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main libtinyxml2.6.2 amd64 2.6.2-1 [43.8 kB]
Get:2 http://http.debian.net/debian/ wheezy/main filezilla-common all 3.5.3-2 [3,015 kB]
Get:3 http://http.debian.net/debian/ wheezy/main filezilla amd64 3.5.3-2 [1,265 kB]
Fetched 4,324 kB in 34s (126 kB/s)                                        
Selecting previously unselected package libtinyxml2.6.2.
(Reading database ... 221226 files and directories currently installed.)
Unpacking libtinyxml2.6.2 (from .../libtinyxml2.6.2_2.6.2-1_amd64.deb) ...
Selecting previously unselected package filezilla-common.
Unpacking filezilla-common (from .../filezilla-common_3.5.3-2_all.deb) ...
Selecting previously unselected package filezilla.
Unpacking filezilla (from .../filezilla_3.5.3-2_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for menu ...
Processing triggers for desktop-file-utils ...
Setting up libtinyxml2.6.2 (2.6.2-1) ...
Setting up filezilla-common (3.5.3-2) ...
Setting up filezilla (3.5.3-2) ...
Processing triggers for menu ...

Wednesday, May 14, 2014

Lvm extend on Linux

Below is a flow of sequence 

[root@pc-DOC ~]# fdisk /dev/sda 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (39163-52216, default 39163): 
Using default value 39163
Last cylinder, +cylinders or +size{K,M,G} (39163-52216, default 52216): 
Using default value 52216

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 5 Extended

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): t
Partition number (1-5): 4
Hex code (type L to list codes): 8e
You cannot change a partition into an extended one or vice versa
Delete it first.

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 5 Extended

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 5 Extended

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): d
Partition number (1-5): 4

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 83 Linux

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)


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.

[root@pc-Doc ~]# ls /dev/sda
sda sda1 sda2 sda3 sda4 

Last login: Thu Jan 23 23:39:15 2014 from 10.253.11.14
[root@pc-Doc ~]# ls /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# ls /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# ls /dev/sda4
/dev/sda4
[root@pc-Doc ~]# pvdisplay 
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_pc-Doc
PV Size 99.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25474
Free PE 0
Allocated PE 25474
PV UUID 2kMDWt-8cjq-WJKd-ThqQ-rzLF-2CC2-UwnYID

--- Physical volume ---
PV Name /dev/sda3
VG Name vg_pc-Doc
PV Size 200.00 GiB / not usable 4.00 MiB
Allocatable yes 
PE Size 4.00 MiB
Total PE 51199
Free PE 321
Allocated PE 50878
PV UUID 8a2FHr-MHsf-x1vu-sbcg-iBX0-chWA-NE9f7X

[root@pc-Doc ~]# pvcreate -f /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# pvcreate -f /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# pvcreate -f /dev/sda4
Physical volume "/dev/sda4" successfully created
[root@pc-Doc ~]# pvdisplay 
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_pc-Doc
PV Size 99.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25474
Free PE 0
Allocated PE 25474
PV UUID 2kMDWt-8cjq-WJKd-ThqQ-rzLF-2CC2-UwnYID

--- Physical volume ---
PV Name /dev/sda3
VG Name vg_pc-Doc
PV Size 200.00 GiB / not usable 4.00 MiB
Allocatable yes 
PE Size 4.00 MiB
Total PE 51199
Free PE 321
Allocated PE 50878
PV UUID 8a2FHr-MHsf-x1vu-sbcg-iBX0-chWA-NE9f7X

"/dev/sda4" is a new physical volume of "99.99 GiB"
--- NEW Physical volume ---
PV Name /dev/sda4
VG Name 
PV Size 99.99 GiB
Allocatable NO
PE Size 0 
Total PE 0
Free PE 0
Allocated PE 0
PV UUID uuAtBs-gAVd-WHv0-7stJ-C3Ed-LVwK-HEc2zM

[root@pc-Doc ~]# vgdisplay 
--- Volume group ---
VG Name vg_pc-Doc
System ID 
Format lvm2
Metadata Areas 2
Metadata Sequence No 10
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 299.50 GiB
PE Size 4.00 MiB
Total PE 76673
Alloc PE / Size 76352 / 298.25 GiB
Free PE / Size 321 / 1.25 GiB
VG UUID AQ59Um-Lsse-N0xS-gfoc-cHCR-AL0r-1HSgia

[root@pc-Doc ~]# vgextend vg_pc-Doc /dev/sda4
Volume group "vg_pc-Doc" successfully extended
[root@pc-Doc ~]# vgdisplay 
--- Volume group ---
VG Name vg_pc-Doc
System ID 
Format lvm2
Metadata Areas 3
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 399.50 GiB
PE Size 4.00 MiB
Total PE 102271
Alloc PE / Size 76352 / 298.25 GiB
Free PE / Size 25919 / 101.25 GiB
VG UUID AQ59Um-Lsse-N0xS-gfoc-cHCR-AL0r-1HSgia

[root@pc-Doc ~]# lvdisplay 
--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_root
LV Name lv_root
VG Name vg_pc-Doc
LV UUID so0YcW-rveL-SDsI-ipVF-JhrR-eUG4-d9yB1g
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:26 -0500
LV Status available
# open 1
LV Size 290.20 GiB
Current LE 74290
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_swap
LV Name lv_swap
VG Name vg_pc-Doc
LV UUID hmD6Yj-m4qE-a422-rGLG-qk3l-TCdk-bOQnAk
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:47 -0500
LV Status available
# open 1
LV Size 8.05 GiB
Current LE 2062
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

[root@pc-Doc ~]# lvextend -L +100G /dev/vg_pc-Doc/lv_root
Extending logical volume lv_root to 390.20 GiB
Logical volume lv_root successfully resized
[root@pc-Doc ~]# lvdisplay 
--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_root
LV Name lv_root
VG Name vg_pc-Doc
LV UUID so0YcW-rveL-SDsI-ipVF-JhrR-eUG4-d9yB1g
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:26 -0500
LV Status available
# open 1
LV Size 390.20 GiB
Current LE 99890
Segments 4
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_swap
LV Name lv_swap
VG Name vg_pc-Doc
LV UUID hmD6Yj-m4qE-a422-rGLG-qk3l-TCdk-bOQnAk
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:47 -0500
LV Status available
# open 1
LV Size 8.05 GiB
Current LE 2062
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

[root@pc-Doc ~]# resize2fs /dev/vg_pc-Doc/lv_root^C
[root@pc-Doc ~]# df -hT /dev/vg_pc-Doc/lv_root
Filesystem Type Size Used Avail Use% Mounted on
- - 7.8G 172K 7.8G 1% /dev
[root@pc-Doc ~]# df -hT / 
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_pc-Doc-lv_root
ext4 286G 201G 71G 75% /
[root@pc-Doc ~]# resize2fs /dev/vg_pc-Doc/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_pc-Doc/lv_root is mounted on /; on-line resizing required
old desc_blocks = 19, new_desc_blocks = 25
Performing an on-line resize of /dev/vg_pc-Doc/lv_root to 102287360 (4k) blocks.
The filesystem on /dev/vg_pc-Doc/lv_root is now 102287360 blocks long.

[root@pc-Doc ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_pc-Doc-lv_root
ext4 385G 201G 164G 56% /
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 ext4 485M 64M 396M 14% /boot
[root@pc-Doc ~]#

Configure SFTP password-less asymmetric key exchange


Creating sftpusers group and adding users into this group

root@SFTP-Server:~# groupadd sftpusers
root@SFTP-Server:~# useradd -G sftpusers -d /home/sftpadmin/ -s /bin/false sftpadmin
root@SFTP-Server:~# chgrp -R sftpusers /home/sftpadmin
root@SFTP-Server:~# chown sftpadmin:sftpusers /home/sftpadmin
root@SFTP-Server:~# chown -R sftpadmin:sftpusers /home/sftpadmin/
root@SFTP-Server:~# chmod 750 /home/sftpadmin

Confirm it as follows:
root@SFTP-Server:~# ls -lhd /home/sftpadmin
drwxr-x--- 4 sftpadmin sftpusers 4.0K Jan 13 09:21 /home/sftpadmin

Now,Create a director .ssh and copy the public key to authorized_keys under the /home/sftpadmin/.ssh/

root@SFTP-Server:~# chmod 700 /home/sftpadmin/.ssh
root@SFTP-Server:~# chmod 600 /home/sftpadmin/.ssh/authorized_keys

Copy the public key to the SFTP-Server
root@SFTP-Server:~# cat /home/sftpadmin/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiy3mJTHkS74taR3spRkbZJhgz4CjSHKsMmPDPRA6cbA1Tkd3BEitAs7ofB7Tlv6+WlMXeuq1V9gy4muF9pSWJuEjzDreULD3mlbjY40jvrYXMZZHdOVfm9J93QcTJChfwmJe5gYyVwp5N2Hyt40f
Make sure there are no extra spaces at the end of the public key

Now execute the below command to complete the permissions
root@SFTP-Server:~# chown -R sftpadmin:sftpusers /home/sftpadmin/

Now change /etc/ssh/sshd_config and comment out sftp-server line and add a new line Subsystem sftp internal-sftp as follows:

root@SFTP-Server:~# vi /etc/ssh/sshd_config
# override default of no subsystems
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp

The configuration is now Done, Confirm by accessing from winscp be providing the private key

To cross verify, Within the /var/log/secure logs we should see the similar messages

Jan 13 01:56:59 cent59-02 sshd[6793]: Accepted publickey for sftpadmin from 172.22.101.217 port 1539 ssh2
Jan 13 01:56:59 cent59-02 sshd[6793]: pam_unix(sshd:session): session opened for user sftpadmin by (uid=0)


=============================

wiz@cb-DOC:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wiz/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wiz/.ssh/id_rsa.
Your public key has been saved in /home/wiz/.ssh/id_rsa.pub.
The key fingerprint is:
7f:0b:98:5b:5b:7c:c4:32:a0:c6:31:d7:78:5e:dd:68 wiz@cb-DOC
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|             o .o|
|          o + E +|
|         . ==. = o |
|        S +   + o|
|         o o . + |
|          == o o .|
|           = + . |
|          . o    |
+-----------------+
wiz@cb-DOC:~$


AAAAB3NzaC1yc2EAAAADAQABAAABAQDQazG6pBU5hBcuPsEg0kwXaCq2KiSdMbWT9HvEFFc8Leb3VbmwfZwSJv5SDd36Zm8x0a8BYnMYW/BZ9fO5z5WdK7lfKCtFLf93T1x3AuwPRk8zJKLJFD7AH7Hw/9IO2Q6fzFQTFnYIMETOpy+SZSCaXkdpGFdkXt3qFw5rXKfd02T2iaHtzhMSp/uevGqQsUmfQB50exgj+SZyzeupibqOaRwQGZGj55iRrsdIVETUXTFFvbiYAJWjD9Wi9KDXMR11XZtDwzYr37kHFl9MaxOx2ktl7avfMDE1scUOoFhtZod/DRI5b6AC9zR4BFvPPGBPoFf


ssh-copy-id -i .ssh/id_dsa.pub root@192.168.1.4
 1247  ssh root@192.168.1.4


root@ubuntu-v12:~# cat /home/sftpadmin/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQazG6pBU5hBcuPsEg0kwXaCq2KiSdMbWT9HvEFFc8Leb3VbmwfZwSJv5SDd36Zm8x0a8BYnMYW/BZ9fO5z5WdK7lfKCtFLf93T1x3AuwPRk8zJKLJFD7AH7Hw/9IO2Q6fzFQTFnYIMETOpy+SZSCaXkdpGFdkXt3qFw5rXKfd02T2iaHtzhMSp/uevGqQsUmfQB50exgj+SZyzeupibqOaRwQGZGj55iRrsdIVETUXTFFvbiYAJWjD9Wi9KDXMR11XZtDwzYr37kHFl9MaxOx2ktl7avfMDE1scUOoFhtZod/DRI5b6AC9zR4BFvPPGBPoFf
root@ubuntu-v12:~#

root@ubuntu-v12:~# ls -lthd  /home/sftpadmin/*
drwxr-x--- 3 sftpadmin sftpadmin 4.0K Jan 13 22:01 /home/sftpadmin/public
root@ubuntu-v12:~# ls -lthd  /home/sftpadmin/
drwxr-x--- 5 sftpadmin sftpusers 4.0K Jan 13 21:32 /home/sftpadmin/
root@ubuntu-v12:~# ls -lthd  /home/
drwxr-xr-x 4 root root 4.0K Jan 13 19:36 /home/

Note, the home folder for the new sftp user has to be given root owner.s

cat /etc/ssh/sshd_config
Subsystem sftp internal-sftp
UsePAM yes
Match Group sftpuser
        ChrootDirectory %h
        ForceCommand internal-sftp


wiz@ubuntu-v12:~$ grep sftpadmin /etc/passwd
sftpadmin:x:1001:1002::/home/sftpadmin/:/bin/false

view /var/log/auth.log
Jan 13 23:20:14 ubuntu-v12 sshd[6372]: Accepted publickey for sftpadmin from 192.168.1.2 port 58409 ssh2
Jan 13 23:20:14 ubuntu-v12 sshd[6372]: pam_unix(sshd:session): session opened for user sftpadmin by (uid=0)
Jan 13 23:20:15 ubuntu-v12 sshd[6514]: subsystem request for sftp by user sftpadmin
Jan 13 23:21:02 ubuntu-v12 sshd[6516]: Accepted password for wiz from 192.168.1.2 port 58410 ssh2
Jan 13 23:21:02 ubuntu-v12 sshd[6516]: pam_unix(sshd:session): session opened for user wiz by (uid=0)

apt-get update public key unavailable error

root@ubuntu1204:~# apt-get upgrade --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@ubuntu1204:~# apt-get update --simulate
Ign http://extras.ubuntu.com precise InRelease
Ign http://in.archive.ubuntu.com precise InRelease
Get:1 http://extras.ubuntu.com precise Release.gpg [72 B]
Hit http://in.archive.ubuntu.com precise Release.gpg
Hit http://in.archive.ubuntu.com precise Release
Hit http://extras.ubuntu.com precise Release
Ign http://extras.ubuntu.com precise Release
Hit http://in.archive.ubuntu.com precise/main Sources
Ign http://extras.ubuntu.com precise/main Sources/DiffIndex
Ign http://archive.canonical.com precise InRelease
Hit http://in.archive.ubuntu.com precise/restricted Sources
Ign http://extras.ubuntu.com precise/main i386 Packages/DiffIndex
Hit http://in.archive.ubuntu.com precise/universe Sources
Ign http://extras.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise/multiverse Sources
Hit http://extras.ubuntu.com precise/main Sources
Hit http://in.archive.ubuntu.com precise/main i386 Packages
Hit http://archive.canonical.com precise Release.gpg
Hit http://extras.ubuntu.com precise/main i386 Packages
Hit http://in.archive.ubuntu.com precise/restricted i386 Packages
Hit http://in.archive.ubuntu.com precise/universe i386 Packages
Hit http://in.archive.ubuntu.com precise/multiverse i386 Packages
Hit http://archive.canonical.com precise Release
Hit http://in.archive.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise/multiverse TranslationIndex
Hit http://in.archive.ubuntu.com precise/restricted TranslationIndex
Hit http://in.archive.ubuntu.com precise/universe TranslationIndex
Hit http://archive.canonical.com precise/partner Sources
Hit http://in.archive.ubuntu.com precise/main Translation-en
Hit http://in.archive.ubuntu.com precise/multiverse Translation-en
Ign http://extras.ubuntu.com precise/main Translation-en_US
Hit http://in.archive.ubuntu.com precise/restricted Translation-en
Hit http://archive.canonical.com precise/partner i386 Packages
Ign http://extras.ubuntu.com precise/main Translation-en
Hit http://in.archive.ubuntu.com precise/universe Translation-en
Ign http://archive.canonical.com precise/partner TranslationIndex
Ign http://archive.canonical.com precise/partner Translation-en_US
Ign http://archive.canonical.com precise/partner Translation-en
Fetched 72 B in 8s (8 B/s)
Reading package lists... Done
W: GPG error: http://extras.ubuntu.com precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

Now follow and execute the gpg commands by fetching the key from the ubuntu.

root@ubuntu1204:~# gpg --keyserver keyserver.ubuntu.com --recv 3E5C1192
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key 3E5C1192 from hkp server keyserver.ubuntu.com
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 3E5C1192: public key "Ubuntu Extras Archive Automatic Signing Key <ftpmaster@ubuntu.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
root@ubuntu1204:~# gpg --export --armor 3E5C1192 | apt-key add -
OK

Now do an update.. and we are fine.
root@ubuntu1204:~# apt-get update --simulate
Ign http://extras.ubuntu.com precise InRelease
Get:1 http://extras.ubuntu.com precise Release.gpg [72 B]
Ign http://in.archive.ubuntu.com precise InRelease
Hit http://extras.ubuntu.com precise Release
Ign http://archive.canonical.com precise InRelease
Hit http://extras.ubuntu.com precise/main Sources
Hit http://in.archive.ubuntu.com precise Release.gpg
Hit http://extras.ubuntu.com precise/main i386 Packages
Ign http://extras.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise Release
Hit http://archive.canonical.com precise Release.gpg
Hit http://in.archive.ubuntu.com precise/main Sources
Hit http://archive.canonical.com precise Release
Hit http://in.archive.ubuntu.com precise/restricted Sources
Hit http://archive.canonical.com precise/partner Sources
Hit http://in.archive.ubuntu.com precise/universe Sources
Ign http://extras.ubuntu.com precise/main Translation-en_US
Hit http://in.archive.ubuntu.com precise/multiverse Sources
Ign http://extras.ubuntu.com precise/main Translation-en
Hit http://archive.canonical.com precise/partner i386 Packages
Hit http://in.archive.ubuntu.com precise/main i386 Packages
Ign http://archive.canonical.com precise/partner TranslationIndex
Hit http://in.archive.ubuntu.com precise/restricted i386 Packages
Hit http://in.archive.ubuntu.com precise/universe i386 Packages
Hit http://in.archive.ubuntu.com precise/multiverse i386 Packages
Hit http://in.archive.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise/multiverse TranslationIndex
Hit http://in.archive.ubuntu.com precise/restricted TranslationIndex
Hit http://in.archive.ubuntu.com precise/universe TranslationIndex
Hit http://in.archive.ubuntu.com precise/main Translation-en
Hit http://in.archive.ubuntu.com precise/multiverse Translation-en
Hit http://in.archive.ubuntu.com precise/restricted Translation-en
Hit http://in.archive.ubuntu.com precise/universe Translation-en
Ign http://archive.canonical.com precise/partner Translation-en_US
Ign http://archive.canonical.com precise/partner Translation-en
Fetched 72 B in 7s (10 B/s)

HTH