Find the answer to your Linux question:
Results 1 to 6 of 6
Hi! I'm having some trouble with my phpMyAdmin. First I installed apache2 and MySql DB. Then I installed phpMyAdmin using "apt-get install phpmyadmin" command. Installation should make a folder ( ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Location
    Slovenia / Maribor
    Posts
    10

    [SOLVED] Problem w/ phpmyadmin

    Hi!

    I'm having some trouble with my phpMyAdmin. First I installed apache2 and MySql DB. Then I installed phpMyAdmin using "apt-get install phpmyadmin" command. Installation should make a folder (afaik) in www root but it doesn't. What's the problem?

    Ciao,
    Simon

    P.S.: Sorry for my bad english



    OK, problem solved:
    Code:
    sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
    sudo /etc/init.d/apache2 reload
    Bye

  2. #2
    Just Joined!
    Join Date
    Feb 2011
    Posts
    5
    download file phpMyadmin 2.11.11.2-all-languages.tar.gz
    cd it to our document root of httpd.
    my document root is /var/www/html
    so
    tar xvfz /home/anucs/Desktop/phpMyAdmin-2.11.11.2-all-languages.tar.gz

    mv phpMyAdmin-2.11.11.2-all-languages/ phpmyadmin

    chown -R phpmy.apache phpmyadmin/
    cd phpmyadmin/
    720 mkdir config
    721 chmod o+x config
    722 cp config.sample.inc.php config/config.inc.php
    723 chmod o+x config/config.inc.php
    check if php-mysql is installed.If not installed install it.
    yum install php-mysql

    cat /etc/my.cnf
    [root@ical ~]# cat /etc/my.cnf
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql


    Copy the socket name to config.inc.php

    [root@ical ~]# cat /var/www/html/phpmyadmin/config.inc.php
    <?php
    /* vim: set expandtab sw=4 ts=4 sts=4: */
    /**
    * phpMyAdmin sample configuration, you can use it as base for
    * manual configuration. For easier setup you can use scripts/setup.php
    *
    * All directives are explained in Documentation.html and on phpMyAdmin
    *
    *
    * @version $Id$
    */

    /*
    * This is needed for cookie based authentication to encrypt password in
    * cookie
    */
    $cfg['blowfish_secret'] = 'ninety'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

    /*
    * Servers configuration
    */
    $i = 0;

    /*
    * First server
    */
    $i++;
    /* Authentication type */
    #$cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'ical123'; // use here your password
    #$cfg['Servers'][$i]['user'] = 'anucs';
    #$cfg['Servers'][$i]['password'] = 'ical123'; // use here your password
    #$cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['connect_type'] = 'socket';
    $cfg['Servers'][$i]['compress'] = false;
    /* Select mysqli if your server has it */
    $cfg['Servers'][$i]['extension'] = 'mysql';
    $cfg['Servers'][$i]['socket'] = '/var/lib/mysql/mysql.sock';
    /* User for advanced features */
    $cfg['Servers'][$i]['controluser'] = 'pma';
    $cfg['Servers'][$i]['controlpass'] = 'pmapass';
    /* Advanced phpMyAdmin features */
    // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
    // $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
    // $cfg['Servers'][$i]['relation'] = 'pma_relation';
    // $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
    // $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
    // $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    // $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
    // $cfg['Servers'][$i]['history'] = 'pma_history';
    // $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

    /*
    * End of servers configuration
    */

    /*
    * Directories for saving/loading files from server
    */
    $cfg['UploadDir'] = '';
    $cfg['SaveDir'] = '';

    ?>

    Edit /etc/php.ini

    ; Default socket name for local MySQL connects. If empty, uses the built-in
    ; MySQL defaults.
    mysql.default_socket = "/var/lib/mysql/mysql.sock"





    After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts:

    mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'

    -> WITH GRANT OPTION;
    mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'

    -> WITH GRANT OPTION;
    mysql> CREATE USER 'admin'@'localhost';
    mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';

    mysql> CREATE USER 'dummy'@'localhost';


    I DID THIS

    [anucs@ical ~]$ mysql -u root
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.0.77 Source distribution

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> CREATE USER 'anucs'@'localhost' IDENTIFIED BY 'ninety';
    Query OK, 0 rows affected (0.00 sec)

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'anucs'@'localhost'
    -> WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)

  3. #3
    Just Joined!
    Join Date
    Feb 2011
    Posts
    5
    # CacheEnable disk /
    # CacheRoot "/var/cache/mod_proxy"
    #</IfModule>
    #

    #</IfModule>
    # End of proxy directives.
    <IfModule mod_mime.c>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
    AddType application/x-httpd-php-source .phps
    </IfModule>
    ### Section 3: Virtual Hosts
    #
    # VirtualHost: If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #

  4. #4
    Just Joined!
    Join Date
    Feb 2011
    Posts
    5
    First, use the mysql program to connect to the server as the MySQL root user:

    shell> mysql --user=root mysql

    If you have assigned a password to the root account, you will also need to supply a --password or -p option, both for this mysql command and for those later in this section.

    After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts:

    mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    -> WITH GRANT OPTION;
    mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    -> WITH GRANT OPTION;
    mysql> CREATE USER 'admin'@'localhost';
    mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
    mysql> CREATE USER 'dummy'@'localhost';

    The accounts created by these statements have the following properties:

    *

    Two of the accounts have a user name of monty and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. The 'monty'@'localhost' account can be used only when connecting from the local host. The 'monty'@'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.

    It is necessary to have both accounts for monty to be able to connect from anywhere as monty. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'monty'@'%' account and thus comes earlier in the user table sort order. (user table sorting is discussed in Section 5.4.4, “Access Control, Stage 1: Connection Verification”.)
    *

    The 'admin'@'localhost' account has no password. This account can be used only by admin to connect from the local host. It is granted the RELOAD and PROCESS administrative privileges. These privileges enable the admin user to execute the mysqladmin reload, mysqladmin refresh, and mysqladmin flush-xxx commands, as well as mysqladmin processlist . No privileges are granted for accessing any databases. You could add such privileges later by issuing other GRANT statements

  5. #5
    Just Joined!
    Join Date
    Feb 2011
    Posts
    5
    SCRIPT

    #!bin/bash
    echo -n "Enter hosts: "
    read hosts
    checkhost()
    {
    echo "Checking host $1..."
    ping -c 2 $1 &> /dev/null

    if [ $? == 0 ]
    then
    echo "$1 is running"
    else
    echo "$1 is not reachable"
    fi
    }

    HOSTLIST="$hosts"

    for hosts in $HOSTLIST
    do
    checkhost $hosts
    done
    ~

  6. #6
    Just Joined!
    Join Date
    Feb 2011
    Posts
    5
    1.List and briefly explain four advantages of installing Linux on multiple partitions.
    Disk partitioning is the act of dividing a hard disk drive into multiple logical storage units referred to as partitions, to treat one physical disk drive as if it were multiple disks.
    The advantages are:-

    We can separate operating system and program files from the users so that we can create necessary backups of them.
    We can keep frequently used programs and their data near to each other.This impoves ease of use
    Cache and log files can be separated from each other.
    We can have multi-boot systems i.e,more than one OS in the same ytem.
    Partitioning makes error recover easier as even though one partition gets corrupted other partitions are not affected.This improve security
    it may reduce the time required to perform file system checks as multiple checks may be done in parallel.
    We can mount one or more partition as read only if necessary
    Smaller file systems are more efficient. You can tune file system as per application such as log or cache files and this can improve performance.
    We can increase disk space efficiency by formatting disk with various block sizes. It depends upon usage.This impoves stability and efficiency.

    2.What are (a) Primary, (b) Extended and (c) Logical Partitions?

    (a)
    A maximum of four partitions can be placed on any hard disk. These are sometimes called primary partitions.

    (b)
    An extended partition is the only kind of partition that can have multiple partitions inside. It is like a box that contains other boxes, the logical partitions. The extended partition can't store anything, it's just a holder for logical partitions.
    The extended partitions is a way to get around the fact we can only have four primary partitions on a drive. We can put lots of logical partitions inside it.

    (c)
    When we set up an extended partition, it is initially empty; we can use up the space in it by adding logical partitions. i.e,extended partition can be further divided into many logical partitions. Internally, the logical drives are stored in a linked structure.

    3.Give an example device name of a (a) Primary (b) Extended and (c) Logical Partition.

    /dev/hda1,/dev/hda2 and /dev/hda3 are primary partitions.
    /dev/hda1 = First partition on master drive.
    /dev/hdb = Entire second HD
    /dev/hdb1 is first partition on second drive.
    /dev/hdb2,/dev/hdb3 are primary partitions
    /dev/hda4 is the entire extended partition.It is theoretical as it cannot be mounted as such but it takes up the number 4.
    /dev/hda5,/dev/hda6,//dev/hda7 and so on are the logical partitions.

    4.What is the device name of a disk of type (a) IDE (b) SATA (c) Flash (d) DVD Drive (e) Floppy?

    (a)
    IDE drives will be given device names /dev/hda to /dev/hdd. Hard Drive A (/dev/hda) is the first drive and Hard Drive C (/dev/hdc) is the third.
    For IDE devices the disk names are of type hdxy where x will be a letter starting with a, then b,c,....
    y will be a number starting with 1, then 2,3,....
    /dev/hda1 is the first primary partition on master drive
    /dev/hda2 is the second primary partition on master drive.
    /dev/hda3 is the third primary partition on master drive
    /dev/hda4 is the extended partition which can be divide into many logical partitions named /dev/hda5./dev/hda6 etc...

    (b)
    SATA drives will be given device names /dev/sda to /dev/sdd.
    For SATA devices the disk names are of type sdxy where x will be a letter starting with a, then b,c,....
    y will be a number starting with 1, then 2,3,....

    (c)
    [root@localhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/hda2 20G 3.9G 15G 21% /
    /dev/hda1 99M 12M 83M 12% /boot
    tmpfs 756M 0 756M 0% /dev/shm
    /dev/sda1 3.8G 1.4G 2.4G 37% /media/TINTU
    /dev/sdb1 1.9G 358M 1.6G 19% /media/DIVYA

    The flash drives are named /dev/sda1,/dev/sdb1 and so on.sd is for removable scsi devices.
    The reason a USB disk becomes /dev/sda1 is that USB-based storage devices, as well as SATA devices are managed by the SCSI subsystem, instead of the IDE subsystem. This explains the s in sda. The d stands for Disk, and the a letter is for the first disk. The second disk would be b,c,d etc. Finally, the "1" at the end is for the partition number 1

    (d)
    The device name is /dev/scd
    The first device is named /dev/scd0,second device is named /dev/scd1 etc


    (e)
    the device name for floppy drive is /dev/fd
    The first partition is named fd0,second partition is named fd1 etc


    5.List with examples, in what three ways your hard-disk device name can be determined.
    (a)
    [root@localhost ~]# fdisk -l
    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris

    The command fdisk with option -l lists the partition table for devices and then exits.

    (b)
    [root@localhost ~]# cat /proc/partitions
    major minor #blocks name

    3 0 78150744 hda
    3 1 104391 hda1
    3 2 20972857 hda2
    3 3 2096482 hda3

    The file proc/partitions lists all the partitions and devices.

    (c)
    [root@localhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/hda2 20G 3.8G 15G 21% /
    /dev/hda1 99M 12M 83M 12% /boot
    tmpfs 756M 0 756M 0% /dev/shm

    df displays the amount of disk space available on the file system containing each file name argument. When no file name is given, the space available on all currently mounted file systems is shown.When option -h is given it displays disk space in human readable format.


    (d)
    [root@localhost ~]# hwbrowser



    It is a graphical browser for current hardware configuration.It provides read only access to hardware information.


    6.What is the MBR?
    A master boot record (MBR), or partition sector, is the 512 byte-boot sector that is the first sector of a partitioned data storage device such as hard disk.
    MBR may be used for holding a disk's primary partition table , boot straping the OS etc
    Every hard disk must have a consistent "starting point" where key information is stored about the disk, such as how many partitions it has, what sort of partitions they are, etc.This is the place where BIOS can load the initial boot program that starts the process of loading the operating system. This is called the master boot record (MBR). It is also sometimes called the master boot sector or even just the boot sector

    7.(a) What is a boot-loader? (b) In what two places can it reside in Linux?
    (a)
    The boot-loader loads the main operating sysem for the computer.
    This loads the first 512-byte sector from the boot disk into RAM and jumps to it.
    A boot loader typically consists of three programs:
    The boot sector program is directly loaded by the BIOS at boot time and is only 512 bytes in size.
    The second stage program is loaded by the boot sector program.
    The boot loader installer is not run when the system is booted, but it is used to install the boot loader and the second stage program onto the boot disk.
    The second stage of boot loader has user interface and kernel loader.The user interface allows us to select any number of operating systems

    (b)
    The two places where boot loader can reside are

    The master boot record (MBR)
    This is the recommended place to install a boot loader. The MBR is a special area on your hard drive that is automatically loaded by your computer's BIOS, and is the earliest point at which the boot loader can take control of the boot process. If we install it in the MBR, when machine boots, GRUB (or LILO) will present a boot prompt. We can then boot Red Hat Linux or any other operating system that we have configured the boot loader to boot.
    The first sector of boot partition
    This is usually recommended if we are already using another boot loader on the system. In this case, the other boot loader will take control first. We can then configure that boot loader to start GRUB (or LILO), which will then boot Red Hat Linux.

    8.Which file under /proc shows the list of partitions currently known to the system
    [root@localhost ~]# cat /proc/partitions
    major minor #blocks name

    3 0 78150744 hda
    3 1 104391 hda1
    3 2 20972857 hda2
    3 3 2096482 hda3

    The file /proc/partitions lists all the partitions known to system

    9.How would you list the disk partition layout on your system.
    To list the partition layout we can use the command fdisk -l
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris

    10.How could you determine the amount of free un-partitioned space on your Hard-Disk?
    (a) Using a GUI Tool (b) Using a CLI Tool
    [Use tools that are included with CentOS]

    (a)
    [root@localhost ~]# hwbrowser



    It is a graphical browser for current hardware configuration.It provides read only acess to hardware information.

    (b)
    [root@localhost ~]# parted
    GNU Parted 1.8.1
    Using /dev/hda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) print free

    Model: ST380011A (ide)
    Disk /dev/hda: 80.0GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number Start End Size Type File system Flags
    1 32.3kB 107MB 107MB primary ext3 boot
    2 107MB 21.6GB 21.5GB primary ext3
    3 21.6GB 23.7GB 2147MB primary linux-swap
    23.7GB 80.0GB 56.3GB Free Space

    or

    [root@localhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/hda2 20G 3.9G 15G 21% /
    /dev/hda1 99M 12M 83M 12% /boot
    tmpfs 756M 0 756M 0% /dev/shm


    11.How would you create a new 256MB partition on Linux using fdisk?
    [Only create without making a filesystem or formatting]

    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    e
    Selected partition 4
    First cylinder (2886-9729, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-9729, default 9729): +256M

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.

    Command n created a new partition and w is to write the changes.


    [root@localhost ~]# partprobe /dev/hda

    [root@localhost ~]# cat /proc/partitions
    major minor #blocks name

    3 0 78150744 hda
    3 1 104391 hda1
    3 2 20972857 hda2
    3 3 2096482 hda3
    3 4 0 hda4

    partprobe informs the OS about changes made to partition table.



    12.How could we quit out of fdisk (a) Writing changes (b) Discarding changes

    (a)
    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +120M

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.
    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2901 128488+ 83 Linux

    The command w writes the changes.If we quit (q) without typing w,it just quits without saving the changes.


    (b)
    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2902-2917, default 2902):
    Using default value 2902
    Last cylinder or +size or +sizeM or +sizeK (2902-2917, default 2917): +100M

    Command (m for help): q

    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2901 128488+ 83 Linux

    As w command was not given the changes made to partition table didn't get saved.



    13.How would you create a new 256MB partition of type:
    (a) Linux Swap (b) VFAT or FAT32 (c) EXT2 (d) RAID Member (e) LVM Physical Volume
    [Be careful with the partition numbers when changing the filesystem type]

    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +256M

    Command (m for help): t
    Partition number (1-5): 5

    Hex code (type L to list codes): 82
    Changed system type of partition 5 to 82 (Linux swap / Solaris)

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.
    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2917 257008+ 82 Linux swap / Solaris

    The hexcode to create partition of type Linux swap is 82

    (b)

    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +256M

    Command (m for help): t
    Partition number (1-5): 5

    Hex code (type L to list codes): b
    Changed system type of partition 5 to b (W95 FAT32)

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.

    WARNING: If you have created or modified any DOS 6.x
    partitions, please see the fdisk manual page for additional
    information.
    Syncing disks.
    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2917 257008+ b W95 FAT32

    The hexcode to create FAT32 type partition is b

    (c)
    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +256M

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.
    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2917 257008+ 83 Linux

    The newly created partition 5 is of type EXT2 by default.The hexcode is 83

    (d)
    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +256M

    Command (m for help): t
    Partition number (1-5): 5
    Hex code (type L to list codes): fd
    Changed system type of partition 5 to fd (Linux raid autodetect)

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.

    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2917 257008+ fd Linux raid autodetect

    The hexcode for raid autodetect is fd

    (e)

    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +256M

    Command (m for help): t
    Partition number (1-5): 5
    Hex code (type L to list codes): 8e
    Changed system type of partition 5 to 8e (Linux LVM)

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.

    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2917 257008+ 8e Linux LVM

    The hexcode for linux LVM is 8e

    14.How could you delete an existing partition?
    [Create a new partition, and then delete to demonstrate, being careful not to delete a needed partition]

    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended

    Next partition 5 can be created using fdisk

    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)


    Command (m for help): n
    First cylinder (2886-2917, default 2886):
    Using default value 2886
    Last cylinder or +size or +sizeM or +sizeK (2886-2917, default 2917): +10M

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.
    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended
    /dev/hda5 2886 2887 16033+ 83 Linux

    The 5th partition got created.

    Now we can delete it using command fdisk

    [root@localhost ~]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): d
    Partition number (1-5): 5

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.
    [root@localhost ~]# partprobe /dev/hda
    [root@localhost ~]# fdisk -l

    Disk /dev/hda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 * 1 13 104391 83 Linux
    /dev/hda2 14 2624 20972857+ 83 Linux
    /dev/hda3 2625 2885 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2886 2917 257040 5 Extended

    The fdisk command option d is used to delete the partition.


    15.What command updates the kernel's copy of disk partitions; without resorting to a reboot.

    We can run 'partprobe' after exiting the partitioning utility and 'partprobe' will let the kernel know about the modified partition table information. If we have several disk drives and want to specify a specific drive for 'partprobe' to scan, we can run 'partprobe <device_node>'
    eg:-
    [root@localhost ~]# partprobe /dev/hda

    partprobe is a program that informs the OS about changes in the partition table by requesting that the operating system re-read the partition table.



    16.How can the current list of partitions be sent to a file using sfdisk?

    [root@localhost ~]# sfdisk -l

    Disk /dev/hda: 9729 cylinders, 255 heads, 63 sectors/track
    Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

    Device Boot Start End #cyls #blocks Id System
    /dev/hda1 * 0+ 12 13- 104391 83 Linux
    /dev/hda2 13 2623 2611 20972857+ 83 Linux
    /dev/hda3 2624 2884 261 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2885 2916 32 257040 5 Extended

    The command sfdisk with option -l lists the current partitions on the system.

    [root@localhost ~]# sfdisk -l > diskfile

    We can redirect the output to a file named diskfile

    [root@localhost ~]# cat diskfile

    Disk /dev/hda: 9729 cylinders, 255 heads, 63 sectors/track
    Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

    Device Boot Start End #cyls #blocks Id System
    /dev/hda1 * 0+ 12 13- 104391 83 Linux
    /dev/hda2 13 2623 2611 20972857+ 83 Linux
    /dev/hda3 2624 2884 261 2096482+ 82 Linux swap / Solaris
    /dev/hda4 2885 2916 32 257040 5 Extended

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...