Posts Tagged ‘GRUB’

Securing Linux for Physical Access

No Comments »

 

Physical access is everything, it is almost impossible to prevent machine access/password break if somebody else got physical access to some Linux machine.

But there are some steps you can make somebody work hard to access the machine physically (provided they have good knowledge of Linux). Read the rest of this entry »


Mount point busy or already mounted error – CentOS

2 Comments »

 

Recently when my servers HDD dead, data center installed a new HDD keeping orginal HDD as secondary so that i can copy data back to new HDD.

I tried to mount the HDD normal way, but got the error:-

[root@server78 ~]# fdisk -l /dev/hda
 
 Disk /dev/hda: 160.0 GB, 160041885696 bytes
 255 heads, 63 sectors/track, 19457 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       19457   156183930   8e  Linux LVM
 
 [root@server78 ~]# mount /dev/hda2 /tmp/mnt
 mount: /dev/hda2 already mounted or /tmp/mnt busy

The old drive is lvm. you were trying to mount it like it was an ext3 filesystem. I have listed what i did below so you can see it.

Now we need to check the old disk is using LVM ? type:-

[root@server78 ~]# pvs
PV         VG         Fmt  Attr PSize   PFree
/dev/hda2  VolGroup01 lvm2 a-   148.94G 32.00M
/dev/hdb2  VolGroup00 lvm2 a-   114.94G 96.00M

So now we know our second hard disk VolumeGroup name is “VolGroup00”, now we can mount it like:-

[root@server78 ~]# mount /dev/VolGroup01/LogVol00 /mnt

That’s it, you can see the folders in /mnt/, Edit/copy as you like.


How To Reset ROOT (or any user’s) Password in Linux distro

2 Comments »

The root user can change the password for any other user. However what if you forget your root password?

To reset your root password (or any other account’s password for that matter), there are essentially two different situations which require varying approaches

When you can use Boot Loaders (GRUB / LILO)

If you have GRUB installed and you have accesses to edit boot parameters of selected entries then the job is as easy as it can get. Follow along and you shall have root access in no time. Once you have root access you can pretty much do anything you want to do!

  • Highlight the GRUB entry for the Linux installation that you want to reset the password for.
  • Press ‘e’ to edit. Select the Kernel line. Add ‘single’ at the end of the kernel line, Press ENTER and then Press ‘b’ to boot. If your system still requires you to enter the root password, add init=/bin/bash at the end. Press ‘b’ to boot.
  • Please note in some distros 'single' can be, 'linux single' , 'run level 1' etc.

GRUB Boot Loader

  • Either you would be taken to the root prompt directly or shown the recovery menu from where you can choose the root prompt. Use passwd <username> to change the password for any account.
  • Type reboot to reboot the system and then log in in with your new password.
When you can’t use Boot Loaders

If you are unable to use GRUB for whatever reasons (like password protected entries) you can still reset the password using a Live CD (I will be using Ubuntu Live CD, you may use any other). Just follow the steps below to achieve this:

  • Boot from the Live CD (Download Link) (Aslo you can try USB drive to boot after downloading .ISO file, try this)
  • Choose
    Try Ubuntu without any changes to your computer” 
  • When the system is ready, fire up a terminal window (CTRL+ALT+F1) and get ready for some command line action
  • Type sudo fdisk -l.
    In the output we are concerned to know which partition Linux is installed on and what name the hard disk is using. (e.g) in my case it is /dev/sda1 is the required partition. If you are sure about the partition you can skip this step
  • Next we need to mount the Linux partition. Create a directory to act as mount point for the partition. Use ‘sudo mkdir /media/masterdrive
  • Mount the linux partition using the command ‘sudo mount /dev/sda1 /media/masterdrive
  • Change Root to the mount directory – ‘sudo chroot /media/masterdrive
    (if no /bin/bash error, then try other partition=> sudo fdisk -l)
  • Type sudo passwd and then enter the new password to change the root password.
  • OR type password <username> for anyother user
  • Type sudo reboot to restart the system.
  • You just recovered your root password.