Diskmanage _ disk management

Source: Internet
Author: User
/* ---------------------------- Disk management -------------------------------------------*/

----- 'Uuuid' ---- (universally unique identifier) 'universal unique identifier'

1. The purpose of UUID is to allow all elements in a distributed system to have unique identifiers without specifying information through the central control terminal ..

2. Take a USB flash drive as an example. If a USB flash drive is divided into three zones, each zone is allocated with a uuid, which is recorded on the USB flash drive ',
Instead of in a system, the device names of USB flash drives are different in different systems.

---- View UUID & label command

'Blkid' -- command-line utility to locate/print block device attributes ('query block device attribute' command line Application)

1. blkid // view the detailed attributes of all Block devices under/dev/

2. blkid/dev/sda1 // view the properties of the specified device

3. blkid-s [type | UUID | label] // UUID of the block Monitoring Device | type | label

'/* Do not run the blkid/dev/* command on the virtual machine. The virtual machine suspends fedora and causes network disconnection */'


------- Application of 'uuid' & 'label --------

'Note': this will make the system more robust (strong): adding or removing a SCSI disk
Changes the disk device name but not the filesystem volume label.

---- Change the LABEL Name:

1. e2label/dev/hda1/boot // set the volume to '/boot' for/dev/hda1'


---- Use LABEL/UUID in the mount command

1. mount LABEL =/boot1/boot
Mount-L/boot/mnt/smbLung/

2. mount UUID = "51f7e9a4-5154-4e29-a7a6-208425290b85"/mnt/
Mount-U 7826f66e-4fdc-4ab8-9d95-6a1ddb1c7eaa/mnt/smbJon/




/** Files :*/

'/Etc/fstab file system table

'/Etc/mtab table of mounted file systems // fs found through mount


---- Use LABEL/UUID in/etc/fstab

1. LABEL = // ext3 defaults 1 1

2. LABEL =/boot1/boot ext3 defaults 1 2

3. UUID = e61f4197-5f00-4f4f-917c-290922a85339/usr ext3 defaults 1 12




******************* ****************

-------- File

1./proc/filesystems // a list of filesystem types to try

2./proc/Partitions // Partition Table; complete information not returned by fdisk-l

3./etc/fstab // file system table


------- Graphical Mount Tool

1. usermount // the root user executes this command

------- Command

-------- Fdisk (Partition Table Manipulator for Linux: 'partition table operator' in Linux ')-------------------------

Note: 'A'. It understands 'dos-type' partition tables and 'bsd-or sun-type disklabels .'

'B'. fdisk does not understand guid partition tables (GPTS) and it is 'not'
Designed for 'large partitions '. In these cases, use the more advanced
GNU 'parted' (8)
/* Fdisk is not applicable to large partitions. In this case, run the parted command */

0. fdisk-l [device] // list the partition tables of the specified device; If no devices are given,
// Those mentioned in/proc/partitions (if that exists) are used


1. A sync () are saved med before exiting when the partition table has been updated.
Note that both the kernel and the disk hardware may buffer data.

After modifying a partition table, we recommend that you use the sync () command to write data in the buffer zone to the disk.
Both the kernel and disk may buffer data.

2. For best results, you should always use an 'OS-specific partition table program'

A. 'Make DOS partitions 'with the 'dos FDISK program'
B. 'linux partition' with the 'linux fdisk program'




---------------- Df-report file system disk space usage ----------------- // view disk usage information

1. df-h // list in the human-readable format


------------------ Mount command

Mount-t vfat/dev/sdb1/mnt/usb //-t specify the File System

Mount-o iocharset = cp936/dev/sdb1/mnt/usb // display Chinese characters in the Window

Mount-a // mount all file systems set by fstab that do not use the noauto option as specified

------------------ Format a disk

/*** In order to make it possible to treat all types in a uniform way,
Mount will execute the program/sbin/mount. TYPE (if that exists)
When called with type TYPE.
***/

Mkfs-t ext3/dev/hd4 // format
Mkfs. ext3/dev/hd4

Mkfs-t vfat/dev/hd3
Mkfs. vfat/dev/hd3


--------- Tune2fs: Adjust the adjustable file system parameter on ext2/3/4 fs.

1. tune2fs-l/dev/sda1 // list the current parameters of the file system



--------- DD: Convert and copy a file: Convert and copy files

1. dd If =/dev/hdx of =/dev/hdy // back up the local/dev/hdx disk to/dev/hdy

------------

2. dd If =/dev/hdx of =/path/to/image // back up the full/dev/hdx data to the image file in the specified path:

3. dd If =/path/to/image of =/dev/hdx // restore the backup file to the specified Disk :,

------------

4. dd If =/dev/hdx | gzip>/path/to/image.gz // back up the full data of/dev/hdx, compress the data using the gzip tool, and save the data to the specified path:

5. gzip-DC/path/to/image.gz | dd OF =/dev/hdx // restore the compressed backup file to the specified Disk:

---- 'Backup MBR'

1. dd If =/dev/hdx of =/path/to/image COUNT = 1 bs = 512 // The MBR information of the 512byte size starting from the backup disk to the specified file:

2. dd If =/path/to/image of =/dev/hdx // write the backup MBR information to the start part of the Disk:

----- '. Copy the memory data to the hard disk'

1. dd If =/dev/MEM of =/root/MEM. Bin BS = 1024 // copy the data in the memory to the mem. binfile in the root directory:

----- 'Copy an ISO image from a cd

1. dd if =/dev/cdrom of =/root/cd. iso // copy the disc data to the root folder and save it as a cd. iso file:

----- 'Increase the size of the Swap partition File

1. dd if =/dev/zero of = swapfile bs = 1 M count = 100 // create a M empty file swapfile

2. mkswap swapfile

3. swapon swapfile // activate

4. swapon-s // view all swap files or partitions

5. mount-a (write the fstab file) // the rc. sysinit initialization script is activated upon restart. The system will be automatically mounted after it is started.


----- 'Destroy Disk Data

1. dd if =/dev/urandom of =/dev/hda1 // fill the hard disk with random data:
// Data can be destroyed when necessary. After this operation is performed, the/dev/hda1 cannot be mounted, and the creation and copy operations cannot be performed.

----- 'Repair the hard drive

/* When a hard disk is not used for a long time (for example, one or two years), a magnetic flux point is generated on the disk. When the head reads
These areas may encounter difficulties and may cause I/O errors. When this affects the first sector of the hard disk
Hard Disk decommission. The following command may bring the data back to life. This process is safe and efficient. */

1. dd if =/dev/sda of =/dev/sda



------ '/Dev/0': Special c file. When reading it, it provides ample null characters (ascii null, 0x00; not ASCII character "digit zero ", "0", 0x30)

---- Purpose

1. provide a character stream for overwriting information.

# Initialise partition (important note: trying out this command will eradicate
# Any files that were on the partition, make sure you have a backup of any important data .)

Dd if =/dev/zero of =/dev/hda7

2. Another might be to generate a clean file of a certain size.

# Create a large empty file called 'foobar'
Dd if =/dev/zero of = foobar count = 1000 bs = 1000

3. Using mmap to map/dev/zero to RAM is the BSD way of implementing shared memory.

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.