Showing posts with label linux-training. Show all posts
Showing posts with label linux-training. Show all posts

2012-04-07

vi tutorial

Here is a link to the slides (or use this link if you have no access) of this LOAD vi tutorial. They are based on these linux-training.be html pages.

2011-11-08

iSCSI mini howto

Some things in life, like iSCSI, are simple!
iSCSI is a protocol that allows you to have SCSI over IP.

The iSCSI Target

The host containing the physical hardware is called the iSCSI target and is easy to setup on Linux using iscsitarget.
aptitude install iscsitarget
aptitude install iscsitarget-dkms (Debian 6)

After enabling it in /etc/default/iscsitarget you can use files, hd devices, partitions, lvm volumes or software raid mdadm devices as 'physical hardware disks'
root@debby6:/etc/iet# cat ietd.conf
Target iqn.2010-02.be.linux-training:storage.lun1
IncomingUser isuser hunter2
OutgoingUser
Lun 0 Path=/iscsi/lun1.img,Type=fileio
Alias LUN1

Where /iscsi/lun1.img is a zeroed file created with
dd if=/dev/zero of=/iscsi/lun1.img count= bs=

Add the device to the allowed list:
root@debby6:/etc/iet# cat initiators.allow
iqn.2010-02.be.linux-training:storage.lun1

and start the server. You should see this:
root@debby6:/etc/iet# cat /proc/net/iet/session
tid:1 name:iqn.2010-02.be.linux-training:storage.lun1
The iSCSI Initiator

The host that connects to this target server is called the Initiator. Most Linux distros have this available as open-iscsi.
aptitude install open-iscsi

A discovery will show available devices on the target:
root@ubu1104:/etc/iscsi# iscsiadm -m discovery -t st -p debby6
192.168.1.31:3260,1 iqn.2010-02.be.linux-training:storage.lun2

Configuration with chap user and password takes a couple of commands:
root@ubu1104:/etc/iscsi# iscsiadm -m node --targetname "iqn.2010-02.be.linux-training:storage.lun1" --portal "debby6:3260" --op=update --name node.session.auth.authmethod --value=CHAP
root@ubu1104:/etc/iscsi# iscsiadm -m node --targetname "iqn.2010-02.be.linux-training:storage.lun1" --portal "debby6:3260" --op=update --name node.session.auth.username --value=isuser
root@ubu1104:/etc/iscsi# iscsiadm -m node --targetname "iqn.2010-02.be.linux-training:storage.lun1" --portal "debby6:3260" --op=update --name node.session.auth.password --value=hunter2

That's it! Now (re)start the open-iscsi service and use fdisk to see your iSCSI device.

2011-04-16

loadays talk

Some people convinced me to do a talk^Wtutorial tomorrow at loadays. It will be about bash!

Maybe I will use some slides from this downloadable pdf (50KB).

Content will come from the linux-training.be project (but that website stalled since February due to a redesign of our build-system). People that go to loadays can download the newest (1MB) pdf here.

LOAD, the Linux system administrator days

2010-11-07

svg with inkscape

Inkscape is an easy (and free) tool to create scalable vector graphics. It is much fun using it, it is even more fun sharing the results.

Two routers connect two LAN's


DNS lookup behind adsl-router


TCP handshake example
More of them can be found here : http://www.linux-training.be/svg/

2010-04-12

Linux processes

Finally got around to reworking the processes chapter (viewable in html now). Still need to add a section about screen and rework the labs for this chapter...

2010-03-25

Why use (hard) links ?

Dear lazyweb,

When explaining inodes, directories and hard links, students regularly ask "Why would you (ever) use hard links ?".

I usually reply with three obvious reasons:
1. To never have a file twice on your system (and thus save disk space).
(they need to know that deleting files with hard links doesn't add free space)
2. For compatibility with legacy applications that use old file locations (without the need to rewrite those applications).
3. Because Linux programs know how they are called, mke2fs, mkfs.ext2 and mkfs.ext3 can be the same file, but with distinct functionality.

Sometimes these arguments fail to convince students of the usefulness of hard links. What would you say ?

2009-11-14

teaching Linux System Administration

Yes it has been a long time since the last blogpost. Yes linux-training.be needs a lot of updates. But it has been a busy couple of months ;-)

Here's a picture of three happy students who were very eager to learn about system administration (and fundamentals). They kept me teaching from nine till six!

2009-08-04

Linux Software RAID and LVM

Wouter configured my nas with two raid1 setups and two lvm partitions like this:

md0 = sdb1 + sdd1
md1 = sda1 + sdc1

/ mounted on wolf/root on md1
swap mounted on wolf/swap on md0

What I wanted was raid5 with four disks, but without rebooting (and possibly bricking) the intel SS4000. Like this:

md0 = sda1 + sdb1 + sdc1 + sdd1
/ mounted on wolf/root on md0

Step 1: remove the swap partition:

swapoff /dev/wolf/swap
vi /etc/fstab
lvremove wolf/swap

Step 2: remove md0 from lvm and stop the raid1

vgreduce wolf /dev/md0
pvremove /dev/md0
mdadm --stop /dev/md0

Step 3: remove one disk from the remaining raid1

mdadm /dev/md1 --fail /dev/sdb1
mdadm /dev/md1 --remove /dev/sdb1

Step 4: build a degraded raid5 with four disks

mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 missing


Step 5: add the raid5 to lvm and move the root partition to it

pvcreate /dev/md0
vgextend wolf /dev/md0
pvmove -v /dev/md1 /dev/md0

Step 6: remove and stop md1

vgreduce wolf /dev/md1
pvremove /dev/md1
mdadm --stop /dev/md1

Step 7: complete the raid5 and update initrd

mdadm /dev/md0 --add /dev/sdd1
update-initramfs -k $(uname -r) -u

2009-05-27

Linux Training updates

Linux Training got a lot of updates the past two weeks (thank you financial crisis for giving me time).

Added an introduction to mysql (chapter 31 in LinuxTraining.pdf). (Can someone with mysql knowledge please review this ?)

Finally updated init and booting, they are two chapters now. Booting is chapter 17, init is chapter 18. The practices for these chapters are not done yet, and lilo could use a bit more info.

Notes to self:
- chapter 13 (more about bash) is dreadful, high priority!
- idem ditto for 22.scheduling and 24.memory management

By the way, there is really no point in putting old copies of this book online (like on scribd). The latest complete version can always be downloaded at www.linux-training.be.

2009-05-19

Where is /proc/bus/usb/devices ?

/proc/bus/usb/devices is still mentioned in the manpage of lsusb, but not existing on my current Ubuntu (2.6.24) and RHEL5 (2.6.18) system.

root@laika:~# ls -al /proc/bus/usb/
total 0
dr-xr-xr-x 2 root root 0 2009-05-19 14:24 .
dr-xr-xr-x 6 root root 0 2009-05-19 10:15 ..
root@laika:~#

The /proc/bus/usb/ structure is however present on Debian (2.6.17), including the devices file.

Where does the lsusb command go to get usb device information ? Is it not reading /proc/bus/usb ? Is this a kernel change in 2.6.18 ?

2009-03-03

macro in vim question...

I can create a simple macro in vi(m) to add the letter b at the end of every line:

q b $ a b Esc j q

q start recording macro
b name the macro
$ jump to end of current line
a append
b the letter b
Esc back to command mode
j one line down
q end recording

When I have a text file, and I execute 20@b, then the letter b is added to 20 lines.

When there are less than 20 lines, then I would expect this macro to add multiple b's to the end of the last line. But it does not. When you type the commands in the macro yourself, then it does add multiple b's.

How can you explain this behaviour ?
Is there an easier way to add a b to every line (in vim) ?

2009-01-27

Samba 4 now works with GPO's

One of my students this week asked about using a Samba 4 Active Directory domain with GPO's to manage the Windows XP clients. Samba 4 alpha 6 impressed me! The download comes with a small howto.txt to setup your kerberos realm and to integrate the SRV records in DNS (a chrooted bind 9.3.4). Adding users is explained, joining Windows computers works flawlessly.

Last time, Samba 4 was unable to operate Group Policies, now I tested a few, and they work! The screenshot below is no proof, but I get a kick out of it ;-)

In this screenshot, you see a fully patched Windows 2003 server in a Samba 4 domain, in its own OU, together with the user 'brel', having applied the GPO setting "remove Search from Start Menu".

The future is free!

2008-12-08

Linux Training

This weekend "chapter 17: the Linux kernel" of my Linux training pdf was reworked. It should contain the essentials about Linux kernel module management and Linux kernel compilation.

The rest will be for later (na mijn twee examens Spaans 16-18 december).

2008-11-16

Linux Training

Made a little time today to work on my Linux course. Almost all corrections from reviewers are integrated (as a stack). Some of those corrections require me to learn a bit more ;-)

I've been teaching the Linux Fundamentals four times since September and (partly) integrated my experience in the course to make the pace flow nicer between theory, demo's and practices.

The thing is, I spent most of today (again) on the "first steps" chapter (pwd, cd, ...). I must not touch it again, unless for typo's! Other chapters require more urgent attention:
- I need to rewrite the two bash chapters, the first one is too long (imho it should be split in two separate chapters), the last one is way too brief.
- I also think the File System Hierarchy chapter is too long (too much theory compared to the humble practice)
- Processes is kinda complete, but the order and layout can improve (same for vi)
- Scripting is incomplete and also needs some order.
- The first chapter (introduction) is a mess. Luckily i teach it better than it is written.

The System Administration course is in even worse shape. I'm really not happy about it. Okay, maybe the hard disk and LVM chapters are good enough, but kernel compile is really lousy. (I have completely rewritten the kernel compile chapter, but only in my mind, not yet on paper.)

Anyway, thank you all for encouraging me and telling me it is a good book. No, this is not a plea for more pats on the back, just look at this post as my todo-list.

I hope to have updated the bash chapters and the kernel compile chapter RSN.

2008-09-20

Linux Training : About NAT

I created a humble little chapter that serves as an introduction to iptables today. Also corrected minor errors in the router chapter. Both chapters are available online (12 page pdf) for your review.

The goal is to provide students (that have knowledge about sniffing, tcp, ip, arp, icmp,...) a practical introduction to setting up a router, packet filter, nat, snat and dnat on Linux with iptables.


10. Routers
10.1. terminology
10.1.1. router or firewall
10.1.2. packet forwarding
10.1.3. packet filtering
10.1.4. NAT (network address translation)
10.1.5. PAT (port address translation)
10.1.6. SNAT (source network address translation)
10.1.7. masquerading
10.1.8. port forwarding
10.2. packet forwarding
10.2.1. about packet forwarding
10.2.2. /proc/sys/net/ipv4/ip_forward
10.2.3. /etc/sysctl.conf
10.2.4. Practice: packet forwarding
10.2.5. Solution: packet forwarding
11. Iptables
11.1. about iptables
11.2. packet filtering
11.2.1. about packet filtering
11.2.2. filter table
11.2.3. Changing default policy rules
11.2.4. Allowing ssh over eth0
11.2.5. Allowing access from a subnet
11.2.6. iptables save
11.2.7. scripting example
11.2.8. Allowing ICMP(ping)
11.2.9. Practice: packet filtering
11.3. network address translation
11.3.1. about NAT
11.3.2. SNAT (Source NAT)
11.3.3. SNAT example setup
11.3.4. IP masquerading
11.3.5. DNAT (Destination NAT)

Linux Training : About routers

I made a draft chapter about router terminology and setting up Linux for packet forwarding.

Please review it (five pages pdf). The students already have an understanding of tcp/ip, arp. mac, addressing and ports, ...
The next chapter is about iptables (port forwarding, nat, ...)

Thanks again for all the corrections on Linux Fundamentals, i will update it soon.