Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux mounts a new hard disk and automatically mounts it when booted.

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Hard disk recognition of Linux:

After 2.6kernel, linux will create the corresponding device file under / dev/ for the identified hardware devices. Such as:

Sda means the first SCSI hard drive. # V, z b,} 2F7u' |

Hda represents the first IDE hard drive (that is, connected to the Master port of the first IDE interface)

Scd0 represents the first USB CD-ROM drive.

When a new hard drive is added, the corresponding device files are generated in the / dev directory. Cciss's hard disk is an exception, its

The device file is in the / dev/cciss/ directory. Generally, you can use the "fdisk-l" command to list the hard drives currently connected to the system.

Device and partition information. If there is no partition information for the new hard disk, only the hard disk size information is displayed.

1. Shut down the server and add a new hard drive

two。 Start the server and log in as root user

3. View hard disk information

# fdisk-l

Disk / dev/sda: 146.1 GB, 146163105792 bytes

255 heads, 63 sectors/track, 17769 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 13 104391 83 Linux

/ dev/sda2 14 5112 40957717 + 83 Linux

/ dev/sda3 5113 5243 1052257 + 82 Linux swap /

Solaris

/ dev/sda4 5244 17769 100615095 5 Extended

/ dev/sda5 5244 17769 100615063 + 83 Linux

Disk / dev/sdb: 291.3 GB, 291331192320 bytes

255 heads, 63 sectors/track, 17769 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk / dev/sdb1: 291.3 GB, 291331192320 bytes

4. Create a new hard disk partition

Fdisk can use the m command to see the internal commands of the fdisk command

A: the command specifies the boot partition

D: command to delete an existing partition

L: the command displays a list of partition ID numbers

M: view fdisk command help

N: command to create a new partition

P: command displays a list of partitions

T: command to modify the type of partition ID number

W: the command is to save changes to the partition table to make it work.

# fdisk / dev/sdb

Command (m for help): n

Command action

E extended / / enter e to create an extended partition

P primary partition (1-4)

P

Partion number (1-4): 1

Command (m for help): W

Enter n enter, then enter p enter, then output 1 enter, all the way enter, and finally enter w to save.

Check it out:

Fdisk-l

You can see the / dev/sdb1 partition

5. Format the partition:

Mkfs.ext3 / dev/sdb1

6. Create the / data1 directory:

Mkdir / data1

7. Mount the partition:

Mount / dev/sdb1 / data1

8. Configure boot auto mount

Because the mount mount fails after restarting the server, you need to write the partition information to the / etc/fstab file so that it can be mounted permanently:

Vi / etc/fstab

Join:

LABEL=/data1 / data1 ext3 defaults 1 2

View cat / etc/fstab

LABEL=/ / ext3 defaults 1 1

LABEL=/data / data ext3 defaults 1 2

LABEL=/data1 / data1 ext3 defaults 1 2

LABEL=/boot / boot ext3 defaults 1 2

Tmpfs / dev/shm tmpfs defaults 0 0

Devpts / dev/pts devpts gid=5,mode=620 0 0

Sysfs / sys sysfs defaults 0 0

Proc / proc proc defaults 0 0

LABEL=SWAP-hda3 swap swap defaults 0 0

9. Restart the system

Cymbals

Load the second hard disk (8G), which is divided into three partitions, one primary partition (2G) and two logical partitions (3G respectively). Create a new directory / mnt/ljp1,/mnt/ljp2, and mount logical partition 1 and logical partition 2 of the second hard disk to / mnt/ljp1 and / mnt/ljp2, respectively (requires that the partition can be mounted automatically after the system boots).

Manual mount:

Mount / dev/sdb5 / mnt/ljp1

Mount / dev/sdb6 / mnt/ljp2

Auto mount:

Vi / etc/fstab

/ dev/sdb5 / mnt/ljp1 ext3 defaults 0 0

/ dev/sdb6 / mnt/ljp2 ext3 defaults 0 0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report