Your Ad Here

Tuesday, March 30, 2010

How can I create a disk partition on a disk that is greater than 2TB in size?

  • The fdisk command only supports the legacy MBR partition table format (also known as msdos partition table)
    • MBR partition table do not support disks greater than 2.1TB, and therefore fdisk is also unable to create partition tables on these devices.
    • Note that some older versions of fdisk may permit a larger size to be created but the resulting partition table will be invalid.
  • The parted command can create disk labels using MBR (msdos), GUID Partition Table (GPT), SUN disk labels and many more types.
    • The GPT disk label overcomes many of the limitations of the DOS MBR including restrictions on the size of the disk, the size of any one partition and the overall number of partitions.
    • Note that booting from a GPT labelled volume requires firmware support and this is not commonly available on non-EFI platforms (including x86 and x86_64 architectures).

    Procedure:
  • Use the parted tool to access the partition table of the device:
    # parted /dev/sdj
    Using /dev/sdj
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted)
    
    
  • Once at the parted prompt, create a GPT label on the disk:
    (parted) mklabel
    Warning: The existing disk label on /dev/sdj will be destroyed and all data on this disk will be lost. Do you want to continue?
    Yes/No? Yes                                                                 
    New disk label type?  [gpt]? gpt                                          
    (parted)
    Note: This will remove any existing partition table and partitions on the device.
  • Use the print command to show the size of the disk as reported by parted.  We need this later:
    (parted) print                                                            
    
    Model: Linux device-mapper (dm)
    Disk /dev/sdj: 5662310.4MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start  End  Size  File system  Name  Flags
    
    
  • Create a primary partition on the device.  In this example, the partition will encompass the entire disk (using size from the step above):
    (parted) mkpart primary 0 5662310.4MB
    
    
  • Unlike fdisk, you do not have to write out the partition table changes with parted.  Display your new partition and quit.
    (parted) print
    
    Model: Linux device-mapper (dm)
    Disk /dev/mapper/VolGroup00-gpttest: 5662310.4MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End          Size         File system  Name     Flags
     1      17.4kB  5662310.4MB  5662310.4MB               primary       
    
    (parted) quit                                                             
    Information: Don't forget to update /etc/fstab, if necessary.
    
    
  • You can now create a filesystem on the device /dev/sdj1

Monday, March 29, 2010

How to spoof a MAC address?


MAC address filtering for wireless networking isn’t real “security”. Anyone who pays any attention to current trends in wireless security at all should know that MAC filtering is less effective than WEP — and that WEP can be cracked almost instantly these days with commonly available tools.

This doesn’t mean MAC filtering is useless. Its resource consumption is almost unmeasurable, and even if it doesn’t keep out any reasonably knowledgeable security crackers willing to spend a few moments gaining access, it does keep out a lot of automated opportunistic attacks that are aiming solely for the absolute lowest-hanging fruit on the security tree. Since that lowest-hanging fruit consists of the majority of wireless access points, MAC filtering can be of value as a way of turning away the majority of opportunistic attackers.

Don’t rely on MAC filtering alone, however. Please, just don’t. It’s a bad idea. People seem to think “Oh, well, sure a determined attacker can get past it, but not anyone else.” It doesn’t take much determination at all to spoof a MAC address. In fact, I’ll tell you how:

1.“Listen” in on network traffic. Pick out the MAC address. This can be done with a plethora of freely available security tools, including Nmap.

2.Change your MAC address.
You can spoof a MAC address when using Nmap with nothing more than a –spoof-mac command line option for Nmap itself to hide the true source of Nmap probes. If you give it a MAC address argument of “0″, it will even generate a random MAC address for you.

For more general MAC address spoofing, your MAC address is trivially reset with tools available in default installs of most operating systems. Here are some examples:

Linux: ifconfig eth0 hw ether 03:a0:04:d3:00:11
FreeBSD: ifconfig bge0 link 03:a0:04:d3:00:11
MS Windows: On Microsoft Windows systems, the MAC address is stored in a registry key. The location of that key varies from one MS Windows version to the next, but find that and you can just edit it yourself. There are, of course, numerous free utilities you can download to make this change for you as well (such as Macshift for MS Windows XP).

All of these techniques can of course be automated by self-propagating malware, and the creation of the malware can even be automated to some extent by existing malware creation “kits”. If that doesn’t convince you that MAC filtering does not provide real security, I don’t know what will.

Tuesday, March 9, 2010

View Config Files Without Comments

I've been using this grep invocation to trim comments out of config files.Comments are useful, but when you want to just get the active configuration entries alone from a long file ( may be of 1000 lines where the config entries will be around 50 lines only ), use the below technique.

$ grep ^[^#] /etc/httpd/conf/httpd.conf

The regex ^[^#] matches the first character of any line, as long as that character that is not a #. Because blank lines don't have a first character they're not matched either, resulting in a nice compact output of just the active configuration lines.

Monday, March 8, 2010

Setup Your Linux Server to Use a Serial Console

Do you have a linux server without a keyboard or monitor? Need to administer the server on-site but don't want to lug over a monitor and keyboard (or kvm)? Then setup the server to output the console to a serial port and use screen/minicom (Hyperterminal or putty in Windows) to console into the server over a serial cable.

To set this up, you need to edit /etc/inittab to tell it to start a terminal on the serial port for the console. If you want to see the kernel load and see all the services start then you also need to configure grub to use the serial port as well.

Edit /etc/inittab and add the line starting with "co" to the file (substitute the device name of your serial port for ttyS0 below):

co:2345:respawn:/sbin/agetty ttyS0 9600 vt100-nav # ADD THIS LINE
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6


To watch the kernel load (and all the services) you must configure grub to enable the console option in the kernel on boot. Edit /boot/grub.conf and add the "serial" and "terminal" lines below, and modify the "kernel" line to include the console specification:

serial --unit=0 --speed=9600
terminal --timeout=5 serial console
title CentOS (2.6.9-55.0.2.EL)
root (hd1,0)
kernel /vmlinuz-2.6.9-55.0.2.EL ro root=/dev/VolGroup00/LogVol00 console=ttyS0,9600n8
initrd /initrd-2.6.9-55.0.2.EL.img


To connect to the server just hook a serial cable from your laptop to the server. Set the speed to 9600, no parity and 8bits. Boot up the server, you should see kernel output, services load, and finally a login prompt. After you disconnect you can easily re-connect and log in: just fire up your terminal emulator, connect your serial cable, hit enter a few times and you should get a prompt to log in.