Skip to main content

Bootable WINDOWS and LINUX Pendrive

 Mount CD/DVD ISO or DVD ITSELF
Type the following command to mount Fedora 12 iso image:
# mount Fedora-12-x86_64-netinst.iso -o loop /media/cdrom0/
# DVD=/media/cdrom0
# ls -l $DVD

Sample outputs:
total 6
dr-xr-xr-x 3 root root 2048 2009-11-09 05:37 EFI
drwxr-sr-x 3 root  499 2048 2009-11-09 05:37 images
drwxr-sr-x 2 root  499 2048 2009-11-09 05:36 isolinux
You need to use files stored in isolinux directory to create a bootable usb pen.

Format Usb

Create the fdisk partition:
# fdisk /dev/sdb
You need to create only 1 partition. Next format the partition:
# USB=/media/usb
# mkdosfs /dev/sdb1

Finally mount the partition:
# mkdir -p /media/usb
# mount /dev/sdb1 /media/usb
# USB=/media/usb

Copy Required Files

Type the following commands:
# cp -av $DVD/isolinux/* $USB
# cd $USB
# rm isolinux.bin boot.cat TRANS.TBL
# mv isolinux.cfg syslinux.cfg

Also copy the installer's initial RAM disk $DVD/images/pxeboot/initrd.img (for CentOS / RHEL Linux use $DVD/RedHat/images/pxeboot/initrd.img file) CD/DVD onto the usb drive:
# cp -v $DVD/images/pxeboot/initrd.img $USB

Unmount the USB drive

# umount /dev/sdb1

Make the USB Bootable

Type the following command to make the USB drive bootable
# syslinux /dev/sdb1
# mount /dev/sdb1 $USB

syslinux is a boot loader for the Linux operating system which operates off an MS-DOS/Windows FAT filesystem.

Install Grub

Type the following command to install GRUB on the USB device:
# grub-install --root-directory=$USB /dev/sdb
Create grub.conf:
# cd $USB
# mkdir -p boot/grub

Edit the grub.conf file
default=0
timeout=5
root (hd1,0)
title Fedora Linux
kernel /vmlinuz
initrd /initrd.img
Finally, unmount the USB pen drive, enter:
# umount /dev/sdb1
Your USB pen is ready and should be bootable from the USB device. This can be used to install Fedora or CentOS or RHEL. You can also copy other required tools (such as sniffers or data recovery tools) on this pen. This is left as exercise for the reader.


Create a bootable Windows VISTA, 7 or Windows 8 install USB drive from ISO or DVD with Linux


It's very easy with Linux to create a bootable USB drive to install Windows 7 or Windows 8.
Requirements:
  • A Windows VISTA, 7 or 8 DVD, or the ISO file (download from Microsoft).
  • A USB drive with at least 4GB space to copy the Windows files on it.
  • A Linux distribution. Maybe Plop Linux ;), others like Ubuntu, Fedora, Debian and so on will also work.

Situation 1 - Partitioning and formatting is not required
Situation 2 - USB drive was not formatted by Windows


Situation 1 - Partitioning and formatting is not required


When you have a USB drive formatted by Windows (FAT32 or NTFS) then simply copy the Windows files that are on the DVD/ISO to the root directory of the USB drive.
To access the files on the ISO you have to mount it as loop device. You can do this with
sudo mkdir /mnt/iso
sudo mount [ISO FILE NAME] /mnt/iso -o loop
Copy the files from /mnt/iso/ to the root directory of the USB drive.
When you want to mount the USB drive from the command line then use

  • for a FAT formatted USB drive
    sudo mkdir /mnt/usb
    sudo mount /dev/sdc1 /mnt/usb
    
    /dev/sdc is in this case the USB drive and 1 is the first partition.


  • for a NTFS formatted USB drive
    sudo mkdir /mnt/usb
    sudo mount /dev/sdc1 /mnt/usb -t ntfs-3g
    
    /dev/sdc is in this case the USB drive and 1 is the first partition.

  • Unmount the USB drive before you unplug it. "umount /dev/sdc1".
    Boot the USB drive to install Windows (when you really need Windows).

    Situation 2 - USB drive was not formatted by Windows


    With this description, you delete all data on the USB drive. You can use tools like Gparted, but I explain it with doing all on the command line. Basically it's only a format to NTFS and copy the Windows install files.

    At first became root when you are not already root.
    You do this with "su" and enter the root password or with "sudo bash" and enter your password.
    In this example the USB drive is /dev/sdc.
    We change the type of the first partition to NTFS with fdisk
    fdisk /dev/sdc
    
    With "p" and enter you list all entries. You will see something similar.
    Disk /dev/sdc: 8011 MB, 8011120640 bytes
    246 heads, 40 sectors/track, 1590 cylinders, total 15646720 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x6b11f4f9
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1            2048    15646719     7822336    b  W95 FAT32
    
    Press "t" and enter to change the type.

    Partition 1 is automatically used because its the only partition on the drive.
    Use the hex code "7".
    Press "a" and enter to set the boot flag.

    Select Partition "1".
    When you press again "p" and enter then you should see something like this. Boot * and Id 7
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *        2048    15646719     7822336    7  HPFS/NTFS/exFAT
       
    
    Press "w" and enter to write the changes.


    Now format the USB drive with "mkntfs -f /dev/sdc1" or with "mkfs.ntfs -f /dev/sdc1"
    When the following directories in /mnt/ are not existing, then create them with "mkdir [directory]" or mount to a place that you want.
    Mount the USB drive. For example "mount /dev/sdc1 /mnt/usb -t ntfs-3g".
    Mount the DVD or ISO file.
    • DVD: Example "mount /dev/sr0 /mnt/dvd". /dev/sr0 is in this case my SATA DVD drive.
    • ISO: Example "mount win8.iso /mnt/dvd -o loop"
    Copy the files with "cp -avr /mnt/dvd/* /mnt/usb".
    Unmount the USB drive "umount /mnt/usb". This can take a while because of the USB file writing.
    Boot the USB drive to install Windows (when you really need Windows).

    Now, create a text file and write the following in it:

    default=1  
    timeout=15
    color_normal=light-cyan/dark-gray
    menu_color_normal=black/light-cyan
    menu_color_highlight=white/black
     
    menuentry "Start Windows Installation" {
        insmod ntfs
        insmod search_label
        search --no-floppy --set=root --label  --hint hd0,msdos1
        ntldr /bootmgr
    }
    
    menuentry "Boot from the first hard drive" {
        insmod ntfs
        insmod chain
        insmod part_msdos
        insmod part_gpt
        set root=(hd1)
        chainloader +1
        boot
    }
    Replace with the label from step 1 (you can place it between quotes if it contains a space, although it is not recommended to use spaces in drive label). Save the file as grub.cfg and put it on the USB drive in the boot/grub folder.

    Comments

    Popular posts from this blog

    RAID

    Check the Raid installed lspci | grep RAID     Software Raid ============== Linux Support For Software RAID Currently, Linux supports the following RAID levels (quoting from the man page): LINEAR RAID0 (striping) RAID1 (mirroring) RAID4 RAID5 RAID6 RAID10 MULTIPATH, and FAULTY. MULTIPATH is not a Software RAID mechanism, but does involve multiple devices: each device is a path to one common physical storage device. FAULTY is also not true RAID, and it only involves one device. It provides a layer over a true device that can be used to inject faults. Install mdadm Type the following command under RHEL / CentOS / Fedora Linux: # yum install mdadm Type the following command under Debian / Ubuntu Linux: # apt-get update && apt-get install mdadm How Do I Create RAID1 Using mdadm? Type the following command to create RAID1 using /dev/sdc1 and /dev/sdd1 (20GB size each). First run fdisk on /dev/sdc and /dev/sdd with " Software R

    How to tweak linux server harddisk using hdparm

    hdparm switches explained http://manpages.ubuntu.com/manpages/intrepid/man8/hdparm.8.html   First of all you have to install hdparm in linux. apt-get install hdparm #hdparm /dev/sda /dev/sda: readonly = 0 (off) readahead = 120 (on) geometry = 8850/255/63, sectors = 142182912, start = 0 Hard disk Performance Information # hdparm -tT /dev/hda /dev/hdd: Timing cached reads: 496 MB in 2.00 seconds = 247.42 MB/sec Timing buffered disk reads: 60 MB in 3.03 seconds = 19.81 MB/sec Hard drive set to low, slow settings # hdparm -cuda /dev/hda /dev/hda: IO_support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) readahead = 256 (on) Use below tweaks to increase disk read write performance. For sda drive ~]# hdparm -a 2048 /dev/sda /dev/sda: setting fs readahead to 2048 readahead = 2048 (on) For sdb drive [root@439298a ~]# hdparm -a 2048 /dev/sdb /dev/sdb: setting fs readahead to 2048 readahead = 2048 (on) ]# echo “anticipatory” > /sy

    Modsecurity block rule for XMLRPC and wp-login attack

    SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134  <Locationmatch "/wp-login.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"  SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"  SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"  SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"  </Locationmatch>  SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000234  <Locationmatch "/xmlrpc.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000235,msg:'ip address blocked for 5 m