linux 加装硬盘(linux添加新硬盘怎么做)

点击量:9420 来源:解译网 发表时间:2023-01-30 10:08作者:秋天

有很多朋友在寻找linux添加新硬盘怎么做相关的资料,本文为大家罗列出linux 加装硬盘一些文章介绍,希望可以帮忙到需要的朋友。如果用得上记得收藏。

本文目录一览:

1、Linux下为LVM更换硬盘操作

2、linux下如何挂载硬盘?

3、Linux机器添加硬盘后的使用方式,手把手教你具体操作步骤

4、如何挂载硬盘(在linux中)?

Linux下为LVM更换硬盘操作

在我们使用 Linux 操作系统时,有时我们可能因为硬盘故障、或者需要升级硬盘,这时候我们就需要做更换硬盘的操作。

以下将以 Ubuntu 系统,LVM 分区 作为例子,简单介绍如何给 Linux 系统下 LVM 磁盘分区作更换硬盘操作。

操作大致分为以下几个步骤:

1- 添加新的硬盘到需要更换的 VG卷

2- 迁移旧硬盘的数据到新的硬盘中

3- 检查确认数据

4- 删除旧硬盘

为方便说明,以下为不同硬盘的标记

旧硬盘 → /dev/sda

新硬盘 → /dev/sdb

其中, /dev/sda 中有一分区 /dev/sda1 ,且当前存在一个 vg_store VG卷,存在一个 store 的 LV 卷。

以上默认假设为新硬盘容量至少大于等于旧硬盘已有的数据容量大小

成分区操作后,为新硬盘创建 PV卷

然后将新的物理卷添加到现有的VG卷中

检查PV卷是否已经成功添加,检查新硬盘容量是否满足要求

使用 pvmove 迁移数据

linux下如何挂载硬盘?

1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘

#fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

2.格式化硬盘

#mkfs -t ext4 /dev/sdb

3.挂载硬盘

#mount 硬盘地址 要挂载的地址

#mount /dev/sdb /media/imgs

4.实现系统重启后自动挂载该分区

#vi /etc/fstab

在最后一行添加

/dev/sdb /media/imgs ext4 defaults 1 2

一、添加磁盘

添加加新硬盘重启服务器

添加完之后就可以重启机器了,如果你机器是开启的,进入系统并不能看见你刚添加的那块磁盘,只有等系统重启,重新加载之后才会显示安装的那块磁盘

二、进入系统

使用root用户进入系统

三、 查看硬盘信息

[root@localhost ~]# fdisk -l   //磁盘命令

1

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x000c4cb5

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        2611    20458496   8e  Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0xd0f5c869

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2610    20964793+  83  Linux

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x00000000

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

可以看到这台机器加载了三个磁盘sda、sdb、sdc

其中sda是初始磁盘,sdb已经初始化且经过使用,sdc是刚刚加载的,未格式化的新磁盘

四、创建新硬盘分区

[root@localhost ~]# fdisk /dev/sdc #进入磁盘

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x45a3cadb.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): m

Command action

a   toggle a bootable flag      #设定可启动标记

b   edit bsd disklabel

c   toggle the dos compatibility flag

d   delete a partition          #删除一个分区

l   list known partition types  #各分区类型所对应的ID

m   print this menu             #菜单

n   add a new partition         #添加一个分区

o   create a new empty DOS partition table

p   print the partition table   #显示该磁盘下的当前分区信息

q   quit without saving changes #不保存退出

s   create a new empty Sun disklabel

t   change a partition's system id

u   change display/entry units

v   verify the partition table

w   write table to disk and exit #保存退出

x   extra functionality (experts only)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

知道命令之后就可以进行分区了

Command (m for help): p //打印分区信息,可以看到当前并没有分区

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x45a3cadb

Device Boot      Start         End      Blocks   Id  System

Command (m for help): n //创建一个新的分区

Command action

e   extended//输入e为创建扩展分区

p   primary partition (1-4) //输入p为创建逻辑分区

p

Partition number (1-4): 1//划分逻辑分区

First cylinder (1-2610, default 1): //我这里直接回车,是不想把该磁盘分成多个分区,把整个磁盘作为1个分区

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):

Using default value 2610

Command (m for help): p //再次查看可以看到该磁盘已经有1个分区了

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x45a3cadb

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        2610    20964793+  83  Linux

Command (m for help): w //保存分区

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

再次使用”fdisk -l”命令查看磁盘信息

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x406a4c58

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        2610    20964793+  83  Linux

1

2

3

4

5

6

7

8

9

第三块磁盘/dev/sdc已经分区好了

五、格式化分区

[root@localhost ~]# mkfs.ext3 /dev/sdc1

//将/dev/sdc1格式化为ext3类型,好像大部分的磁盘都是格式化为ext3类型,具体为什么没有深入研究,暂时不清楚,想了解的朋友可以自己查一下

1

2

[root@localhost ~]# mkfs.ext3 /dev/sdc1

mke2fs 1.41.12 (17-May-2010)

文件系统标签=

操作系统:Linux

块大小=4096 (log=2)

分块大小=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

1310720 inodes, 5241198 blocks

262059 blocks (5.00%) reserved for the super user

第一个数据块=0

Maximum filesystem blocks=4294967296

160 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000

正在写入inode表: 完成                          

Creating journal (32768 blocks): 完成

Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 31 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

格式化完毕,此时就可以使用“mount”命令挂载分区了,然后使用这个磁盘空间

六、挂载分区以及开机自动挂载

[root@localhost ~]# df -h //此时只有sda1和sdb1两个磁盘挂载

Filesystem                    Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root   18G   15G  1.5G  92% /

tmpfs                         932M   76K  932M   1% /dev/shm

/dev/sda1                     485M   40M  421M   9% /boot

/dev/sdb1                      20G  1.2G   18G   7% /disk/diskone

/dev/sr0                      4.2G  4.2G     0 100% /media/CentOS_6.5_Final

[root@localhost /]# cd /disk/

[root@localhost disk]# ll

总用量 4

drwxr-xr-x. 4 root root 4096 7月  28 17:04 diskone

[root@localhost disk]# cd diskone/

[root@localhost diskone]# ll

总用量 20

drwx------. 2 root root 16384 7月  28 16:12 lost+found

drwxr-xr-x. 2 root root  4096 7月  28 17:09 software

[root@localhost diskone]# cd ../

[root@localhost disk]# mkdir disktwo //创建被挂载的路径

[root@localhost disk]# ll

总用量 8

drwxr-xr-x. 4 root root 4096 7月  28 17:04 diskone

drwxr-xr-x. 2 r

Linux机器添加硬盘后的使用方式,手把手教你具体操作步骤

1、执行fdisk -l 查看新添加的硬盘,可以看到 sdb为新添加的硬盘。

2、fdisk /dev/sdb对新加硬盘格式化

3、输入m可以查看帮助

4、输入n新建分区,输入p新建主分区,输入1(主分区号),分别磁盘分区的起始终止位置,这里采用默认,即分区为硬盘大小。

5、输入w对分区进行保存

6、fdisk -l 查看分区,有了sdb1 ;输入mkfs.ext4将分区格式化为ext4格式

7、编辑/etc/fstab ,在最下面添加:

8、/dev/sdb1 /app ext4 defaults 0 0

9、使得磁盘开机挂载到/app

如何挂载硬盘(在linux中)?

Linux添加新硬盘自动挂载硬盘的具体步骤

1.插入新硬盘,启动Linux服务器,使用fdisk -l  查看硬盘

#fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

2.格式化硬盘

#mkfs -t ext4 /dev/sdb

3.挂载硬盘

#mount 硬盘地址  要挂载的地址

#mount /dev/sdb /media/imgs

4.实现系统重启后自动挂载该分区

#vi  /etc/fstab

在最后一行添加

/dev/sdb  /media/imgs                  ext4    defaults        1   2

Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的UNIX工具软件应用程序网络协议。它支持32位和64位硬件。Linux继承了Unix以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

Linux操作系统诞生于1991 年10 月5 日(这是第一次正式向外公布时间)。Linux存在着许多不同的Linux版本,但它们都使用了Linux内核。Linux可安装在各种计算机硬件设备中,比如手机平板电脑路由器视频游戏控制台、台式计算机、大型机和超级计算机。

严格来讲,Linux这个词本身只表示Linux内核,但实际上人们已经习惯了用Linux来形容整个基于Linux内核,并且使用GNU 工程各种工具和数据库的操作系统。

linux 加装硬盘(linux添加新硬盘怎么做)

以上就是linux添加新硬盘怎么做和linux 加装硬盘的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

  • 加装路由器怎么装

    网友孙金鹏提问:加装路由器怎么装 解译网将综合多位内业人士从不同角度和维度来解答 今天给各位分享加装路由器怎样接线的知识,其中也会

    2023-04-14阅读:0
  • 路由器加装铜片天线怎么设置

    网友陈海泉提问:路由器加装铜片天线怎么设置 解译网将综合多位内业人士从不同角度和维度来解答 今天给各位分享路由器加装铜片天线的知识

    2023-04-10阅读:1
  • 换天线能增强路由器信号吗

    网友周斌提问:换天线能增强路由器信号吗 解译网将综合多位内业人士从不同角度和维度来解答 本篇文章给大家谈谈天线可以加装路由器吗,以

    2023-04-08阅读:0
  • 路由器加装天线应该接在哪个线

    网友陈永昌提问:路由器加装天线应该接在哪个线 解译网将综合多位内业人士从不同角度和维度来解答 本篇文章给大家谈谈家用路由器天线安装

    2023-04-06阅读:0
  • 加装路由器怎么设置密码

    网友刘江提问:加装路由器怎么设置密码 解译网将综合多位内业人士从不同角度和维度来解答 今天给各位分享加装路由器怎么设置的知识,其中

    2023-04-02阅读:0
  • 软路由加装wifi

    网友李文妍提问:软路由加装wifi 解译网将综合多位内业人士从不同角度和维度来解答 本篇文章给大家谈谈软路由加装万兆网口,以及软路

    2023-03-31阅读:1
声明

删帖请联系zhiyihome@qq.com;