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

How to add a new hard disk under the linux system

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

Share

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

This article mainly introduces "how to add a new hard disk under the linux system". In the daily operation, I believe that many people have doubts about how to add a new hard disk under the linux system. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubts of "how to add a new hard disk under the linux system". Next, please follow the editor to study!

Fdisk-l # # here is to see how many hard drives there are on the system.

Disk / dev/sda: 36.4 GB, 36401479680 bytes

255 heads, 63 sectors/track, 4425 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 255 2048256 83 Linux

/ dev/sda2 256 1530 10241437 + 83 Linux

/ dev/sda3 4296 4425 1044225 82 Linux swap

/ dev/sda4 1531 4295 22209862 + f Win95 Ext'd (LBA)

/ dev/sda5 1531 2805 10241406 83 Linux

/ dev/sda6 2806 4295 11968393 + 83 Linux

Partition table entries are not in disk order

Disk / dev/sdb: 36.7G GB, 36703918080 bytes # # found here / dev/sdb, capacity 36.7G, and not partitioned

255 heads, 63 sectors/track, 4462 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk / dev/sdc doesn't contain a valid partition table

Connect the hard drive on the server, start linux, and log in as root.

For example, if I add a new SCSI hard drive, I need to divide it into three zones:

# fdisk / dev/sdb

Enter fdisk mode:

Command (m for help): P / / View the partition of the new hard disk

Command (m for help): n / / create a new partition

You can use the m command to see the internal command of the fdisk command; the n command to create a new partition; the d command to delete an existing partition; the p command to display a list of partitions; the t command to modify the partition type ID number; the l command to display a list of partition ID numbers; the a command to specify the boot partition; and the w command to save changes to the partition table to make it work.

Command action

E extended / / enter e to create an extended partition

P primary partition (1-4) / / enter p to create the primary partition, here we select p

Partion number (1-4): 1 / / the first extended partition, which can be divided into up to 4 primary partitions according to your needs

First Cylinder (1-1014): 1 / / the number of disk blocks starting from the first primary partition

Last cylindet or + siza or + sizeM or + sizeK: + 1024MB / / can be a number in MB or a number in

The number of disk blocks. Here we enter + 1024MB to indicate that the partition size is 1G.

In this way, we have finished creating a partition, and if you want to create more partitions, you can continue to create them as described above.

Save the partition with w after creation.

Command (m for help): W

The partition table has been altered!

Calling ioctl () to re-read partition table.

Syncing disks.

In this way, the partition is finished, and we have to format it.

# mkfs-t ext3-c / dev/sdb1 / / if there are multiple partitions, modify the partition to be like sdb2

After formatting, we need to mount the partition.

# mkdir www / / create / www directory, and we will hang the new partition under www

# mount / dev/sdb1 / www / / Mount / dev/sdb1 to / www

# df / / View with df command

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/sda2 3771316 1388956 2190788 39% /

/ dev/sda1 101089 9463 86407 10% / boot

None 62988 0 62988 / dev/shm

/ dev/sdb1 485906 8239 452580 2% / www / / see, this is what we just

Newly mounted partition

We are nearing the end of our work here, but if we end this way, we will have to restart the server every time.

Manual mount, which is troublesome, we need to modify the / etc/fstab file to mount automatically.

# vi / etc/fstab

Add the following at the end of the file:

/ dev/sdb1 / www ext3 defaults 1 2

If there are multiple partitions, you can modify sdb1 and / www, save after modification, and restart the server.

At this point, our work of adding a new hard drive is over.

At this point, the study on "how to add a new hard disk under the linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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