The every day things from Thalamus' life.

Thalamus' Blog

28 June, 2011

LVM and adding more disk

Filed under: ComputerStuff_en — Thalamus @ 01:27

Very short writeup.

On my laptop I descided NOT to use the whole disk during install, and instead add the last amount of GB later on – in order to teach myself how to use LVM.

In this example we have only one disk ‘sda’ – adding it to a already existing volum group named ‘vgn0’. I only had 2 logical logical volumes named ‘lvn_root’ and ‘lvn_swap’.

If for some reason you’re not sure what you have on your system, you can issue

# vgdisplay

  --- Volume group ---
  VG Name               vgn0
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               29.28 GiB
  PE Size               32.00 MiB
  Total PE              937
  Alloc PE / Size       937 / 29.28 GiB
  Free  PE / Size       0 / 0   
  VG UUID               FrlqQi-gSJM-aknK-iG53-vx3m-32XM-IRIPHo

and

# lvdisplay

  --- Logical volume ---
  LV Name                /dev/vgn0/lvn_root
  VG Name                vgn0
  LV UUID                aAWPof-PdPH-2odn-aWBN-3GOL-7un9-DmaGKO
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                26.34 GiB
  Current LE             843
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
 
  --- Logical volume ---
  LV Name                /dev/vgn0/lvn_swap
  VG Name                vgn0
  LV UUID                LMeJ5T-ZZIG-4evD-cwlX-MIJg-eSXw-FAYd4b
  LV Write Access        read/write
  LV Status              available
  # open                 2
  LV Size                2.94 GiB
  Current LE             94
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

I examined the internal layout by issuing.

# parted -l /dev/sda

Model: ATA INTEL SSDSA2MH16 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
 
Number  Start   End     Size    Type      File system  Flags
 1      1049kB  106MB   105MB   primary   ntfs
 2      106MB   86.6GB  86.5GB  primary   ntfs         boot
 3      86.6GB  118GB   31.5GB  primary                lvm
 4      118GB   160GB   41.9GB  extended
 5      118GB   118GB   262MB   logical   ext4
 
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/vgn0-lvn_swap: 3154MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
 
Number  Start  End     Size    File system     Flags
 1      0.00B  3154MB  3154MB  linux-swap(v1)
 
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/vgn0-lvn_root: 28.3GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
 
Number  Start  End     Size    File system  Flags
 1      0.00B  28.3GB  28.3GB  ext4

My laptop is used as a dual boot – Wiin7 / Fedora15. So the first 2 partitions is the system and os disks of Win7. The 3rd is the / (and swap) of my Fedora – the 4th is an extended partition with some free space that I’m going to use. The 5th partition is a small /boot partition.

So, next step. I created a new partition on the disk – type 8e (LVM).
Then added physical extents that LVM need issuing.

# pvcreate /dev/sda6

Last verify …

# vgdisplay vgn0

Added new partition to volum group.

# vgextend vgn0 /dev/sda6

Last verify …

# lvdisplay /dev/vgn0/lvn_root

Added 10G of the new partition to the volum group – if this partition isn’t a member of the volum group or there is not enough space avail on the partition, the command will fail. In this case it didn’t.

# lvextend -L +10G /dev/vgn0/lvn_root

Now – last part, resize my ext4 filesystem – growing it by 10G. Using ‘-p’ to show me a progress bar.

# resize2fs -p /dev/vgn0/lvn_root

…. success !

After this – I had a look around and found a nice article that explained how to reduce the swap partition and add it to … in my case /dev/vgn0/lvn_root.

http://www.how2centos.com/centos-lvm-resizing-guide/

Now, my / partition is (compare it to the previous listing above)

  --- Logical volume ---
  LV Name                /dev/vgn0/lvn_root
  VG Name                vgn0
  LV UUID                aAWPof-PdPH-2odn-aWBN-3GOL-7un9-DmaGKO
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                28.34 GiB
  Current LE             907
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

– grown by 2 GB, swap shrinked by same amount – success story # 2 🙂

• • •
 

21 June, 2011

No access to console – but need those messages ?

Filed under: ComputerStuff_en — Thalamus @ 07:44

Might be you find it if you do a ….

# cat /dev/vcs

… its a raw output – this could help.

# cat /dev/vcs1 | perl -e 'while(<>) { $fix = $_; $fix =~s /\s{80,}/\n/g; print $fix }' | less

Why perl ? – just to illustrate that it is possible – a better choice is sed

# cat /dev/vcs1 | sed 's/\s*{80,}/\n/g' | less
• • •
 

19 June, 2011

cifs mounting with systemd on Fedora 15

Filed under: ComputerStuff_en — Thalamus @ 04:12

Please note: Although this method seems to work – it seems not to be perfect yet. When I booted the machine for the frist time after implementation – it looked like I was trying to dismount after the network was teared down. It might be that it would be better to install autofs and use that instead of systemctl.automount. Have to revisit this some day.

I wrote a blog some months ago about doing automount of some cifs shares in my home network. Today I descided that I wanted to setup the same rules, but by using the new systemd instead.

Systemd needs 2 files for this. One *.automount and one *.mount – these files need to have names that refer to the mount location. Eg. mounting a host named ‘nmt’ with a share named ‘share’ to the mountpoint ‘/cifs/nmt’. I would have to create one file ‘cifs-nmt.automount’ and one file ‘cifs-nmt.mount’. Both are to be placed in /lib/systemd/system

cifs-nmt.automount

[Unit]
Description=CIFS Directory Automount Point
Wants=network.target
After=network.target
 
[Automount]
Where=/cifs/nmt
 
[Install]
WantedBy=multi-user.target

cifs-nmt.mount

[Unit]
Description=Data Directory
Wants=network.target
After=network.target
 
[Mount]
What=//nmt/share
Where=/cifs/nmt
Type=cifs
Options=credentials=/root/.cifs-nmt.credentials,rw,iocharset=utf8,uid=500,gid=500,_netdev

Of course – change the uid/gid according to your system. And – create the credentials file refererd to … like this

username=someuser
password=somepassword

After this was done – I ran :

# systemctl --system daemon-reload
# systemctl enable cifs-nmt.automount
# systemctl restart cifs-nmt.automount

That was all that was required … 🙂

• • •
 

16 June, 2011

Gi Java mer enn 2 GB minne.

Filed under: Dagbok_no — Thalamus @ 12:44

Om vi skal tildele over 2 GB minne for java – trenger vi å tune linux kjernen noe.
La oss gå ut ifra at vi har 8 GB og ønsker å tildele 6 for Java. Vi snakker her altså om 64 bits versjon av linux – ikke 32 !

Shared memory – la oss sette denne til 6 GB.

# bc
(1024*1024*1024)*6
6442450944

Editer /etc/sysctrl.conf

kernel.shmmax = 6442450944

Hugepages – la oss sette av 5 av disse 6.

# cat /proc/meminfo | grep Hugepagesize
# Hugepagesize:       2048 kB

…. eller, 2 MB

# bc
(1024*1024*1024*5)/(1024*1024*2)
2560

Denne går også inn i /etc/sysctl.conf

vm.nr_hugepages = 2560

Lag gruppe eller finn gruppe ID til brukeren som skal kjøre java prosessen.
Eks.

# grep java /etc/group
java:x:1000:

Denne legger vi til :

vm.hugetlb_shm_group = 1000

… igjen – sysctl.conf

Ett siste sted – for å tillate denne brukeren tilgang – editer /etc/security/limits.conf

jboss soft memlock 2560
jboss hard memlock 2560

….. all set and done !

• • •
 

3 June, 2011

Finding an ISP ip address range.

Filed under: ComputerStuff_en — Thalamus @ 14:31

I started wondering how one can find an ISPs assigned address ranges. And since I knew that on the Internet – the BGP (Border Gateway Protocol) is the main routing protocol I … wondered if there where anyone out there that had a solution for me.

I think this guy has the solution I needed. Just use a whois on the ip address in question – find the AS number from there and use Dan’s tool. Thanks Dan !

https://www.dan.me.uk/bgplookup

• • •