Linux Disk Management Command usage detailed

Source: Internet
Author: User
Tags lowercase memory usage mkdir posix readable zip disk usage

Let's take a look at an example and write it yourself.

The first step is to find the newly added disk usage

FDISK-L lists all the disks. The more stupid way can also go to the/dev directory under LS, see the newly added disk name. If it's just a mount, the disk name is found and can be mounted.

Second Step partition

Fdisk/dev/sdb refer to the command prompt can be, relatively simple.

Initializing the Swap partition

Mkswap/dev/sda2 Activate swap partition

SWAPON/DEV/SDA2 Format Partition Example:

Format the/dev/hdc6 just as Windows readable VFAT format!

For:

Mkfs-t VFAT/DEV/HDC6

Disk Management commands for common commands

CD usage rights: All users
How to use: CD [dirname]
Description: Transform working directory to dirname. Where the dirname notation can be either an absolute path or a relative path. If the directory name is omitted, it is transformed to the user's home directory (that is, the directory where the login was just started).
In addition, "~" is also expressed as the meaning of home directory, "." is the current directory, "..." to represent the current directory location of the previous level.
Example: Skip to/usr/bin/:
Cd/usr/bin
Skip to your home directory:
CD ~
Skip to the top two levels of the current directory:
Cd.. /..
cd– returns to the directory before entering the current directory

DF Use permissions: All users
using: DF [Options] ... [FILE] ...   
Display the status of the file system, or look at the status of all archival systems (preset)
-a,–all contains all 0 Blocks file systems
–block-size={size} using the size of {size} Blocks
-h,–human-readable use human readable format (default is not added to this option ...)
-h,–si is like-H, but listing inode information in 1000 units instead of 1024
-i,–inodes does not list the used block
-k,–kilobytes is like –block-siz e=1024
-l,–local Limit the file structure listed
-m,–megabytes is like –block-size=1048576
–no-sync get information before the Sync (preset)
-p,–   Portability uses the POSIX output format
–sync sync before getting information
-t,–type=type limits the type
-t,–print-type display file system in which the file system is listed
-x,–exclude-type=type Limit list file system do not display type
-V (ignore)
–help Display this helper and leave
–version output version information and leave

mkdir Use Rights: All users with appropriate permissions in the current directory
Use mode: mkdir [-P] DirName
Description: Create a subdirectory named DirName.
Parameter:-P to ensure that the directory name exists, do not exist on the build one.
Example:
In the working directory, create a subdirectory named AAA:
mkdir AAA
In the BBB directory under the working directory, create a subdirectory named Test. If the BBB directory does not exist, then establish a. (Note: If this example does not add-p, and the original BBB directory does not exist, then produce an error.) )
Mkdir-p Bbb/test

Mount usage rights: Users allowed in system managers or/etc/fstab


How to use:


Mount [-HV]


mount-a [-FFNRSVW] [-t Vfstype]


Mount [-FNRSVW] [-O options [,...]] device | Dir


Mount [-FNRSVW] [-t vfstype] [-O options] Device dir


Description


Interpret the contents of a file as a file system, and then hang it over a location in the directory. After this command has been successfully executed, all files under this command will not be invoked until we use Umnount to remove the file system.


This command can be used to hang up any file system, and you can even use the-o loop option to put a generic file on a hard drive partition system. This feature is useful for interpreting ramdisk,romdisk or ISO 9660 image files.


Parameters


-V


Show Program version


-H


Show secondary messages


-V


Displays more messages, usually with-F for debugging.


-A


Hang all the file systems defined in the/etc/fstab.


-F


This command is typically used with-a, which produces a stroke for each mount action. You can speed up the action when the system needs to hang a large number of NFS file systems.


-F


Usually used in the use of the debugging. It causes the mount to not perform the actual hanging action, but rather simulates the entire hanging process. is typically used with-V.


-N


In general, the mount will write a piece of data in the/etc/mtab after hanging. However, this option can be used to cancel this action if there is no writable file system in the system.


-s-r


equals-o ro


-W


Equals-o RW


-L


Hangs the hard drive partition that contains a specific label.


-U


Hang the file system with the file split serial number. -L and-u must be meaningful when/proc/partition such a file exists.


-T


Specifies the type of the file system, which is not usually specified. Mount will automatically select the correct form.


-O Async


Open asynchronous mode, all file read and write actions will be performed in asynchronous mode.


-O Sync


Executes in synchronous mode.


-O Atime


-O Noatime


When Atime is open, the system updates the file's "Last Call time" every time the file is read. When we use the Flash archive system, we may be able to turn this option off to reduce the number of writes.


-O Auto


-O Noauto


Turn on/off auto suspend mode.


-O Defaults


Use preset options rw, suid, dev, exec, auto, Nouser, and async.


-O Dev


-O nodev-o exec


-O noexec


Allow execution of the file to be executed.


-O suid


-O Nosuid


Allows the execution of files to execute under root permissions.


-O User


-O Nouser


The user can perform mount/umount actions.


-O remount


Put an already-hung file system back in a different way. For example, a system that was previously read-only is now hung up in a read-write mode.


-O ro


Hang on with read-only mode.


-O RW


Hangs in a writable mode.


-O loop=


Use the loop mode to suspend a file as a hard disk partition system.


Example


Hang the/dev/hda1 under the/mnt.


#mount/dev/hda1/mnt


The/dev/hda1 is hung under/mnt with the read-only mode.


#mount-O ro/dev/hda1/mnt


Use the loop mode to hang the image file of/tmp/image.iso this disc under/mnt/cdrom. In this way, you can view the contents of the Linux CD ISO file that can be found on a general network without being burned into a CD.


#mount-O Loop/tmp/image.iso/mnt/cdrom


Related Commands Umount

1.1 DD
1.1.1 Function Description
Read, convert, and output data.

1.1.2 Syntax
dd [bs=< bytes >][cbs=< bytes >][conv=< keywords >][count=< blocks & gt;] [ibs=< byte number "] [if=< file "] [obs=< byte number "] [of=< file "] [seek=< block Number "] [skip=< block Number "] [--help] [--version]

1.1.3 Supplementary note
DD can read data from standard inputs or files, transform data in a specified format, and then output to a file, device, or standard output.

1.1.4 parameters
bs=< bytes > Sets the IBS (input) and the OBS (output) to the specified number of bytes.
cbs=< bytes > conversions, only the specified number of bytes is converted at a time.

conv=< keywords > Specify how files are converted.

Conv = ASCII converts EBCDIC code to Ascil code.

Conv = EBCDIC converts ascil code to EBCDIC code.

CONV = IBM converts ascil code to alternate EBCDIC code.

CONV = block Converts a bit of change to a fixed character.

CONV = Ublock Converts a fixed bit into a change bit.

CONV = UCase converts letters from lowercase to uppercase.

CONV = LCase converts letters from uppercase to lowercase.

CONV = Notrunc does not truncate the output file.

CONV = Swab Exchange Each pair of input bytes.

CONV = NoError does not stop processing when an error occurs.

Conv = sync the size of each input record to the size of the IBS (filled with nul).

count=< block Count > read only the specified number of blocks.

The number of bytes ibs=< > bytes per read.

if=< file > read from file.

Number of bytes obs=< > bytes per output.

of=< file > output to file.

seek=< block count > First output, skip the specified number of blocks.

Number of skip=< blocks > skips the specified number of blocks at the start of a read.

–help Help.

–version Displays version information.

1.1.5 Example
1 full disk data backup and recovery

Backup:

DD IF=/DEV/HDX Of=/dev/hdy

Back up the local/DEV/HDX whole disk to/dev/hdy

DD IF=/DEV/HDX Of=/path/to/image

/DEV/HDX The overall data back to the image file of the specified path

DD IF=/DEV/HDX | Gzip >/path/to/image.gz

Back up/DEV/HDX overall data and use the Gzip tool to compress and save to the specified path

Recovery:

DD If=/path/to/image OF=/DEV/HDX

Restore the backup file to the specified disk

gzip-dc/path/to/image.gz | DD OF=/DEV/HDX

Restores a compressed backup file to a specified disk

2. Remote backup using Netcat

DD If=/dev/hda bs=16065b | Netcat < TARGETHOST-IP > 1234

Perform this command backup on the source host/dev/hda

Netcat-l-P 1234 | DD OF=/DEV/HDC bs=16065b

Executes this command on the destination host to receive data and write to/DEV/HDC

Netcat-l-P 1234 | bzip2 > Partition.img

Netcat-l-P 1234 | gzip > Partition.img

The above two instructions are the purpose of the host instruction changes using BZIP2 gzip to compress the data, and save the backup file in the current directory.

3. Backup MBR

Backup:

DD IF=/DEV/HDX of=/path/to/image count=1 bs=512

The backup disk starts with the 512Byte size of MBR information to the specified file

Recovery:

DD If=/path/to/image OF=/DEV/HDX

Write back up the MBR information to the beginning of the disk

4. Backup floppy disk

DD if=/dev/fd0 of=disk.img count=1 bs=1440k

Back up the floppy drive data to the Disk.img file in the current directory

5. Copy the memory data to the hard disk

DD If=/dev/mem Of=/root/mem.bin bs=1024

Copy the data in memory to the Mem.bin file in the root directory

6. Copy ISO image from CD

DD If=/dev/cdrom Of=/root/cd.iso

Copy the disc data to the root folder and save it as a Cd.iso file

7. Increase the size of the swap partition file

DD If=/dev/zero of=/swapfile bs=1024 count=262144

Create a file that is large enough (256M here)

Mkswap/swapfile

Turn this file into a swap file

Swapon/swapfile

Enable this swap file

/swapfile Swap Defaults 0 0

Automatically load the swap file every time you turn on, you need to add a row to the/etc/fstab file

8. Destroying disk data

DD If=/dev/urandom OF=/DEV/HDA1

The use of random data to fill the hard disk, in some necessary occasions can be used to destroy data. After you do this, the/dev/hda1 will not mount, and the Create and copy operations cannot be performed.

9. Get the most appropriate block size

DD If=/dev/zero bs=1024 count=1000000 of=/root/1gb.file

DD If=/dev/zero bs=2048 count=500000 of=/root/1gb.file

DD If=/dev/zero bs=4096 count=250000 of=/root/1gb.file

DD If=/dev/zero bs=8192 count=125000 of=/root/1gb.file

The optimal block size of the system can be determined by comparing the command execution time shown in the DD instruction output

10. Test hard disk read and write speed

DD If=/root/1gb.file bs=64k | DD Of=/dev/null

DD If=/dev/zero of=/root/1gb.file bs=1024 count=1000000

The read/write speed of the test hard disk can be computed by the execution time of the two command output

11. Repair the hard drive

DD IF=/DEV/SDA OF=/DEV/SDA

Magnetic flux point is generated on the disk when the hard drive is not used for a long time (for example, 1, 2 years). When the head is read to these areas, it encounters difficulties and can cause I/O errors. When this condition affects the first sector of the hard disk, it may cause the hard drive to scrap. The commands above may bring the data back to the dead. And the process is safe and efficient.

1.2 DF
1.2.1 Function Description
Displays information about the disk.

1.2.2 Syntax
DF [-ahhiklmpt][--block-size=< Chunk Size >][-t < file system Type >][-x < file system type >][--help][--no-sync][--sync][-- version][files or Devices]

1.2.3 Supplementary note
DF Displays the file system and usage situation of the disk.

1.2.4 Parameters
-A or –all contains all file systems.

–block-size=< Chunk Size > Displays the number of blocks by the specified chunk size.

-H or –human-readable display information in a more readable manner.

The-H or –si is the same as the-h parameter, but is calculated using 1000 Bytes as the conversion unit instead of 1024 Bytes.

-I or –inodes display information about the inode.

-K or –kilobytes specifies a chunk size of 1024 bytes.

-L or –local only displays the file system on the local side.

-M or –megabytes specifies a chunk size of 1048576 bytes.

–no-sync do not perform sync instructions, which is a preset value, before obtaining disk usage information.

-P or –portability uses the POSIX output format.

–sync performs the sync instruction before obtaining the disk usage information.

-t< file System type > or –type=< file system type > displays only disk information for the specified file system type.

-T or –print-type displays the file system type.

-x< file System type > or –exclude-type=< file system type > do not display disk information for the specified file system type.

–help display Help.

–version Displays version information.

[File or device] specifies the disk device.

1.3 du
1.3.1 Function Description
Displays the size of the directory or file.

1.3.2 Syntax
Du [-abcdhhklmssx][-l < symbolic connection >][-x < file >][--block-size] [--exclude=< directory or file >][--max-depth=< number of directory layers >][--help][--version][directory or file]

1.3.3 Supplementary note
DU displays the disk space occupied by the specified directory or file.

1.3.4 parameters
A or-all displays the size of individual files in the directory.

-B or-bytes displays the directory or file size in bytes.

-C or –total displays the sum of all directories or files in addition to the size of individual directories or files.

-D or –dereference-args displays the source file size for the specified symbolic connection.

-H or –human-readable to k,m,g to improve the readability of the information.

The-H or –si is the same as the-h parameter, but K,m,g is a unit of conversion in 1000.

-K or –kilobytes in 1024 bytes.

-L or –count-links a file that calculates hardware connections repeatedly.

The source file size for the symbol connection specified in the-l< symbol connection > or –dereference< symbol connection > Display option.

-M or –megabytes is in 1MB.

-S or –summarize displays totals only.

When-S or –separate-dirs displays the size of an individual directory, it does not contain the size of its subdirectories.

-X or –one-file-xystem the file system at the start of the process, and if you encounter a different file system directory, skip.

-x< files > or –exclude-from=< files > specify directories or files in < file >.

–exclude=< directory or File > skips the specified directory or file.

–max-depth=< the directory layer > beyond the specified number of layers, ignored.

–help display Help.

–version Displays version information.

1.4 Fdisk
1.4.1 Function Description
Disk partitions.

1.4.2 syntax
fdisk [-b < partition size >][-uv][Peripheral code] or Fdisk [-l][-b < partition size >][-uv][peripheral device code ...] or Fdisk [-s < partition number]

1.4.3 Supplementary note
FDISK is a disk partitioning program that uses a traditional question-and-answer interface, rather than a cfdisk interactive interface like DOS Fdisk, so it is inconvenient to use, but does not have a compromised function.

1.4.4 parameters
-b< Partition Size > Specify the size of each partition.

-l lists the partition table status of the specified peripherals.

The-s< partition number > outputs the specified partition size to the standard output, in blocks.

-U with the "-l" argument list, the number of partitions is replaced by the number of columns to represent the starting address for each partition.

-V Displays version information.

1.5 format
1.5.1 Function Description
Format the disk. It is best to use an unformatted disk.

1.5.2 syntax
format [-n] Device

-N floppy is formatted without checking.

1.5.3 Supplementary note
DOS format a: In fact, the following work is done:

(1) Physical format of the disk;

(2) Establish a: This directory (=linux in the establishment of a file system);

(3) Enable this disk to be used by the user (mount a drive in =linux).

These three steps are separate in Linux, you can build and use MS-DOS disks in Linux, and other formats (such as the most commonly used ext2), and the following is an available disk method:

(1) First Su as root

(2) format a 1.44M floppy disk (a:)

# fdformat/dev/fd0h1440

(3) Establishment of a file system:

# mkfs-t Ext2-c/dev/fd0h1440 (Create a ext2 file system)

or # Mformat A: (Establish an MS-DOS file system)

Before using this disk, you need to first connect this disk to the drive Mount,mount a drive:

# mount-t Ext2/dev/fd0/mnt

or # mount-t Msdos/dev/fd0/mnt

Now you can use this disk, and when you want to take out the disk, be sure to umount!

# umount/mnt

Now you can take the disk out.

Fdformat and MKFS are best used only for unformatted disks and have done so that they do not need to use these two commands.

To use the B drive, replace the fd0h1440 and fd0 in the previous article with fd1h1440 and FD1. In this way, previous work on A:,b: Now all are transferred to the/mnt operation, for example:

DOS Linux

C:guido>dir A: $ ls/mnt

C:guido>copy a:*.* docs emp $ cp/mnt/*/docs/temp

C:guido>copy *.zip A:zip $ cp *.zip/mnt/zip

C:guido>a: $ cd/mnt

A:>/mnt$

Using a hard disk is similar to a floppy disk, for example, you can mount a hard drive or optical drive, and slightly change the device under/dev, such as mount an optical drive: # mount-t Iso9660/dev/cdrom/cdrom

1.6 Free
1.6.1 Function Description
Displays the memory status.

1.6.2 syntax
Free [-bkmotv][-s < interval seconds]

1.6.3 Supplementary note
The free instruction displays memory usage, including entity memory, virtual swap file memory, shared memory segment, and buffer used by the system core.

1.6.4 parameters
-B Displays memory usage in byte.

-K displays memory usage in kilobytes.

-m displays memory usage in MB.

-O does not display buffer throttling columns.

-s< interval seconds > Continuous observation of memory usage.

-T displays the memory sum column.

-V Displays version information.

1.7 Mount
1.7.1 function Description
Mount the file system.

1.7.2 syntax
Mount [-t vfstype] [-O options] Device dir

which

1.-t vfstype Specifies the type of file system, which is not usually specified. Mount automatically selects the correct type. Common types are:

Optical or optical Image: iso9660

DOS FAT16 file system: MSDOS

Windows 9x FAT32 file system: VFAT

Windows NT NTFS file system: NTFS

Mount Windows file network share: SMBFS

UNIX (LINUX) file network share: NFS

2.-o options are mainly used to describe how devices or files are hooked up. The commonly used parameters are:

Loop: Used to mount a file as a hard disk partition to connect the system

RO: Use read-only way to hook up equipment

RW: Hook up device with read-write mode

Iocharset: Specifies the character set used to access the file system

3.device the device to hook up (Mount).

4.dir device mount point on the system.

1.7.3 Example
1.7.3.1 production and mounting of CD-ROM ISO documents
1. Make CD-ROM image files from CD-ROM. Put the CD into the CD drive and execute the following command.

#cp/dev/cdrom/home/sunky/mydisk.iso or

#dd If=/dev/cdrom Of=/home/sunky/mydisk.iso

Note: Perform any of the above commands to make the CD-ROM image file in the current CD-ROM/home/sunky/mydisk.iso

2, the files and directories made into a CD-ROM image files, to execute the following command.

#mkisofs-R-j-v Mydisk-o/home/sunky/mydisk.iso/home/sunky/mydir

Note: This command makes a CD-ROM image file of all directories and files in the/home/sunky/mydir directory/home/sunky/mydisk.iso, and the disc volume is labeled: Mydisk

3, CD-ROM image file Hook (mount)

#mkdir/mnt/vcdrom

Note: Create a directory for hanging contacts (mount point)

#mount-O loop-t iso9660/home/sunky/mydisk.iso/mnt/vcdrom

Note: Use/mnt/vcdrom to access all files in the disk image file Mydisk.iso.

1.7.3.2 mounted removable hard drive
For Linux systems, the USB interface's removable hard disk is treated as a SCSI device. Before you insert a mobile hard disk, you should use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partitions.

[Root at Pldyrouter/]# fdisk-l

disk/dev/sda:73 Dot 4 GB, 73407820800 bytes

255 heads, Sectors/track, 8924 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 4 32098+ de Dell Utility

/DEV/SDA2 * 5 2554 20482875 7 Hpfs/ntfs

/dev/sda3 2555 7904 42973875 Linux

/DEV/SDA4 7905 8924 8193150 f Win95 Ext ' d (LBA)

/dev/sda5 7905 8924 8193118+ Linux Swap

It is clear here that the system has a SCSI hard drive/DEV/SDA and its four partition/dev/sda1-/dev/sda4,/DEV/SDA5 is the logical partition of the partition/DEV/SDA4. After you have moved the hard disk, then use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partition

[Root at Pldyrouter/]# fdisk-l

disk/dev/sda:73 Dot 4 GB, 73407820800 bytes

255 heads, Sectors/track, 8924 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 4 32098+ de Dell Utility

/DEV/SDA2 * 5 2554 20482875 7 Hpfs/ntfs

/dev/sda3 2555 7904 42973875 Linux

/DEV/SDA4 7905 8924 8193150 f Win95 Ext ' d (LBA)

/dev/sda5 7905 8924 8193118+ Linux Swap

disk/dev/sdc:40.0 GB, 40007761920 bytes

255 heads, Sectors/track, 4864 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDC1 1 510 4096543+ 7 Hpfs/ntfs

/DEV/SDC2 511 4864 34973505 F Win95 Ext ' d (LBA)

/DEV/SDC5 511 4864 34973473+ b Win95 FAT32

You should be able to find one more SCSI hard drive/DEV/SDC and its two partition/DEV/SDC1,/DEV/SDC2, where/DEV/SDC5 is the logical partition of the/DEV/SDC2 partition. We can use the following command to hook up/DEV/SDC1 and/DEV/SDC5.

#mkdir-P/MNT/USBHD1

#mkdir-P/MNT/USBHD2

Note: Create a directory to use for hanging contacts (mount point)

#mount-T NTFS/DEV/SDC1/MNT/USBHD1

#mount-T VFAT/DEV/SDC5/MNT/USBHD2

Note: Disk partitions in NTFS format should use the-T NTFS parameter, and the-T VFAT parameter should be used for disk partitions in FAT32 format. If the Chinese character file name appears garbled or does not display, you can use the following command format.

#mount-T Ntfs-o iocharset=cp936/dev/sdc1/mnt/usbhd1

#mount-T Vfat-o iocharset=cp936/dev/sdc5/mnt/usbhd2

Using the Fdisk partitioning command and the Mkfs file system creation command on Linux systems, you can make partitions of a removable hard disk into a ext2, ext3 format that is unique to the Linux system. In this way, it is more convenient to use Linux. Use the following command to hook up directly.

#mount/DEV/SDC1/MNT/USBHD1

1.7.3.3 Hook up u disk
As with the USB interface of the mobile hard disk on the Linux system as a USB disk is treated as a SCSI device. Using the method is exactly the same as moving the hard disk. Before inserting a U disk, you should use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partitions.

[Root at Pldyrouter root]# fdisk-l

disk/dev/sda:73 Dot 4 GB, 73407820800 bytes

255 heads, Sectors/track, 8924 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 4 32098+ de Dell Utility

/DEV/SDA2 * 5 2554 20482875 7 Hpfs/ntfs

/dev/sda3 2555 7904 42973875 Linux

/DEV/SDA4 7905 8924 8193150 f Win95 Ext ' d (LBA)

/dev/sda5 7905 8924 8193118+ Linux Swap

Insert a U disk, then use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partitions.

[Root at Pldyrouter root]# fdisk-l

disk/dev/sda:73 Dot 4 GB, 73407820800 bytes

255 heads, Sectors/track, 8924 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 4 32098+ de Dell Utility

/DEV/SDA2 * 5 2554 20482875 7 Hpfs/ntfs

/dev/sda3 2555 7904 42973875 Linux

/DEV/SDA4 7905 8924 8193150 f Win95 Ext ' d (LBA)

/dev/sda5 7905 8924 8193118+ Linux Swap

disk/dev/sdd:131 MB, 131072000 bytes

9 Heads, Sectors/track, 888 cylinders

Units = Cylinders of 147456 bytes

Device Boot Start End Blocks Id System

/DEV/SDD1 * 1 889 127983+ b Win95 FAT32

Partition 1 has different physical/logical endings:

phys= (1000, 8) logical= (888, 7, 31)

The system has a SCSI hard drive/DEV/SDD and a disk partition/dev/sdd1,/dev/sdd1 is the U disk we want to hook up.

#mkdir-P/MNT/USB

Note: Create a directory for hanging contacts (mount point)

#mount-T Vfat/dev/sdd1/mnt/usb

Note: Now you can access the U disk by/mnt/usb, if the Chinese character file name is garbled or not displayed, you can use the following command.

#mount-T Vfat-o iocharset=cp936/dev/sdd1/mnt/usb

1.7.3.4 hook up Windows file share
The core of Windows network sharing is smb/cifs, where you must install and use the Samba package to connect (mount) Windows disk sharing under Linux. Most popular Linux distributions now contain samba packages, and if you install the Linux system without samba, install Samba first. Of course, can also be downloaded to the www.samba.org website ... The new version is the 3.0.10 version.

When Windows system sharing is set up, you can hook up the Linux client (mount), as follows:

# Mkdir–p/mnt/samba

Note: Create a directory for hanging contacts (mount point)

# mount-t Smbfs-o username=administrator,password=pldy123//10.140.133.23/c$/mnt/samba

Note: The Administrator and pldy123 are a user name and password for the IP address 10.140.133.23 Windows computer, and C $ is a disk share for this computer. This allows access to the files on the Windows system disk via/mnt/samba on the Linux system.

1.7.3.5 Hook up UNIX system NFS file sharing
Similar to Windows network sharing, UNIX (Linux) systems also have their own network share, that is, NFS (Network File system), below we take the Sun Solaris2.8 and Redhat as server 3 For example, let's take a look at how to mount an NFS network share under Linux.

Before Linux client Hook (Mount) NFS disk sharing, you must first configure the NFS server.

1, the Solaris System NFS Service-side configuration method is as follows:

(1) Modify/etc/dfs/dfstab, add the shared directory

Share-f Nfs-o Rw/export/home/sunky

(2) Start NFS Service

#/etc/init.d/nfs.server Start

(3) After the NFS service is started, you can also use the following command to add new shares

# Share/export/home/sunky1

# Share/export/home/sunky2

Note:/export/home/sunky and/export/home/sunky1 are the directories to be shared

2, the Linux system NFS server configuration methods are as follows:

(1) Modify/etc/exports, add the shared directory

/export/home/sunky 10.140.133.23 (rw)

/export/home/sunky1 * (rw)

/export/home/sunky2 linux-client (rw)

Note: The Sunky, Sunky1, sunky2 in the/export/home/directory are ready to share, 10.140.133.23, *, linux-client are the IP addresses or host names that are allowed to hook up this shared Linux client. If you want to use host name linux-client you must add the Linux-client host IP definition to the server-side host/etc/hosts file. The format is as follows:

10.140.133.23 linux-client

(2) Start and stop NFS services

/etc/rc.d/init.d/portmap Start (Portmap is started by default in Redhat)

/etc/rc.d/init.d/nfs Start Server for NFS

/etc/rc.d/init.d/nfs Stop stopping NFS services

Note: If you modify the/etc/export file to add new shares, you should stop the NFS service before starting the NFS service to make the newly added share work. The same effect can be achieved by using command EXPORTFS-RV.

3, Linux client Hook (mount) other Linux systems or UNIX system NFS sharing

# Mkdir–p/mnt/nfs

Note: Create a directory for hanging contacts (mount point)

#mount-t Nfs-o RW 10.140.133.9:/export/home/sunky/mnt/nfs

Note: Here we assume that 10.140.133.9 is the host IP address of the NFS server, and of course the hostname can be used here, but the server-side IP definition must be added to the native/etc/hosts file. /export/home/sunky is a directory shared by the service side.

1.8 Umount
1.8.1 function Description
Remove the file system.

1.8.2 syntax
Umount [-ahnrvv][-t < file system type >][file system]

1.8.3 Supplementary note
Umount can dismount a file system currently attached to a Linux directory.

1.8.4 parameters
-A dismount all file systems recorded in the/etc/mtab.

-h displays Help.

Do not save the information in the/etc/mtab file when-n dismount.

-R attempts to reseat the file system in a read-only manner if the removal cannot be successful.

-t< file System type > Remove only the file system specified in the option.

-V displays detailed information when executing.

-V Displays version information.

The

File system]   can represent the file system with either a device name or a mount point, in addition to specifying the file system directly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.