10 Replies Latest reply: Jul 17, 2014 6:53 AM by Billy~Verreynne RSS

    How to format one partition from existing filesysem

    V. A. Nagpure

      Hi All,

       

      I want to install ASM on my RHEL machine. There is one disk which has been partitioned into regular filesystem as follows:

       

      [root@*** /]# fdisk -l

       

      Disk /dev/hda: 644.2 GB, 644245094400 bytes

      255 heads, 63 sectors/track, 78325 cylinders

      Units = cylinders of 16065 * 512 = 8225280 bytes

       

         Device Boot      Start         End      Blocks   Id  System

      /dev/hda1   *           1          25      200781   83  Linux

      /dev/hda2              26       57392   460800427+  83  Linux

      /dev/hda3           57393       61471    32764567+  82  Linux swap / Solaris

      /dev/hda4           61472       78325   135379755    5  Extended

      /dev/hda5           61472       78325   135379723+  83  Linux

       

      My question is, how can I format and merge a couple of partitions from these to create a volume for ASM? Is it even possible?

       

      Regards,

      Vinod

        • 1. Re: How to format one partition from existing filesysem
          Catch~22

          For ASM it does not matter whether a device is a raw disk or partition. It will use IO_DIRECT flag to open the database files to bypass the filesystem and kernel buffering. You can however not use a logical or extended partition since ASM would overwrite that partition table. Looking at your partition layout, you cannot use ASM without erasing the data. You could probably use parted or gparted and erase the last 2 partitions, then create a new primary partition and use that for ASM. Considerations for Oracle ASM Storage

          • 2. Re: How to format one partition from existing filesysem
            V. A. Nagpure

            I want to erase the /dev/hda2 partition and use it to install ASM. How can it be done?

            • 3. Re: How to format one partition from existing filesysem
              Senthilkumar -Oracle

              It can be done as below:

               

              #fdisk /dev/hda

               

              p

               

              --To print partitions

               

              d

               

              --To delete partition, chose 2[This will erase the contents in it]

               

              n

               

              --Create new partition

              choose p to create primary partition

               

              now /dev/hda1 can be used as  ASM disk.

               

              #chown oracle:oinstall /dev/hda1

               

              login to ASM and update the asm_diskstring to include this disk and run "select* from v$asm_disk" we can see this new disk as CANDIDATE Or Provisioned

               

              Thanks,
              Senthil

              • 4. Re: How to format one partition from existing filesysem
                Billy~Verreynne

                Vinod Nagpure wrote:

                 

                I want to erase the /dev/hda2 partition and use it to install ASM. How can it be done?

                 

                I would simply change the partition type to "da" (Non-FS Data), using fisk. (select type, partition, enter da and write changes).

                 

                You may need to edit /etc/fstab to prevent the kernel from mounting the partition (which will fail as it no longer can be mounted as a file system due to its type).

                 

                The next step is to make that device visible to ASM. ASM will run typically as either the grid or oracle o/s users. The device needs to be owned by the ASM user, group needs to be oinstall, and read/write permissions are needed by the group. Usually grid will own the disk/partition device, and oracle will perform I/O in it from a db perspective - which means that oracle, as part of group oinstall, need to have full read and write access to that device.

                 

                The quick dirty hack to do this (to get you started) is to edit /etc/rc.local and adding:

                chown grid.oinstall /dev/hda2

                chmod ug+rw /dev/hda2

                 

                However, disk/device permissions should be dealt with using udev rules.

                 

                In ASM, set the disk discovery string to "/dev/hda2".

                 

                You should see the disk via a "select * from v$asm_disk", connected as sysasm via sqlplus to the ASM instance.

                • 5. Re: How to format one partition from existing filesysem
                  Billy~Verreynne

                  SenthilKumar - Oracle wrote:

                   

                  It can be done as below:

                   

                  #fdisk /dev/hda

                   

                  p

                   

                  --To print partitions

                   

                  d

                   

                  --To delete partition, chose 2[This will erase the contents in it]

                   

                  n

                   

                  --Create new partition

                  choose p to create primary partition

                   

                  now /dev/hda1 can be used as  ASM disk.

                   

                  #chown oracle:oinstall /dev/hda1

                   

                  login to ASM and update the asm_diskstring to include this disk and run "select* from v$asm_disk" we can see this new disk as CANDIDATE Or Provisioned

                   

                  Thanks,
                  Senthil


                  Dangerous - the default partition type of a newly created partition is ext3. Which means the kernel will view that partition as a regular file system - and will attempt to mount and use it. A sysadmin will not know, looking at the type of partition, that it is not an ext file system, but in fact a raw device.

                   

                  One needs to avoid this confusion - as it easily can trash your entire database's storage (diskgroup). With the only option being to restore backups that likely is out of date, or non-existent. (given the lackadaisical attitude to use a file system partition as a raw device, it is a reasonable assumption that backups are in a similar sorry state)

                   

                   

                  PS. and the question was how to use /dev/hda2 - you described removing that partition and then using /dev/hda1 (which will likely trash the root file system).

                  • 6. Re: How to format one partition from existing filesysem
                    V. A. Nagpure

                    Thank you, BillyVerreynne!

                     

                    I managed to do it by using 'oracleasm'. This is a test machine where I am trying to learn Grid, RAC, ASM...

                     

                    Regards,

                    Vinod

                    • 7. Re: How to format one partition from existing filesysem
                      V. A. Nagpure

                      I had tried fdisk but it was not working for me. Maybe I was missing something.

                      • 8. Re: How to format one partition from existing filesysem
                        Catch~22

                        Alternatively, the OP can simply install and setup Linux asmlib. Them simply add the existing /dev/hda2 partition as a ASM disk, e.g. /etc/init.d/oracleasm createdisk VOL1 /dev/hda2. That's all. No need to worry about device persitance, owneship, partitioning, etc.

                         

                        However, the setup defeats the purpose of ASM in general. I woud rather suggest the OP installs VirtualBox and creates as many virtual disks required for the desired ASM setup and testing.

                        • 9. Re: How to format one partition from existing filesysem
                          Billy~Verreynne

                          Using fdisk one can print the list of partitions using the p key. E.g.

                          # fdisk /dev/hda

                          p

                           

                          If you want to change the partition type of partition 2, then press t, select partition, and specify the type. E.g.

                          t

                          2

                          da

                           

                          Use the print key to view changes made. E.g.

                          p

                           

                          If happy, write the changes to disk using the w key. E.g.

                          w

                           

                          This is basic Linux sysadmin for dealing with disks.

                          • 10. Re: How to format one partition from existing filesysem
                            Billy~Verreynne

                            Agree - virtualisation can be used to create realistic cluster architecture, from iscsi target servers, to database iscsi initiator cluster nodes.