≡ Menu

mount command

Linux: Recovering Deleted /etc/shadow Password File

You may delete a file called /etc/shadow. If you try to boot into a single user mode, system will ask for the maintenance root password. Now imagine this, you do not have a backup of /etc/shadow file. How do you fix such problem in a production environment where time is a critical factor? I will explain how to recover a deleted /etc/shadow file in five easy steps.
[click to continue…]

Linux: Burn multi session CDs on Linux

Under Linux you can use tool called cdrecored (use to record audio or data Compact Discs) with mkisofs (use to create an hybrid SO9660/JOLIET/HFS filesystem with optional Rock Ridge attributes ) for this purpose.

Step #1: Create first session as follows

1) Create an iso image first:

# mkisofs -R -o /tmp/cd.iso /backup/06-07-2004/

Where,

  • -R : Uses Rock Ridge naming convention/attributes
  • -o : Name of new iso file (cd.iso)
  • /backup/06-07-2004/ : Everything in /backup/06-07-2004/ will be put into cd.iso file

2) Burning the disk (or an ISO image) for first session:

# cdrecord -dev=0,0,0 -multi -data -v -eject -speed=4 /tmp/cd.iso

Where,

  • -dev=0,0,0 : device number (tip you can use cdrecord -scanbus command to get this number)
  • -multi : Start multi session disk
  • -data : This option required for HP and Sony CD Writer only.
  • -v : Verbose i.e show info while burning the disk
  • -eject : Ejects the CD when done
  • -speed=4 : Write speed (4x)
  • cd.iso : Name of image being burned

3) Mount cdrom and see the contains:

# mount /mnt/cdrom
# ls /mnt/cdrom
# rm -f /tmp/cd.iso

OR< pre># mount /dev/hda /mnt/cdrom; ls /mnt/cdrom; rm -f /tmp/cd.iso
4) You can also verify that how many sessions written so far:

# umount /mnt/cdrom
# cdrecord -dev=0,0,0 -toc

Where,

  • -dev=0,0,0 : Device number
  • -toc : Retrieve and print out the table of content

Step #2: Burning the disk (or ISO image) for next session

Next session is bit tricky. You need to specify last sessions starting and ending sector numbers this information can be obtained from the following command:

# cdrecord -dev=0,0,0 -msinfo

Output:

0,11063

1) Create next session ISO file:

# mkisofs -o /tmp/ses2.iso -R -V session2 -C $(cdrecord -dev=0,0,0 =msinfo)
-M 0,0,0 /backup/07-07-2004

Where,

  • -C $(cdrecord -dev=0,0,0 –msinfo) : This option is needed when mkisofs is used to create the image of a second session or a higher level session for a multi session disk
  • -M 0,0,0 : Specifies path to existing iso9660 image to be merged.

2) Burning the disk (or an ISO image) for second session:

# cdrecord -dev=0,0,0 -multi -data -v -eject -speed=4 /tmp/ses2.iso

3) Mount cdrom and see the contains:

# mount /mnt/cdrom; ls /mnt/cdrom; rm -f /tmp/ses2.iso

OR

# mount /dev/hda  /mnt/cdrom; ls /mnt/cdrom; rm -f /tmp/ses2.iso

Note: When you wish to close disk (multi session cd), omit the -multi option for last session.

Online references:

All files accessible in a Linux (and UNIX) system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file system found on some device to the big file tree.

Use the mount command to mount remote windows partition or windows share under Linux as follows:

Procedure to mount remote windows partition (NAS share)

1) Make sure you have following information:
==> Windows username and password to access share name
==> Sharename (such as //server/share) or IP address
==> root level access on Linux

2) Login to Linux as a root user (or use su command)

3) Create the required mount point:
# mkdir -p /mnt/ntserver
4) Use the mount command as follows:
# mount -t cifs //ntserver/download -o username=vivek,password=myPassword /mnt/ntserver

Use following command if you are using Old version such as RHEL <=4 or Debian <= 3: # mount -t smbfs -o username=vivek,password=D1W4x9sw //ntserver/download /mnt/ntserver

5) Access Windows 2003/2000/NT share using cd and ls command:
# cd /mnt/ntserver; ls -l
Where,

  • -t smbfs : File system type to be mount (outdated, use cifs)
  • -t cifs : File system type to be mount
  • -o : are options passed to mount command, in this example I had passed two options. First argument is password (vivek) and second argument is password to connect remote windows box
  • //ntserver/download : Windows 2000/NT share name
  • /mnt/ntserver Linux mount point (to access share after mounting)

See also:

Updated for accuracy on Aug-8-2007, 8:19PM.

How to: Mount an ISO image under Linux

An ISO image is an archive file (disk image) of an optical disc using a conventional ISO (International Organization for Standardization) format. ISO image files typically have a file extension of .ISO. The name "ISO" is taken from the ISO 9660 file system used with CD-ROM media, but an ISO image can also contain UDF file system because UDF is backward-compatible to ISO 9660.

You can mount an ISO images via the loop device under Linux. It is possible to specify transfer functions (for encryption/decryption or other purposes) using loop device.

But, how do you mount an ISO image under Linux? You need to use mount command as follows:
[click to continue…]