Its high time we must bid bye-byes to cdrecord and growisofs...!
Until yesterday were were using the ISO9660 filesystem for burning the CDs and DVDs. But from now, its an oblivion.... welcome UDF.. Universal Disk Format..!
UDF lets us write datas incrementally to a mounted filessytem.
For this to work you should have the udftools package installed on your system, one blank cdrw, distribution of linux with a 2.6 kernel ( i tested in RHEL 5.0 ).
you can get the udftools package from here
here we goooooooo
Step 1:
Insert the blank cdrw into the drive and using the cdrwtool command which
we got from the udftools package, we are doing to blank the cdrw first..
Assuming your cd-burner is connected as secondary master..(/dev/hdc)
#cdrwtool -d /dev/hdc -t 4 -l 3 -q
( man cdrwtool )
this would blank the cdrw. Please be patient, it might take SOME time..!
Step 2:
We need to associate the blank formatted media with a packet device using the command pktsetup.
#pktsetup dragme /dev/hdc
Step 3:
Now we need to format the media with the udf filesystem,
#mkudffs --media-type=cdrw --udfrev=0x0150 /dev/pktcdvd/dragme
Step 4:
Now we need to make a mountpoint, let me give it as /drag-n-drop
#mkdir /drag-n-drop
#mount -t udf -o rw /dev/pktcdvd/dragme /drag-n-drop
#chmod 777 /drag-n-drop
(If you want local uses also to drag-n-drop something into it)
Now try some drag and dropping into that mountpoint
Now about the unmounting,
Its always safe to sync before unmouting,
So,
#sync
#umount /dev/pktcdvd/dragme
Then we can release the device /dev/pktcdvd/dragme from the packet device association.
#pktsetup -d /dev/pktcdvd/dragme
NOTE: Its always good to mount the packet device with noatime mount option if you want to ignore the number of rewrites in your media.
Now if you want to mount this media in other machine,
make a packet device with pktsetup and associate it with the device of your cd-drive
#pktsetup dragger /dev/hdd
This will map /dev/pktcdvd/dragger with /dev/hdd
Now you can mount the packet device and use it
#mount -t udf /dev/pktcdvd/dragger /mnt
~mj0vy
Monday, December 3, 2007
Wednesday, November 21, 2007
LOG ME IN....!
This article just illustrates the use of the expect command used for automatic logging to a remote machine
without using the complex ssh key pair exchange and all...!
Make sure you have the expect package installed in your machine...
lets try for telnet login...
make a file by name telnetme
$vi telnetme
#!/usr/bin/expect
eval spawn telnet 10.0.0.27
set timeout 30
expect login:
send " username\r"
expect password:
send " password\r"
interact
Now set execute permission to the script and copy it to any of the directories in your PATH variable
For SSH Login theres a little change...
I am here making a file by nane sshme
$vi sshme
#!/usr/bin/expect
eval spawn ssh 10.0.0.27
set timeout 30
expect password:
send " password\r"
interact
NOTE: change the italicised strings with appropriate username and password
It is recommended that you give read permission only to the user who is using this script , otherwise all users could read the plain password entered
PS: Please extend the features of expect if someone knows it...
without using the complex ssh key pair exchange and all...!
Make sure you have the expect package installed in your machine...
lets try for telnet login...
make a file by name telnetme
$vi telnetme
#!/usr/bin/expect
eval spawn telnet 10.0.0.27
set timeout 30
expect login:
send "
expect password:
send "
interact
Now set execute permission to the script and copy it to any of the directories in your PATH variable
For SSH Login theres a little change...
I am here making a file by nane sshme
$vi sshme
#!/usr/bin/expect
eval spawn ssh 10.0.0.27
set timeout 30
expect password:
send "
interact
NOTE: change the italicised strings with appropriate username and password
It is recommended that you give read permission only to the user who is using this script , otherwise all users could read the plain password entered
PS: Please extend the features of expect if someone knows it...
Friday, October 26, 2007
#mv cds DVD
Hollaaaaaaaa....
Yesterday i was trying to make a DVD out of my 5 RHEL 5.0 CDs. During the process i ended up losing my two plain DVD's.
But the most interesting thing is that i finally found the solution :). And i thought i must publish it cause i dont want
any other person to have the same difficulties i encountered.
alrights, lets get started...
I am creating a directory to copy all the RHEL 5.0 CDs
#mkdir /tmp/RHEL5_DVD
Loop mount the individual ISO images to any directory
#mount -o loop /path/to/iso1.iso /mnt
then copy the first CD contents to /tmp/RHEL5_DVD
#cd /mnt
#cp -r * /tmp/RHEL5_DVD
make sure you copied the .discinfo file also
#cp .discinfo /tmp/RHEL5_DVD
now unmount /mnt and mount the second iso.
#mount -o loop /path/to/iso2.iso /mnt
then copy all the rpm files inside /mnt/Server to /tmp/RHEL5_DVD/Server
#cp /mnt/Server/*.rpm /tmp/RHEL5_DVD/Server
we need to append the contents of the TRANS.TBL file found inside /mnt/Server to that inside /tmp/RHEL5_DVD/Server
#cat /mnt/Server/TRANS.TBL >> /tmp/RHEL5_DVD/Server/TRANS.TBL
NOTE:We are going to make a single TRANS.TBL file with all the TRANS.TBL files inside every isos.
Do the same thing for third, fourth and fifth iso files.
while copying the fifth iso file's contents, you should copy the rpm files under /mnt/VT/ to /tmp/RHEL5_DVD/VT
and append the TRANS.TBL file found under /mnt/Server/VT to /tmp/RHEL5_DVD/VT/TRANS.TBL
Now edit the .discinfo file inside the directory /tmp/RHEL5_DVD
to change the fourth line from 1 to 1,2,3,4,5
NOTE: If you miss any cd number, then installation would prompt you to insert that cd.
So you must include all the cd numbers correctly!
Now we must create the ISO image of the /tmp/RHEL5_DVD directory.
Free some 3 GB space in your HDD as the entire build would make an iso file of size
no less than 2.6 GB.
#cd /tmp/RHEL5_DVD
I assume you are creating the iso image inside /DVD directory.
#mkisofs -o /DVD/rhel5dvd.iso -b isolinux/isolinux.bin -c isolinux/boot.cat
-no-emul-boot -boot-load-size 4 -boot-info-table -J -r .
NOTE the . at the end of the previous command which specifies the current directory.
the -b flag to mkisofs command specifies the path and filename of the boot
image to be used when making the bootable iso.
the -c flag specifies the path and filename of the boot
catalog.
Now to burn the DVD, use the growisofs command.
#growisofs -dvd-compat -Z /dev/dvdwriter-hdc=/DVD/rhel5dvd.iso
NOTE: dd (disk duplicator) command can also be used to burn the iso image.
#dd if=/DVD/rhel5dvd.iso of=/dev/dvdwriter-hdc obs=32k seek=0
(plain DVDs and DVD burners are not that cheap here in my locality.. :D)
consult the man page of dd for more information.
make changes to the DVD device. I have plugged the DVD as secondary master in
my desktop PC.
the = sign used in the growisofs command finalized the DVD disc.
linuxly yours....
~mj0vy
Yesterday i was trying to make a DVD out of my 5 RHEL 5.0 CDs. During the process i ended up losing my two plain DVD's.
But the most interesting thing is that i finally found the solution :). And i thought i must publish it cause i dont want
any other person to have the same difficulties i encountered.
alrights, lets get started...
I am creating a directory to copy all the RHEL 5.0 CDs
#mkdir /tmp/RHEL5_DVD
Loop mount the individual ISO images to any directory
#mount -o loop /path/to/iso1.iso /mnt
then copy the first CD contents to /tmp/RHEL5_DVD
#cd /mnt
#cp -r * /tmp/RHEL5_DVD
make sure you copied the .discinfo file also
#cp .discinfo /tmp/RHEL5_DVD
now unmount /mnt and mount the second iso.
#mount -o loop /path/to/iso2.iso /mnt
then copy all the rpm files inside /mnt/Server to /tmp/RHEL5_DVD/Server
#cp /mnt/Server/*.rpm /tmp/RHEL5_DVD/Server
we need to append the contents of the TRANS.TBL file found inside /mnt/Server to that inside /tmp/RHEL5_DVD/Server
#cat /mnt/Server/TRANS.TBL >> /tmp/RHEL5_DVD/Server/TRANS.TBL
NOTE:We are going to make a single TRANS.TBL file with all the TRANS.TBL files inside every isos.
Do the same thing for third, fourth and fifth iso files.
while copying the fifth iso file's contents, you should copy the rpm files under /mnt/VT/ to /tmp/RHEL5_DVD/VT
and append the TRANS.TBL file found under /mnt/Server/VT to /tmp/RHEL5_DVD/VT/TRANS.TBL
Now edit the .discinfo file inside the directory /tmp/RHEL5_DVD
to change the fourth line from 1 to 1,2,3,4,5
NOTE: If you miss any cd number, then installation would prompt you to insert that cd.
So you must include all the cd numbers correctly!
Now we must create the ISO image of the /tmp/RHEL5_DVD directory.
Free some 3 GB space in your HDD as the entire build would make an iso file of size
no less than 2.6 GB.
#cd /tmp/RHEL5_DVD
I assume you are creating the iso image inside /DVD directory.
#mkisofs -o /DVD/rhel5dvd.iso -b isolinux/isolinux.bin -c isolinux/boot.cat
-no-emul-boot -boot-load-size 4 -boot-info-table -J -r .
NOTE the . at the end of the previous command which specifies the current directory.
the -b flag to mkisofs command specifies the path and filename of the boot
image to be used when making the bootable iso.
the -c flag specifies the path and filename of the boot
catalog.
Now to burn the DVD, use the growisofs command.
#growisofs -dvd-compat -Z /dev/dvdwriter-hdc=/DVD/rhel5dvd.iso
NOTE: dd (disk duplicator) command can also be used to burn the iso image.
#dd if=/DVD/rhel5dvd.iso of=/dev/dvdwriter-hdc obs=32k seek=0
(plain DVDs and DVD burners are not that cheap here in my locality.. :D)
consult the man page of dd for more information.
make changes to the DVD device. I have plugged the DVD as secondary master in
my desktop PC.
the = sign used in the growisofs command finalized the DVD disc.
linuxly yours....
~mj0vy
Sunday, September 9, 2007
Encrypted File Systems
The need to encrypt filesystems is to make ur data more secure and safe.
The whole steps include
1) Creating a partition with the fdisk utility ( pre-requisite :-( )
2) Selecting a cipher.
3) Setting up a loop device using the losetup command.
4) Detaching the loop back device
5) Mouting the parition
alright... lets get started..!
let me assume u have created the partition /dev/hda7
first of all we need to shred the partition
#shred -n 1 /dev/hda7
this command would overwrite /dev/hda7 only once!
-OR-
we can use the dd command to overwrite the device..
#dd if=/dev/urandom of=/dev/hda7 bs=1M
Now we need to select a cipher for the encyption
u can list the available ciphers by cat /proc/crypto
here i am using the serpent cipher
make sure u have got the serpent cipher modules inbuilt in ur kernel!
otherwise try
#modprobe serpent
#modprobe cryptoloop ( to setup the loop device described in the next step )
the next step is to setup a loop device using the losetup command.
#losetup -e serpent /dev/loop0 /dev/hda7
It prompts u for a passphrase. DONOT forget the passphrase as its not easy to change
the passphrase as it is hashed to create the encryption key.
Now create a filesystem on the loopback device and mount it.
#mke2fs -j /dev/loop0
#mkdir /cryptfs
#mount -t ext3 /dev/loop0 /cryptfs
once we have mounted the partition, we can then detach the
loop back device frm the partition.
#umount /cryptfs
#losetup -d /dev/loop0
Now mount the partition,
#mount -o encryption=serpent /dev/hda7 /cryptfs
the passphrase which we have given during the loop device setup will be asked
and u need to enter it correctly to mount the device.
The whole steps include
1) Creating a partition with the fdisk utility ( pre-requisite :-( )
2) Selecting a cipher.
3) Setting up a loop device using the losetup command.
4) Detaching the loop back device
5) Mouting the parition
alright... lets get started..!
let me assume u have created the partition /dev/hda7
first of all we need to shred the partition
#shred -n 1 /dev/hda7
this command would overwrite /dev/hda7 only once!
-OR-
we can use the dd command to overwrite the device..
#dd if=/dev/urandom of=/dev/hda7 bs=1M
Now we need to select a cipher for the encyption
u can list the available ciphers by cat /proc/crypto
here i am using the serpent cipher
make sure u have got the serpent cipher modules inbuilt in ur kernel!
otherwise try
#modprobe serpent
#modprobe cryptoloop ( to setup the loop device described in the next step )
the next step is to setup a loop device using the losetup command.
#losetup -e serpent /dev/loop0 /dev/hda7
It prompts u for a passphrase. DONOT forget the passphrase as its not easy to change
the passphrase as it is hashed to create the encryption key.
Now create a filesystem on the loopback device and mount it.
#mke2fs -j /dev/loop0
#mkdir /cryptfs
#mount -t ext3 /dev/loop0 /cryptfs
once we have mounted the partition, we can then detach the
loop back device frm the partition.
#umount /cryptfs
#losetup -d /dev/loop0
Now mount the partition,
#mount -o encryption=serpent /dev/hda7 /cryptfs
the passphrase which we have given during the loop device setup will be asked
and u need to enter it correctly to mount the device.
Saturday, September 8, 2007
COPY FROM LINUX TO M$ and vice-versa
SAMBA:
------
Samba acts as a fileserver for windows/linux using the SMB protocol
(Server Message Block), SMB is sometimes referred to as CIFS (Common Internet
File System).
Server Side:
------------
The directory to be shared from a linux server has to be given a sharename.
Clients access server's directory by referring to this sharename.
We can have user level access list and host level access list in samba.
Those users to whom server is granting access shuld be a unix server user
as well, and those users shuld be converted to samba users by giving them a
seperate samba password also. The samba users password database is located
inside /etc/samba directory in the name smbpasswd.
ie, /etc/samba/smbpasswd
Eg:
There is a directory in the server named /backups.
These directory needs to be shared to clients which use windows OS.
First of all we need to give /backups a sharename, by which the windows clients
access our /backups. Let it be UNIXBAKUP.
We are planning to give access to this share only for windows clients
192.168.0.3 and 192.168.0.2 only.
More over, they shuld be granted access if and only if they login as users
jack or jane.
Open the samba configuration file using an editor,
-------------------------------------
#vi /etc/samba/smb.conf
[UNIXBAKUP]
comment = Share for windows clients
path = /backups
valid users = jane jack
hosts allow = 192.168.0.3 192.168.0.2
writeable = yes
create mask = 0765
-------------------------------------
Now we need to add the allowed users
#useradd jane
#useradd jack
#passwd -l jack ; passwd -l jane
this is done to lock their unix password
Now we need to convert these unix users to samba users.
#smbpasswd -a jane
now u will be prompted for a password.
this step only adds the user to the samba password database.
we need to allow this user to use our samba server.
#smbpasswd -e jane
same way add the user jack also.
now we need to give permission to users jane and jack the write permission in
our share
#chmod 777 /backups
#/etc/init.d/smb start
#chkconfig smb on
to make our samba server persistent across reboots.
now we can test whether our samba configuration is correct or not with the
command testparm
#testparm
if any errors are there it will be reported.
--------------------------------------------
Client Side: (in 192.168.0.2 and 192.168.0.3)
------------
#smbclient //sambaserveraddress/sharename -U username
here
#smbclient //192.168.0.4/UNIXBAKUP -U jane/jack
enter the password
u will be put into a samba shell
smb: \>
now u are inside 192.168.0.4's /backups directory
frm here if u want to get some files, frm with in samba shell issue
smb: \>mget filename
file is now copied frm samba server to the client directory frm where we logged into the samba server.
instead if u want to put some files frm the folder where u logged into the
samba server, issue
smb: \>mput file-frm-the-client
smb: \>ls
you will be listed with the file u have just copied frm client to the
samba server.
Using GUI:
------------
Take run in KDE/Gnome and try
smb://sambaserverip
then u will be prompted for the samba username and password!
In M$ Windows u can access the Linux samba share by taking Start>Run and issuing
\\sambaserverip
upon opening any directory u will be asked the samba username and password...!
------
Samba acts as a fileserver for windows/linux using the SMB protocol
(Server Message Block), SMB is sometimes referred to as CIFS (Common Internet
File System).
Server Side:
------------
The directory to be shared from a linux server has to be given a sharename.
Clients access server's directory by referring to this sharename.
We can have user level access list and host level access list in samba.
Those users to whom server is granting access shuld be a unix server user
as well, and those users shuld be converted to samba users by giving them a
seperate samba password also. The samba users password database is located
inside /etc/samba directory in the name smbpasswd.
ie, /etc/samba/smbpasswd
Eg:
There is a directory in the server named /backups.
These directory needs to be shared to clients which use windows OS.
First of all we need to give /backups a sharename, by which the windows clients
access our /backups. Let it be UNIXBAKUP.
We are planning to give access to this share only for windows clients
192.168.0.3 and 192.168.0.2 only.
More over, they shuld be granted access if and only if they login as users
jack or jane.
Open the samba configuration file using an editor,
-------------------------------------
#vi /etc/samba/smb.conf
[UNIXBAKUP]
comment = Share for windows clients
path = /backups
valid users = jane jack
hosts allow = 192.168.0.3 192.168.0.2
writeable = yes
create mask = 0765
-------------------------------------
Now we need to add the allowed users
#useradd jane
#useradd jack
#passwd -l jack ; passwd -l jane
this is done to lock their unix password
Now we need to convert these unix users to samba users.
#smbpasswd -a jane
now u will be prompted for a password.
this step only adds the user to the samba password database.
we need to allow this user to use our samba server.
#smbpasswd -e jane
same way add the user jack also.
now we need to give permission to users jane and jack the write permission in
our share
#chmod 777 /backups
#/etc/init.d/smb start
#chkconfig smb on
to make our samba server persistent across reboots.
now we can test whether our samba configuration is correct or not with the
command testparm
#testparm
if any errors are there it will be reported.
--------------------------------------------
Client Side: (in 192.168.0.2 and 192.168.0.3)
------------
#smbclient //
here
#smbclient //192.168.0.4/UNIXBAKUP -U jane/jack
enter the password
u will be put into a samba shell
smb: \>
now u are inside 192.168.0.4's /backups directory
frm here if u want to get some files, frm with in samba shell issue
smb: \>mget filename
file is now copied frm samba server to the client directory frm where we logged into the samba server.
instead if u want to put some files frm the folder where u logged into the
samba server, issue
smb: \>mput
smb: \>ls
you will be listed with the file u have just copied frm client to the
samba server.
Using GUI:
------------
Take run in KDE/Gnome and try
smb://sambaserverip
then u will be prompted for the samba username and password!
In M$ Windows u can access the Linux samba share by taking Start>Run and issuing
\\sambaserverip
upon opening any directory u will be asked the samba username and password...!
Manage Logical Volumes
LVM Creation:
-------------
Create a linux partition, make it a LVM by toggling the linux partitions id to
8e.
Convert it to a physical volume by issuing the command
#pvcreate devicename
Then, make the volume group in that physical volume,
#vgcreate vgname devicename
Then make logical volumes in the volume group,
#lvcreate -L sizeM -n lvname vgname
Make a linux filesystem in the logical volume,
#mkfs.ext3 /dev/vgname/lvname
This device is a softlink to the device /dev/mapper/vgname-lvname
Then mount that logical volume,
#mount /dev/vgname/lvname
LVM Resizing:
-------------
LVM format 2.0 is now implemented which supports online resizing of filesystems.
check the current size of the filesystem by 'df -h'
Extend the above created logical volume BY X MB,
#lvextend -L +XM /dev/vgname/lvname
we are doing it without unmounting the filesystem
Now to make the extension effective, issue
#resize2fs /dev/vgname/lvname
now recheck the filesystem size by 'df -h',
now the filesystem will be extended by X MB.
Now if u want to reduce the logical volume TO X MB,
u must first umount the device, online reducing of logical volumes cannot be done..!
#umount
then u need to scan the filesystem for integrity.
#e2fsck -f /dev/vgname/lvname
now resize the filesystem
#resize2fs /dev/vgname/lvname X MB
then reduce the volume with lvreduce and mount it..
#lvreduce -L XM /dev/vgname/lvname
#mount /dev/vgname/lvname
-------------
Create a linux partition, make it a LVM by toggling the linux partitions id to
8e.
Convert it to a physical volume by issuing the command
#pvcreate devicename
Then, make the volume group in that physical volume,
#vgcreate vgname
Then make logical volumes in the volume group,
#lvcreate -L size
Make a linux filesystem in the logical volume,
#mkfs.ext3 /dev/
This device is a softlink to the device /dev/mapper/vgname-lvname
Then mount that logical volume,
#mount /dev/
LVM Resizing:
-------------
LVM format 2.0 is now implemented which supports online resizing of filesystems.
check the current size of the filesystem by 'df -h'
Extend the above created logical volume BY X MB,
#lvextend -L +XM /dev/
we are doing it without unmounting the filesystem
Now to make the extension effective, issue
#resize2fs /dev/
now recheck the filesystem size by 'df -h',
now the filesystem will be extended by X MB.
Now if u want to reduce the logical volume TO X MB,
u must first umount the device, online reducing of logical volumes cannot be done..!
#umount
then u need to scan the filesystem for integrity.
#e2fsck -f /dev/vgname
now resize the filesystem
#resize2fs /dev/vgname
then reduce the volume with lvreduce and mount it..
#lvreduce -L XM /dev/vgname
#mount /dev/vgname
Wednesday, September 5, 2007
init-->xinetd
this is how we can convert the init based service ftp to an xinetd service..
1) First of all we need to make FTP not to listen on port 21 by making 'listen=NO' in
/etc/vsftpd/vsftpd.conf.
2) Then, make a file named ftp inside /etc/xinetd.d
the contents of /etc/xinetd.d/ftp should look like this
service ftp
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/sbin/vsftpd
server_args = /etc/vsftpd/vsftpd.conf
nice = 10
flags = IPv4
}
3) then restart the xinetd service by
#/etc/init.d/xinetd restart
#chkconfig xinetd on
now if u 'nmap localhost', u can see that the port 21 is now open...!
1) First of all we need to make FTP not to listen on port 21 by making 'listen=NO' in
/etc/vsftpd/vsftpd.conf.
2) Then, make a file named ftp inside /etc/xinetd.d
the contents of /etc/xinetd.d/ftp should look like this
service ftp
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/sbin/vsftpd
server_args = /etc/vsftpd/vsftpd.conf
nice = 10
flags = IPv4
}
3) then restart the xinetd service by
#/etc/init.d/xinetd restart
#chkconfig xinetd on
now if u 'nmap localhost', u can see that the port 21 is now open...!
Subscribe to:
Posts (Atom)