linux hangs on the hard disk

1. Use fdisk -l to view the detailed information of the hard disk

analyze:

2. Partition initialization

fdisk /dev/sdb

Analysis: analysis of each parameter

1. Enter m to display a list of all commands.

2. Enter p to display the hard disk partition and print the partition table.

3. Enter a to set the hard disk bootable area.

4. Enter n to set a new hard disk partition.

4.1. Input e, the hard disk is an [extended] partition (extend).

4.2. Input p The hard disk is the [primary] partition (primary).

5. Enter t to change the hard disk partition properties.

t: partition system id number

L:82:linux swap

83:linux

86: NTFS window partition

6. Enter d to delete the hard disk partition attribute.

7. Enter q to end the attribute of not saving the hard disk partition.

8. Enter w to end and write the properties of the hard disk partition

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 287 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 287 2611 18668544 83 Linux

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x02537cbf

Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux partition created successfully

Note: 1.

Partition number (1-4): 2 #If 1 partition has been created here, then 1 cannot be entered for this value.

3. Partitioned file system

Specify the file system for the partition: ext2 and ext3

mke2fs /dev/sdb1 #The default is ext2, this command is to create a file system

mke2fs -j /dev/sdb1 #-j is ext3

mke2fs -t ext4 /dev/sdb1 #ext4 to create a file system

e2fsck -p /dev/sdb1 #Check the file system: whether there is an error in the file or sector Parameter -p is automatic repair

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Analysis: After mounting for 37 or 180 days, check the file system
tune2fs -l /dev/sdb1 #View the detailed information of the file system

-l View details

-c 30 /dev/sdb1 How many checks to set (how many checks to mount)

-i 70d /dev/sdb1 70-day check (how many days to check)

e2label /dev/sdb1 www-data #specified label

findfs www-data #Find transscript

4. mount

vim /etc/fstab permanent mount configuration

Add the following to the file: /dev/sdb1 /opt ext3 defaults 1 1

mount : View the partition format

  -a 挂载信息立即生效

  -t ext3 /dev/sdb1 /opt 临时挂载linux分区

  -t vfat /dev/sdc1 //media/usb u盘挂载 window分区

  -o loop docs.iso /media/iso 挂载镜像文件

mount media/cdrom CD-ROM mount

umount /opt Unmount mount

5 successful

df -h : View the current hard disk usage

6. Supplementary NTFS mobile hard disk mount
First, you need a NTFS-3G tool, and after compiling it, you can mount it, it's that simple.

First, enter the official website to download the NTFS-3G tool

http://www.tuxera.com/community/ntfs-3g-download/

1. Unzip after downloading

wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz

tar -xvf ntfs-3g_ntfsprogs-2017.3.23.tgz

2. Compile and install

Enter the ntfs-3g_ntfsprogs-2017.3.23 folder

./configure && make && make install

ps: If it prompts that there is no gcc, then yum install gcc* will install the compilation environment and execute the above command once

The above command can also be executed three times

./configure

make

make install

3. Mount NTFS

mount -t ntfs-3g /dev/sda2 /mnt/Windows

ps: Mount will fail after reboot

4. CentOS 7 will automatically mount NTFS when booting (Of ​​course, if you don’t want to automatically mount, you can skip this step.)

Change /etc/fstab, backup before changing cp /etc/fstab /etc/fstab.bak

/dev/sda1 /mnt/windows ntfs-3g defaults 0 0

ps: If you don't know what sda is, just use fdisk -l to check the partition table. The mount point in /etc/fstab cannot have spaces, even if you use \ to escape the spaces, it seems useless (probably unsuccessful), this is personal experience.

For example: there is a mount point in fstab: /mnt/Virtual\ Machines. After saving and restarting, it will directly enter the read-only file system. At this time, you cannot modify the content in fstab. You can run the following command, and then restart vi.

mount -n -o remount, rw / Note that there is no space between the commas, and there is a space in front of /.

Then vi fstab deletes the mount point with spaces, which is /mnt/Virtual\ Machines.

Guess you like

Origin blog.csdn.net/mkleft/article/details/117044238